public void Construct2() { Matrix43<double> m = new Matrix43<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0); Assert.AreEqual(1.0, m.Column0Row0); Assert.AreEqual(2.0, m.Column1Row0); Assert.AreEqual(3.0, m.Column2Row0); Assert.AreEqual(4.0, m.Column3Row0); Assert.AreEqual(5.0, m.Column0Row1); Assert.AreEqual(6.0, m.Column1Row1); Assert.AreEqual(7.0, m.Column2Row1); Assert.AreEqual(8.0, m.Column3Row1); Assert.AreEqual(9.0, m.Column0Row2); Assert.AreEqual(10.0, m.Column1Row2); Assert.AreEqual(11.0, m.Column2Row2); Assert.AreEqual(12.0, m.Column3Row2); Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0]); Assert.AreEqual(5.0, m.ReadOnlyColumnMajorValues[1]); Assert.AreEqual(9.0, m.ReadOnlyColumnMajorValues[2]); Assert.AreEqual(2.0, m.ReadOnlyColumnMajorValues[3]); Assert.AreEqual(6.0, m.ReadOnlyColumnMajorValues[4]); Assert.AreEqual(10.0, m.ReadOnlyColumnMajorValues[5]); Assert.AreEqual(3.0, m.ReadOnlyColumnMajorValues[6]); Assert.AreEqual(7.0, m.ReadOnlyColumnMajorValues[7]); Assert.AreEqual(11.0, m.ReadOnlyColumnMajorValues[8]); Assert.AreEqual(4.0, m.ReadOnlyColumnMajorValues[9]); Assert.AreEqual(8.0, m.ReadOnlyColumnMajorValues[10]); Assert.AreEqual(12.0, m.ReadOnlyColumnMajorValues[11]); }
public void Construct1() { Matrix43<double> m = new Matrix43<double>(1.0); for (int i = 0; i < m.NumberOfComponents; ++i) { Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0], 1e-14); } }
internal UniformFloatMatrix43GL3x(string name, int location, ICleanableObserver observer) : base(name, UniformType.FloatMatrix43) { _location = location; _value = new Matrix43 <float>(); _dirty = true; _observer = observer; _observer.NotifyDirty(this); }
public void MultMatrix43(Matrix43 mtx) { if (MtxMode == NDSMatrixMode.Position || MtxMode == NDSMatrixMode.Position_Vector) { CurPosMtx = CurPosMtx * new Matrix44(mtx, new Vector4(0, 0, 0, 1)); } if (MtxMode == NDSMatrixMode.Position_Vector) { CurDirMtx = CurDirMtx * new Matrix44(mtx, new Vector4(0, 0, 0, 1)); } }
//public unsafe virtual void Render(GLContext ctx) //{ // ctx.glPushMatrix(); // ctx.glTranslate(_translation._x, _translation._y, _translation._z); // ctx.glRotate(_rotation._x, 1.0f, 0.0f, 0.0f); // ctx.glRotate(_rotation._y, 0.0f, 1.0f, 0.0f); // ctx.glRotate(_rotation._z, 0.0f, 0.0f, 1.0f); // ctx.glScale(_scale._x, _scale._y, _scale._z); // Matrix43 m; // ctx.glGet(GLGetMode.MODELVIEW_MATRIX, (float*)&m); // _matrix = m; // foreach (GLBone b in _children) // b.Render(ctx); // ctx.glPopMatrix(); // //ctx.glBegin(GLPrimitiveType.Lines); // //Vector3 v = new Vector3(); // //Vector3 v2 = _translation; // //ctx.glVertex3v((float*)&v); // //ctx.glVertex3v((float*)&v2); // //ctx.glEnd(); // //ctx.glPushMatrix(); // //Matrix m = _transformMatrix; // //ctx.glMultMatrix(m.Data); // //ctx.glTranslate(_translation._x, _translation._y, _translation._z); // //ctx.glRotate(_rotation._x, 1.0f, 0.0f, 0.0f); // //ctx.glRotate(_rotation._y, 0.0f, 1.0f, 0.0f); // //ctx.glRotate(_rotation._z, 0.0f, 0.0f, 1.0f); // //ctx.glScale(_scale._x, _scale._y, _scale._z); // //Matrix m = _transformInverted; // //ctx.glGet(0x0BA6, m.Data); // //ctx.glLoadMatrix(m.Data); // //foreach (GLPolygon poly in _polygons) // // poly.Render(ctx, _transformInverted); // //ctx.glScale(_scale._x, _scale._y, _scale._z); // //ctx.glTranslate(_translation._x, _translation._y, _translation._z); // //ctx.glRotate(_rotAngle, _rotation._x, _rotation._y, _rotation._z); // //foreach (GLBone b in _children) // // b.Render(ctx); // //ctx.glPopMatrix(); //} public unsafe GLBone(MDL0BoneNode node) { _translation = node.Translation; _rotation = node.Rotation; _scale = node.Scale; _nodeId = node.NodeId; _index = node.BoneIndex; _transformMatrix = (Matrix43)node._frameMatrix; _transformInverted = (Matrix43)node._inverseFrameMatrix; }
//public GLNode(GLModel model) //{ // _model = model; //} //public unsafe GLNode(GLModel model, MDL0Node3Class def) //{ // _model = model; // foreach (MDL0NodeType3Entry e in def._entries) // _nodeLinks[model._nodes[e._id]] = e._value; //} internal unsafe void Rebuild() { if (_bone != null) { _matrix = _bone._transformMatrix; } else { _matrix = Matrix43.Identity; //_matrix = new Matrix43(); //foreach (KeyValuePair<GLBone, float> pair in _nodeLinks) //{ // Matrix43 ifm = pair.Key._inverseFinalMatrix; // Matrix43 fm = pair.Key._finalMatrix; // fm.Multiply(&ifm); // fm.Multiply(pair.Value); // _matrix.Add(&fm); //} } }
public void DoubleToFloat() { Matrix43<double> m = new Matrix43<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0); Matrix43<float> mf = Matrix43<double>.DoubleToFloat(m); Assert.AreEqual(1.0f, mf.Column0Row0, 1e-7); Assert.AreEqual(2.0f, mf.Column1Row0, 1e-7); Assert.AreEqual(3.0f, mf.Column2Row0, 1e-7); Assert.AreEqual(4.0f, mf.Column3Row0, 1e-7); Assert.AreEqual(5.0f, mf.Column0Row1, 1e-7); Assert.AreEqual(6.0f, mf.Column1Row1, 1e-7); Assert.AreEqual(7.0f, mf.Column2Row1, 1e-7); Assert.AreEqual(8.0f, mf.Column3Row1, 1e-7); Assert.AreEqual(9.0f, mf.Column0Row2, 1e-7); Assert.AreEqual(10.0f, mf.Column1Row2, 1e-7); Assert.AreEqual(11.0f, mf.Column2Row2, 1e-7); Assert.AreEqual(12.0f, mf.Column3Row2, 1e-7); }
public Bone(EventHandler handler, uint Bone, Matrix43 matrix43) : base(handler) { mNameHash = Bone; mInverseBindPose = new Matrix43(handler, matrix43); }
public Bone(EventHandler handler) : base(handler) { mInverseBindPose = new Matrix43(handler); }
public void Matrix43() { string fs = @"#version 330 uniform mat4x3 exampleMat43; out vec3 FragColor; void main() { FragColor = vec3(exampleMat43[1].y, exampleMat43[3].x, 0.0); }"; using (GraphicsWindow window = Device.CreateWindow(1, 1)) using (Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context)) using (ShaderProgram sp = Device.CreateShaderProgram(ShaderSources.PassThroughVertexShader(), fs)) using (VertexArray va = TestUtility.CreateVertexArray(window.Context, sp.VertexAttributes["position"].Location)) { Matrix43<float> m42 = new Matrix43<float>( 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); Uniform<Matrix43<float>> exampleMat43 = (Uniform<Matrix43<float>>)sp.Uniforms["exampleMat43"]; Assert.AreEqual("exampleMat43", exampleMat43.Name); Assert.AreEqual(UniformType.FloatMatrix43, exampleMat43.Datatype); Assert.AreEqual(new Matrix43<float>(), exampleMat43.Value); exampleMat43.Value = m42; Assert.AreEqual(m42, exampleMat43.Value); window.Context.Framebuffer = framebuffer; window.Context.Draw(PrimitiveType.Points, 0, 1, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState()); TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 255, 0); } }
public void Equals() { Matrix43<double> a = new Matrix43<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0); Matrix43<double> b = new Matrix43<double>(0.0); Matrix43<double> c = new Matrix43<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0); Assert.IsTrue(a.Equals(c)); Assert.IsTrue(c.Equals(a)); Assert.IsTrue(a == c); Assert.IsTrue(c == a); Assert.IsFalse(c != a); Assert.IsFalse(c != a); Assert.IsFalse(a.Equals(b)); Assert.IsFalse(b.Equals(a)); Assert.IsFalse(a == b); Assert.IsFalse(b == a); Assert.IsTrue(a != b); Assert.IsTrue(b != a); object objA = a; object objB = b; object objC = c; Assert.IsTrue(a.Equals(objA)); Assert.IsTrue(a.Equals(objC)); Assert.IsFalse(a.Equals(objB)); Assert.IsTrue(objA.Equals(objC)); Assert.IsFalse(objA.Equals(objB)); Assert.IsFalse(a.Equals(null)); Assert.IsFalse(a.Equals(5)); }
public void TestGetHashCode() { Matrix43<double> a = new Matrix43<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0); Matrix43<double> b = new Matrix43<double>(0.0); Matrix43<double> c = new Matrix43<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0); Assert.AreEqual(a.GetHashCode(), c.GetHashCode()); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { Matrix43 m = new Matrix43(); string s = value.ToString(); string[] arr = s.Split(delims, StringSplitOptions.RemoveEmptyEntries); if (arr.Length == 12) { float.TryParse(arr[0], out m._data[0]); float.TryParse(arr[1], out m._data[1]); float.TryParse(arr[2], out m._data[2]); float.TryParse(arr[3], out m._data[3]); float.TryParse(arr[4], out m._data[4]); float.TryParse(arr[5], out m._data[5]); float.TryParse(arr[6], out m._data[6]); float.TryParse(arr[7], out m._data[7]); float.TryParse(arr[8], out m._data[8]); float.TryParse(arr[9], out m._data[9]); float.TryParse(arr[10], out m._data[10]); float.TryParse(arr[11], out m._data[11]); } return m; }