diff --git a/PluginCommon/AddressTranslate.cs b/PluginCommon/AddressTranslate.cs
index fd6af4e..d57ea72 100644
--- a/PluginCommon/AddressTranslate.cs
+++ b/PluginCommon/AddressTranslate.cs
@@ -82,7 +82,7 @@ namespace PluginCommon {
}
try {
byte foo = data[offset];
- } catch (Exception ex) {
+ } catch (Exception) {
throw new AddressTranslateException("FAILED at srcOff=$" + srcOffset.ToString("x4") +
" addr=$" + address.ToString("x4"));
}
diff --git a/PluginCommon/Interfaces.cs b/PluginCommon/Interfaces.cs
index 857362c..8da317f 100644
--- a/PluginCommon/Interfaces.cs
+++ b/PluginCommon/Interfaces.cs
@@ -326,9 +326,9 @@ namespace PluginCommon {
///
The wireframe generator may offer the choice of perspective vs. orthographic projection, and whether or not to enable backface -culling. If the generator doesn't provide them, the default is to -render with a perspective projection and without culling.
+culling. These are declared in the visualization generator script, +but implemented in the viewer. If the generator doesn't +declare them, the default is to render with a perspective projection +and without culling.The viewer allows you to rotate the image about the X, Y, and Z -axes. The viewer provides a conventional right-handed coordinate system, +axes. The viewer provides a left-handed coordinate system, with +X toward the right, +Y toward the top of the screen, and +Z -coming out of the screen. Positive rotations cause a counter-clockwise -rotation when looking down the axis in the positive direction. The +going into the screen. The object will be placed a short distance +down the Z axis and scaled to fit the window. +Positive rotations cause a counter-clockwise rotation when the axis +about which rotations are performed points toward the viewer. The rotations are performed with a matrix using Euler angles, and are subject to gimbal lock (e.g. if you set Y to 90 degrees, X and Z rotate about the same axis).
diff --git a/SourceGen/SGTestData/Visualization/wireframe-test b/SourceGen/SGTestData/Visualization/wireframe-test index 8f644ca..46d5d05 100644 Binary files a/SourceGen/SGTestData/Visualization/wireframe-test and b/SourceGen/SGTestData/Visualization/wireframe-test differ diff --git a/SourceGen/SGTestData/Visualization/wireframe-test.S b/SourceGen/SGTestData/Visualization/wireframe-test.S index e568f8b..d142799 100644 --- a/SourceGen/SGTestData/Visualization/wireframe-test.S +++ b/SourceGen/SGTestData/Visualization/wireframe-test.S @@ -3,6 +3,9 @@ ; ; Assembler: Merlin 32 +; Cube with a decoration on the front (should look like a "7"). +; Defined in a left-handed coordinate system (+Z away from viewer). + org $1000 lda vertices @@ -12,19 +15,19 @@ ; List of vertices (X,Y,Z). vertices - dfb -32,32,32 ;0 - dfb -32,-32,32 ;1 - dfb 32,-32,32 ;2 - dfb 32,32,32 ;3 - dfb -32,32,-32 ;4 - dfb -32,-32,-32 ;5 - dfb 32,-32,-32 ;6 - dfb 32,32,-32 ;7 + dfb -32,32,-32 ;0 + dfb -32,-32,-32 ;1 + dfb 32,-32,-32 ;2 + dfb 32,32,-32 ;3 + dfb -32,32,32 ;4 + dfb -32,-32,32 ;5 + dfb 32,-32,32 ;6 + dfb 32,32,32 ;7 -; put a decoration on the front face; should look like a '7' - dfb -20,-20,32 ;8 - dfb 20,20,32 ;9 - dfb 10,20,32 ;10 +; Put a decoration on the front face. + dfb -20,-20,-32 ;8 + dfb 20,20,-32 ;9 + dfb 10,20,-32 ;10 dfb $80 ; List of edges (vertex0, vertex1, face0, face1). @@ -48,8 +51,8 @@ edges ; List of faces (surface normal X,Y,Z). faces - dfb 0,0,1 ;0 front - dfb 0,0,-1 ;1 back + dfb 0,0,-1 ;0 front + dfb 0,0,1 ;1 back dfb 0,1,0 ;2 top dfb 0,-1,0 ;3 bottom dfb 1,0,0 ;4 right diff --git a/SourceGen/SGTestData/Visualization/wireframe-test.dis65 b/SourceGen/SGTestData/Visualization/wireframe-test.dis65 index c78de9b..c81b6a5 100644 --- a/SourceGen/SGTestData/Visualization/wireframe-test.dis65 +++ b/SourceGen/SGTestData/Visualization/wireframe-test.dis65 @@ -2,7 +2,7 @@ { "_ContentVersion":3, "FileDataLength":120, -"FileDataCrc32":1015994132, +"FileDataCrc32":-604155558, "ProjectProps":{ "CpuName":"6502", "IncludeUndocumentedInstr":false, @@ -274,7 +274,7 @@ "_deltaRotY":6, "_deltaRotZ":0, "_frameCount":120, -"_frameDelayMsec":100}}, +"_frameDelayMsec":33}}, { "Tag":"bmp_data", diff --git a/SourceGen/WireframeObject.cs b/SourceGen/WireframeObject.cs index 94ef108..dfa124a 100644 --- a/SourceGen/WireframeObject.cs +++ b/SourceGen/WireframeObject.cs @@ -246,8 +246,18 @@ namespace SourceGen { scale = (scale * zadj) / (zadj + 0.3); } - Matrix44 rotMat = new Matrix44(); - rotMat.SetRotationEuler(eulerX, eulerY, eulerZ); + // In a left-handed coordinate system, +Z is away from the viewer. The + // visualizer expects a left-handed system with the "nose" aimed toward +Z, + // which leaves us looking at the back end of things. We can add a 180 degree + // rotation about Y so we're looking at the front instead, though this + // effectively reverses the direction of rotation about X. We can compensate + // for it by reversing the handedness of the X rotation. + //eulerY = (eulerY + 180) % 360; + + // Form rotation matrix. + Matrix33 rotMat = new Matrix33(); + rotMat.SetRotationEuler(eulerX, eulerY, eulerZ, Matrix33.RotMode.ZYX_LLL); + //Debug.WriteLine("ROT: " + rotMat); if (doBfc) { // Mark faces as visible or not. This is determined with the surface normal, @@ -264,9 +274,9 @@ namespace SourceGen { face.IsVisible = true; continue; } - Vector3 camVec = rotMat.Multiply(face.Vert.Vec); + Vector3 camVec = rotMat.Multiply(face.Vert.Vec); // transform camVec = camVec.Multiply(-scale); // scale to [-1,1] and negate to get -C - camVec = camVec.Add(new Vector3(0, 0, zadj)); // translate + camVec = camVec.Add(new Vector3(0, 0, -zadj)); // translate // Now compute the dot product of the camera vector. double dot = Vector3.Dot(camVec, rotNorm); @@ -278,7 +288,7 @@ namespace SourceGen { // For orthographic projection, the camera is essentially looking // down the Z axis at every X,Y, so we can trivially check the // value of Z in the transformed normal. - face.IsVisible = (rotNorm.Z >= 0); + face.IsVisible = (rotNorm.Z <= 0); } } } @@ -300,9 +310,9 @@ namespace SourceGen { double x0, y0, x1, y1; if (doPersp) { - // +Z on the shape is closer to the viewer, so we negate it here - double z0 = -trv0.Z * scale; - double z1 = -trv1.Z * scale; + // Left-handed system, so +Z is away from viewer. + double z0 = trv0.Z * scale; + double z1 = trv1.Z * scale; x0 = (trv0.X * scale * zadj) / (zadj + z0); y0 = (trv0.Y * scale * zadj) / (zadj + z0); x1 = (trv1.X * scale * zadj) / (zadj + z1);