mirror of
https://github.com/fadden/6502bench.git
synced 2025-01-11 18:29:53 +00:00
Relocate Matrix/Vector code to lib where plugins can use it
Also, tweak the perspective projection scaling to fill out the area a bit more, and change the visualization editor to use the grid's size when setting the path dimensions. Also, note gimbal lock.
This commit is contained in:
parent
971301d5b8
commit
01d64f79b7
@ -17,7 +17,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace CommonUtil {
|
namespace PluginCommon {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple 4x4 matrix.
|
/// Simple 4x4 matrix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -26,7 +26,6 @@ namespace CommonUtil {
|
|||||||
get { return mVal; }
|
get { return mVal; }
|
||||||
private set { mVal = value; }
|
private set { mVal = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private double[,] mVal;
|
private double[,] mVal;
|
||||||
|
|
||||||
public Matrix44() {
|
public Matrix44() {
|
||||||
@ -67,7 +66,7 @@ namespace CommonUtil {
|
|||||||
double sycx = sy * cx;
|
double sycx = sy * cx;
|
||||||
double sysx = sy * sx;
|
double sysx = sy * sx;
|
||||||
|
|
||||||
bool useXyz = false;
|
bool useXyz = true;
|
||||||
if (useXyz) {
|
if (useXyz) {
|
||||||
// R = Rz * Ry * Rx (from wikipedia)
|
// R = Rz * Ry * Rx (from wikipedia)
|
||||||
Val[0, 0] = cz * cy;
|
Val[0, 0] = cz * cy;
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace CommonUtil {
|
namespace PluginCommon {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simple 3-element column vector.
|
/// Simple 3-element column vector.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -32,7 +32,6 @@ namespace CommonUtil {
|
|||||||
get { return mZ; }
|
get { return mZ; }
|
||||||
set { mZ = value; }
|
set { mZ = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private double mX, mY, mZ;
|
private double mX, mY, mZ;
|
||||||
|
|
||||||
public Vector3(double x, double y, double z) {
|
public Vector3(double x, double y, double z) {
|
@ -172,8 +172,9 @@ namespace PluginCommon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(maybe): confirm that every face has a vertex. Not strictly necessary
|
// TODO(maybe): confirm that every face (i.e. normal) has a vertex we can use for
|
||||||
// since you can do orthographic-projection BFC without it... but who does that?
|
// BFC calculation. Not strictly necessary since you can do orthographic-projection
|
||||||
|
// BFC without it... but who does that?
|
||||||
|
|
||||||
msg = string.Empty;
|
msg = string.Empty;
|
||||||
return true;
|
return true;
|
||||||
|
@ -111,7 +111,10 @@ render with a perspective projection and without culling.</p>
|
|||||||
axes. The viewer provides a conventional right-handed coordinate system,
|
axes. The viewer provides a conventional right-handed coordinate system,
|
||||||
with +X toward the right, +Y toward the top of the screen, and +Z
|
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
|
coming out of the screen. Positive rotations cause a counter-clockwise
|
||||||
rotation when looking down the axis in the positive direction.</p>
|
rotation when looking down the axis in the positive direction. 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).</p>
|
||||||
<p>If you check the "Animated" box, you can add a simple spin. Choose
|
<p>If you check the "Animated" box, you can add a simple spin. Choose
|
||||||
the number of degrees to rotate per frame, how many frames to generate before
|
the number of degrees to rotate per frame, how many frames to generate before
|
||||||
resetting, and the delay between each frame. Clicking the "Auto" button
|
resetting, and the delay between each frame. Clicking the "Auto" button
|
||||||
|
@ -52,6 +52,10 @@ namespace SourceGen {
|
|||||||
Vec = new Vector3(x, y, z);
|
Vec = new Vector3(x, y, z);
|
||||||
Faces = new List<Face>();
|
Faces = new List<Face>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return Vec.ToString() + " + " + Faces.Count + " faces";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Edge {
|
private class Edge {
|
||||||
@ -226,7 +230,7 @@ namespace SourceGen {
|
|||||||
double scale = 1.0 / mBigMag;
|
double scale = 1.0 / mBigMag;
|
||||||
if (doPersp) {
|
if (doPersp) {
|
||||||
// objects closer to camera are bigger; reduce scale slightly
|
// objects closer to camera are bigger; reduce scale slightly
|
||||||
scale = (scale * zadj) / (zadj + 0.5);
|
scale = (scale * zadj) / (zadj + 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix44 rotMat = new Matrix44();
|
Matrix44 rotMat = new Matrix44();
|
||||||
|
@ -605,7 +605,7 @@ namespace SourceGen.WpfGui {
|
|||||||
previewGrid.Background = Brushes.Black;
|
previewGrid.Background = Brushes.Black;
|
||||||
previewImage.Source = Visualization.BLANK_IMAGE;
|
previewImage.Source = Visualization.BLANK_IMAGE;
|
||||||
double dim = Math.Floor(
|
double dim = Math.Floor(
|
||||||
Math.Min(previewImage.ActualWidth, previewImage.ActualHeight));
|
Math.Min(previewGrid.ActualWidth, previewGrid.ActualHeight));
|
||||||
WireframeObject wireObj = WireframeObject.Create(visWire);
|
WireframeObject wireObj = WireframeObject.Create(visWire);
|
||||||
wireframePath.Data = Visualization.GenerateWireframePath(wireObj, dim, parms);
|
wireframePath.Data = Visualization.GenerateWireframePath(wireObj, dim, parms);
|
||||||
BitmapDimensions = "n/a";
|
BitmapDimensions = "n/a";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user