mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-07-09 23:02:11 -04:00
Editor sun face the camera
This commit is contained in:
@@ -306,7 +306,7 @@ bool IntersectRaySphere(const Ray& ray, const FVector& sphereCenter, float radiu
|
||||
// }
|
||||
|
||||
// Transform a matrix to a matrix identity
|
||||
void Editor_Matrixidentity(Mat4 mtx) {
|
||||
void Editor_MatrixIdentity(Mat4 mtx) {
|
||||
register s32 i;
|
||||
register s32 k;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ void Clear(MtxF* mf);
|
||||
bool IntersectRayTriangle(const Ray& ray, const Triangle& tri, const FVector& objectPos, float& t);
|
||||
bool IntersectRaySphere(const Ray& ray, const FVector& sphereCenter, float radius, float& t);
|
||||
|
||||
void Editor_Matrixidentity(Mat4 mtx);
|
||||
void Editor_MatrixIdentity(Mat4 mtx);
|
||||
void Editor_AddMatrix(Mat4 mtx, int32_t flags);
|
||||
float CalculateAngle(const FVector& start, const FVector& end);
|
||||
void SetDirectionFromRotator(IRotator rot, s8 direction[3]);
|
||||
|
||||
@@ -253,7 +253,7 @@ void Gizmo::DrawHandles() {
|
||||
|
||||
if (center) {
|
||||
Mat4 CenterMtx;
|
||||
Editor_Matrixidentity(CenterMtx);
|
||||
Editor_MatrixIdentity(CenterMtx);
|
||||
|
||||
// Calculate camera-to-object distance
|
||||
FVector cameraDir = FVector(Pos.x - cameras[0].pos[0], Pos.y - cameras[0].pos[1], Pos.z - cameras[0].pos[2]);
|
||||
|
||||
@@ -55,14 +55,29 @@ size_t LightObject::NumLights = 0;
|
||||
SetDirectionFromRotator(*Rot, Direction);
|
||||
}
|
||||
void LightObject::Draw() {
|
||||
Mat4 mtx;
|
||||
Mat4 mtx_sun;
|
||||
Editor_MatrixIdentity(mtx_sun);
|
||||
|
||||
// Calculate camera-to-object distance
|
||||
FVector cameraDir = FVector(LightPos.x - cameras[0].pos[0], LightPos.y - cameras[0].pos[1], LightPos.z - cameras[0].pos[2]);
|
||||
cameraDir = cameraDir.Normalize();
|
||||
|
||||
IRotator centerRot;
|
||||
SetRotatorFromDirection(cameraDir, ¢erRot);
|
||||
|
||||
// Account for object not facing the correct direction when exported
|
||||
centerRot.yaw += 0x4000;
|
||||
ApplyMatrixTransformations(mtx_sun, LightPos, centerRot, LightScale);
|
||||
Editor_AddMatrix(mtx_sun, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(gDisplayListHead++, sun_LightModel_mesh);
|
||||
|
||||
// Draw Arrow
|
||||
Mat4 mtx_arrow;
|
||||
IRotator rot = LightRot;
|
||||
rot.yaw += 0x4000;
|
||||
ApplyMatrixTransformations(mtx, LightPos, rot, LightScale);
|
||||
Editor_AddMatrix(mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(gDisplayListHead++, sun_LightModel_mesh);
|
||||
FVector scale = LightScale;
|
||||
ApplyMatrixTransformations(mtx_arrow, LightPos, rot, scale);
|
||||
Editor_AddMatrix(mtx_arrow, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(gDisplayListHead++, handle_Cylinder_mesh);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user