Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Calendis committed Jun 12, 2024
1 parent 7144f49 commit ff0e489
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
11 changes: 6 additions & 5 deletions magician/geo/Statics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public static class Ref
public static Node Perspective { get; }
public static Node Undefined { get; internal set; }
//public static List<Multi> AllowedOrphans;
public static Vec3 DefaultHeading = new(0,0,-1);
public static Vec3 DefaultHeading = new(0, 0, -1);
public static Vec3 DefaultUp = new(0, 1, 0);
public static double FOV
{
get => Perspective.Val;
Expand Down Expand Up @@ -99,9 +100,9 @@ public static Node Rect(double x, double y, double width, double height)
// new Renderer.Text("3", new RGBA(0xff0000e0), 20).Render()
//),
Point(0, -height)
//.Textured(
// new Renderer.Text("4", new RGBA(0xff0000e0), 20).Render()
//)
//.Textured(
// new Renderer.Text("4", new RGBA(0xff0000e0), 20).Render()
//)
).To(x, y);
}

Expand Down Expand Up @@ -179,7 +180,7 @@ public static Node TriPyramid(double x, double y, double z, double radius)
Node tetra = new(x, y, z, Mesh.SimplePyramid,
Create.RegularPolygon(3, radius)
.Add(
new Node[] { Create.Point(0, 0, Math.Sqrt(3)*radius) }
new Node[] { Create.Point(0, 0, Math.Sqrt(3) * radius) }
).ToArray()
);
return tetra;
Expand Down
19 changes: 5 additions & 14 deletions magician/paint/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,12 @@ public static void Clear()
public static unsafe void PrepareMatrices()
{
Node camera = Ref.Perspective;
//Matrix4X4<double> rot = Matrix4X4.CreateFromYawPitchRoll(camera.yaw, camera.pitch+Math.PI/2, camera.roll);
//Scribe.Info(camera.roll);
// Use quaternions to avoid gimbal lock
Quaternion<double> qYaw = Quaternion<double>.CreateFromYawPitchRoll(camera.yaw, 0, 0);
Quaternion<double> qPitch = Quaternion<double>.CreateFromYawPitchRoll(0, camera.pitch, 0);
Quaternion<double> qRoll = Quaternion<double>.CreateFromYawPitchRoll(0, 0, camera.roll);
Quaternion<double> rot = qPitch * qRoll * qYaw ;
Vector3D<double> defaultUp = new(0, 1, 0);
Vector3D<double> defaultHeading = new(0, 0, -1);
Vector3D<double> heading = Vector3D.Transform(defaultHeading, rot);
Vector3D<double> upV = Vector3D.Transform(defaultUp, rot);
double targX = camera.X + camera.Heading.X;
double targY = camera.Y + camera.Heading.Y;
double targZ = camera.Z + camera.Heading.Z;

double targX = camera.X + heading.X;
double targY = camera.Y + heading.Y;
double targZ = camera.Z + heading.Z;
Vector3D<double> defaultUp = new(0, 1, 0);
Vector3D<double> upV = Vector3D.Transform(defaultUp, camera.Rotation);

Matrix4X4<float> mview = Matrix4X4.CreateLookAt<float>(
new((float)camera.X, (float)camera.Y, (float)camera.Z),
Expand Down

0 comments on commit ff0e489

Please sign in to comment.