1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-27 10:32:31 +00:00

Minor tweaks to wireframe viewer

Experimented with different orders of rotation for wireframe viewer.
Made perspective projection the default behavior.  Removed animation
parameters from the stored Visualization when it's not animated.
This commit is contained in:
Andy McFadden 2020-03-11 15:20:03 -07:00
parent ecb22ef9a4
commit 4221602e12
5 changed files with 67 additions and 36 deletions

View File

@ -45,6 +45,8 @@ namespace PluginCommon {
Val[0, 0] = Val[1, 1] = Val[2, 2] = Val[3, 3] = 1.0;
}
private enum RotMode { XYZ, ZYX, ZXY };
/// <summary>
/// Sets the matrix to perform rotation about Euler angles in the order X, Y, Z.
/// </summary>
@ -66,33 +68,51 @@ namespace PluginCommon {
double sycx = sy * cx;
double sysx = sy * sx;
bool useXyz = true;
if (useXyz) {
// R = Rz * Ry * Rx (from wikipedia)
Val[0, 0] = cz * cy;
Val[0, 1] = sz * cy;
Val[0, 2] = -sy;
RotMode rm = RotMode.ZYX;
switch (rm) {
case RotMode.ZYX:
// R = Rz * Ry * Rx (from wikipedia)
Val[0, 0] = cz * cy;
Val[0, 1] = sz * cy;
Val[0, 2] = -sy;
Val[1, 0] = cz * sysx - sz * cx;
Val[1, 1] = sz * sysx + cz * cx;
Val[1, 2] = cy * sx;
Val[1, 0] = cz * sysx - sz * cx;
Val[1, 1] = sz * sysx + cz * cx;
Val[1, 2] = cy * sx;
Val[2, 0] = cz * sycx + sz * sx;
Val[2, 1] = sz * sycx - cz * sx;
Val[2, 2] = cy * cx;
} else {
// R = Rx * Ry * Rz (from Arc3D)
Val[0, 0] = cz * cy;
Val[0, 1] = -sz * cy;
Val[0, 2] = sy;
Val[2, 0] = cz * sycx + sz * sx;
Val[2, 1] = sz * sycx - cz * sx;
Val[2, 2] = cy * cx;
break;
case RotMode.XYZ:
// R = Rx * Ry * Rz (from Arc3D)
Val[0, 0] = cz * cy;
Val[0, 1] = -sz * cy;
Val[0, 2] = sy;
Val[1, 0] = cz * sysx + sz * cx;
Val[1, 1] = -sz * sysx + cz * cx;
Val[1, 2] = -cy * sx;
Val[1, 0] = cz * sysx + sz * cx;
Val[1, 1] = -sz * sysx + cz * cx;
Val[1, 2] = -cy * sx;
Val[2, 0] = -cz * sycx + sz * sx;
Val[2, 1] = sz * sycx + cz * sx;
Val[2, 2] = cy * cx;
Val[2, 0] = -cz * sycx + sz * sx;
Val[2, 1] = sz * sycx + cz * sx;
Val[2, 2] = cy * cx;
break;
case RotMode.ZXY:
// R = Rz * Rx * Ry (from Arc3D)
double cysx = cy * sx;
Val[0, 0] = cz * cy + sz * sysx;
Val[0, 1] = -sz * cy + cz * sysx;
Val[0, 2] = sy * cx;
Val[1, 0] = sz * cx;
Val[1, 1] = cz * cx;
Val[1, 2] = -sx;
Val[2, 0] = -cz * sy + sz * cysx;
Val[2, 1] = sz * sy + cz * cysx;
Val[2, 2] = cy * cx;
break;
}
//Val[0, 3] = Val[1, 3] = Val[2, 3] = Val[3, 0] = Val[3, 1] = Val[3, 2] = 0.0;
Val[3, 3] = 1.0;

View File

@ -19,6 +19,9 @@ using System.Collections.ObjectModel;
using PluginCommon;
namespace RuntimeData.Apple {
/// <summary>
/// Visualizer for Apple II hi-res bitmaps.
/// </summary>
public class VisHiRes : MarshalByRefObject, IPlugin, IPlugin_Visualizer {
// IPlugin
public string Identifier {

View File

@ -263,7 +263,7 @@ namespace SourceGen {
int eulerX = Util.GetFromObjDict(parms, VisWireframeAnimation.P_EULER_ROT_X, 0);
int eulerY = Util.GetFromObjDict(parms, VisWireframeAnimation.P_EULER_ROT_Y, 0);
int eulerZ = Util.GetFromObjDict(parms, VisWireframeAnimation.P_EULER_ROT_Z, 0);
bool doPersp = Util.GetFromObjDict(parms, VisWireframe.P_IS_PERSPECTIVE, false);
bool doPersp = Util.GetFromObjDict(parms, VisWireframe.P_IS_PERSPECTIVE, true);
bool doBfc = Util.GetFromObjDict(parms, VisWireframe.P_IS_BFC_ENABLED, false);
return GenerateWireframeImage(wireObj, dim, eulerX, eulerY, eulerZ, doPersp, doBfc);
}
@ -325,7 +325,7 @@ namespace SourceGen {
int eulerX = Util.GetFromObjDict(parms, VisWireframeAnimation.P_EULER_ROT_X, 0);
int eulerY = Util.GetFromObjDict(parms, VisWireframeAnimation.P_EULER_ROT_Y, 0);
int eulerZ = Util.GetFromObjDict(parms, VisWireframeAnimation.P_EULER_ROT_Z, 0);
bool doPersp = Util.GetFromObjDict(parms, VisWireframe.P_IS_PERSPECTIVE, false);
bool doPersp = Util.GetFromObjDict(parms, VisWireframe.P_IS_PERSPECTIVE, true);
bool doBfc = Util.GetFromObjDict(parms, VisWireframe.P_IS_BFC_ENABLED, false);
return GenerateWireframePath(wireObj, dim, eulerX, eulerY, eulerZ, doPersp, doBfc);
}

View File

@ -139,6 +139,8 @@ namespace SourceGen {
#region Image generation
private class ScriptSupport : MarshalByRefObject, PluginCommon.IApplication {
public string MsgTag { get; set; } = string.Empty;
public ScriptSupport() { }
public void ReportError(string msg) {
@ -146,7 +148,7 @@ namespace SourceGen {
}
public void DebugLog(string msg) {
Debug.WriteLine("Vis plugin: " + msg);
Debug.WriteLine("Vis [" + MsgTag + "]: " + msg);
}
public bool SetOperandFormat(int offset, DataSubType subType, string label) {
@ -195,6 +197,7 @@ namespace SourceGen {
iapp = new ScriptSupport();
project.PrepareScripts(iapp);
}
iapp.MsgTag = vis.Tag;
if (plugins == null) {
plugins = project.GetActivePlugins();

View File

@ -440,19 +440,24 @@ namespace SourceGen.WpfGui {
// Strictly speaking we don't need this, because we use a different object
// type, but this ties into how the object is stored in the project file.
// We add it here rather than in the project file save code so that the
// parameter manipulation is all in one place.
valueDict.Add(VisWireframeAnimation.P_IS_ANIMATED, IsWireframeAnimated);
// These could be any integer value, but the UI limits them to 4 chars, and
// it's all mod 360.
valueDict.Add(VisWireframeAnimation.P_DELTA_ROT_X, RotDeltaX);
valueDict.Add(VisWireframeAnimation.P_DELTA_ROT_Y, RotDeltaY);
valueDict.Add(VisWireframeAnimation.P_DELTA_ROT_Z, RotDeltaZ);
if (IsWireframeAnimated) {
// These could be any integer value, but the UI limits them to 4 chars, and
// it's all mod 360.
valueDict.Add(VisWireframeAnimation.P_DELTA_ROT_X, RotDeltaX);
valueDict.Add(VisWireframeAnimation.P_DELTA_ROT_Y, RotDeltaY);
valueDict.Add(VisWireframeAnimation.P_DELTA_ROT_Z, RotDeltaZ);
// These aren't strictly checked by the UI, so range-check here.
int fc = (FrameCount >= 1 && FrameCount <= 9999) ? FrameCount : 1;
valueDict.Add(VisWireframeAnimation.P_FRAME_COUNT, fc);
int dly = (FrameDelayMsec >= 1 && FrameDelayMsec <= 999999) ? FrameDelayMsec : 100;
valueDict.Add(VisWireframeAnimation.P_FRAME_DELAY_MSEC, dly);
// These aren't strictly checked by the UI, so range-check here.
int fc = (FrameCount >= 1 && FrameCount <= 9999) ? FrameCount : 1;
valueDict.Add(VisWireframeAnimation.P_FRAME_COUNT, fc);
int dly = (FrameDelayMsec >= 1 && FrameDelayMsec <= 999999) ?
FrameDelayMsec : 100;
valueDict.Add(VisWireframeAnimation.P_FRAME_DELAY_MSEC, dly);
}
}
return new ReadOnlyDictionary<string, object>(valueDict);