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.Text;
|
||||
|
||||
namespace CommonUtil {
|
||||
namespace PluginCommon {
|
||||
/// <summary>
|
||||
/// Simple 4x4 matrix.
|
||||
/// </summary>
|
||||
@ -26,7 +26,6 @@ namespace CommonUtil {
|
||||
get { return mVal; }
|
||||
private set { mVal = value; }
|
||||
}
|
||||
|
||||
private double[,] mVal;
|
||||
|
||||
public Matrix44() {
|
||||
@ -67,7 +66,7 @@ namespace CommonUtil {
|
||||
double sycx = sy * cx;
|
||||
double sysx = sy * sx;
|
||||
|
||||
bool useXyz = false;
|
||||
bool useXyz = true;
|
||||
if (useXyz) {
|
||||
// R = Rz * Ry * Rx (from wikipedia)
|
||||
Val[0, 0] = cz * cy;
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace CommonUtil {
|
||||
namespace PluginCommon {
|
||||
/// <summary>
|
||||
/// Simple 3-element column vector.
|
||||
/// </summary>
|
||||
@ -32,7 +32,6 @@ namespace CommonUtil {
|
||||
get { return mZ; }
|
||||
set { mZ = value; }
|
||||
}
|
||||
|
||||
private double mX, mY, mZ;
|
||||
|
||||
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
|
||||
// since you can do orthographic-projection BFC without it... but who does that?
|
||||
// TODO(maybe): confirm that every face (i.e. normal) has a vertex we can use for
|
||||
// BFC calculation. Not strictly necessary since you can do orthographic-projection
|
||||
// BFC without it... but who does that?
|
||||
|
||||
msg = string.Empty;
|
||||
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,
|
||||
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.</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
|
||||
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
|
||||
|
@ -52,6 +52,10 @@ namespace SourceGen {
|
||||
Vec = new Vector3(x, y, z);
|
||||
Faces = new List<Face>();
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return Vec.ToString() + " + " + Faces.Count + " faces";
|
||||
}
|
||||
}
|
||||
|
||||
private class Edge {
|
||||
@ -226,7 +230,7 @@ namespace SourceGen {
|
||||
double scale = 1.0 / mBigMag;
|
||||
if (doPersp) {
|
||||
// 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();
|
||||
|
@ -605,7 +605,7 @@ namespace SourceGen.WpfGui {
|
||||
previewGrid.Background = Brushes.Black;
|
||||
previewImage.Source = Visualization.BLANK_IMAGE;
|
||||
double dim = Math.Floor(
|
||||
Math.Min(previewImage.ActualWidth, previewImage.ActualHeight));
|
||||
Math.Min(previewGrid.ActualWidth, previewGrid.ActualHeight));
|
||||
WireframeObject wireObj = WireframeObject.Create(visWire);
|
||||
wireframePath.Data = Visualization.GenerateWireframePath(wireObj, dim, parms);
|
||||
BitmapDimensions = "n/a";
|
||||
|
Loading…
x
Reference in New Issue
Block a user