当前位置: 首页>>代码示例>>C#>>正文


C# LinearMath.JMatrix类代码示例

本文整理汇总了C#中Jitter.LinearMath.JMatrix的典型用法代码示例。如果您正苦于以下问题:C# JMatrix类的具体用法?C# JMatrix怎么用?C# JMatrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JMatrix类属于Jitter.LinearMath命名空间,在下文中一共展示了JMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

 protected override void Update()
 {
     base.Update();
     if (form.MouseClickedHappenend)
     {
         form.MouseClickedHappenend = false;
         var screenPosition = new JVector(
             -1f + 2* (form.MouseClickPosition.x / form.ClientSize.Width),
             1, -1f + 2 * ((form.MouseClickPosition.y / form.ClientSize.Height)));
         var projectionMatrix = Common.ProjectionMatrix;
         JMatrix jMatrix = new JMatrix(
             projectionMatrix.M11, projectionMatrix.M12, projectionMatrix.M13,
             projectionMatrix.M21, projectionMatrix.M22, projectionMatrix.M23,
             projectionMatrix.M31, projectionMatrix.M32, projectionMatrix.M33);
         JMatrix invertedJMatrix;
     JMatrix.Invert(ref jMatrix, out invertedJMatrix);
         var rayDirection = JVector.Transform(screenPosition, invertedJMatrix);
         RigidBody body;
         JVector normal;
         float fraction;
         Entities.world3D.CollisionSystem.Raycast(JitterDatatypes.ToJVector(Common.CameraPosition),
             rayDirection, null, out body, out normal, out fraction);
         if (body != null && !body.IsStatic)
             body.ApplyImpulse(rayDirection * 200);
     }
 }
开发者ID:BenjaminNitschke,项目名称:PhysicsCourse,代码行数:26,代码来源:JointsPhysics3D.cs

示例2: TransformedShape

 /// <summary>
 /// Creates a new instance of the TransformedShape struct.
 /// </summary>
 /// <param name="shape">The shape.</param>
 /// <param name="orientation">The orientation this shape should have.</param>
 /// <param name="position">The position this shape should have.</param>
 public TransformedShape(Shape shape, JMatrix orientation, JVector position)
 {
     this.position = position;
     this.orientation = orientation;
     JMatrix.Transpose(ref orientation, out invOrientation);
     this.shape = shape;
 }
开发者ID:tpb3d,项目名称:TPB3D,代码行数:13,代码来源:CompoundShape.cs

示例3: FixedAngle

        /// <summary>
        /// Constraints two bodies to always have the same relative
        /// orientation to each other. Combine the AngleConstraint with a PointOnLine
        /// Constraint to get a prismatic joint.
        /// </summary>
        public FixedAngle(RigidBody body1, RigidBody body2) : base(body1, body2)
        {
            initialOrientation1 = body1.orientation;
            initialOrientation2 = body2.orientation;

            //orientationDifference = body1.orientation * body2.invOrientation;
            //orientationDifference = JMatrix.Transpose(orientationDifference);
        }
开发者ID:onefiftyone,项目名称:jitterphysics,代码行数:13,代码来源:FixedAngle.cs

示例4: ToMatrix4

 public static Matrix4 ToMatrix4(JMatrix m, JVector position)
 {
     return new Matrix4(
         m.M11, m.M12, m.M13, 0,
         m.M21, m.M22, m.M23, 0,
         m.M31, m.M32, m.M33, 0,
         position.X, position.Y, position.Z, 1);
 }
开发者ID:BenjaminNitschke,项目名称:PhysicsCourse,代码行数:8,代码来源:JitterDatatypes.cs

示例5: ToTritonMatrix

 public static Matrix4 ToTritonMatrix(JMatrix matrix)
 {
     return new Matrix4(
         matrix.M11, matrix.M12, matrix.M13, 0.0f,
         matrix.M21, matrix.M22, matrix.M23, 0.0f,
         matrix.M31, matrix.M32, matrix.M33, 0.0f,
         0.0f, 0.0f, 0.0f, 1.0f);
 }
开发者ID:johang88,项目名称:triton,代码行数:8,代码来源:Conversion.cs

示例6: ToMatrix4

 public static Matrix4 ToMatrix4(JMatrix orientation, JVector position)
 {
     return new Matrix4(
         orientation.M11, orientation.M12, orientation.M13, 0,
         orientation.M21, orientation.M22, orientation.M23, 0,
         orientation.M31, orientation.M32, orientation.M33, 0,
         position.X, position.Y, position.Z, 1);
 }
开发者ID:BenjaminNitschke,项目名称:PhysicsCourse,代码行数:8,代码来源:JitterMath.cs

示例7: GetBoundingBox

 /// <summary>
 /// Calculates the bounding box of the sphere.
 /// </summary>
 /// <param name="orientation">The orientation of the shape.</param>
 /// <param name="box">The resulting axis aligned bounding box.</param>
 public override void GetBoundingBox(ref JMatrix orientation, out JBBox box)
 {
     box.Min.X = -radius;
     box.Min.Y = -radius;
     box.Min.Z = -radius;
     box.Max.X = radius;
     box.Max.Y = radius;
     box.Max.Z = radius;
 }
开发者ID:onefiftyone,项目名称:jitterphysics,代码行数:14,代码来源:SphereShape.cs

示例8: ClosestPoints

        public static bool ClosestPoints(ISupportMappable support1, ISupportMappable support2, ref JMatrix orientation1,
            ref JMatrix orientation2, ref JVector position1, ref JVector position2,
            out JVector p1, out JVector p2, out JVector normal)
        {
            VoronoiSimplexSolver simplexSolver = simplexSolverPool.GetNew();
            simplexSolver.Reset();

            p1 = p2 = JVector.Zero;

            JVector r = position1 - position2;
            JVector w, v;

            JVector supVertexA;
            JVector rn,vn;

            rn = JVector.Negate(r);

            SupportMapTransformed(support1, ref orientation1, ref position1, ref rn, out supVertexA);

            JVector supVertexB;
            SupportMapTransformed(support2, ref orientation2, ref position2, ref r, out supVertexB);

            v = supVertexA - supVertexB;

            normal = JVector.Zero;

            int maxIter = 15;

            float distSq = v.LengthSquared();
            float epsilon = 0.00001f;

            while ((distSq > epsilon) && (maxIter-- != 0))
            {
                vn = JVector.Negate(v);
                SupportMapTransformed(support1, ref orientation1, ref position1, ref vn, out supVertexA);
                SupportMapTransformed(support2, ref orientation2, ref position2, ref v, out supVertexB);
                w = supVertexA - supVertexB;

                if (!simplexSolver.InSimplex(w)) simplexSolver.AddVertex(w, supVertexA, supVertexB);
                if (simplexSolver.Closest(out v))
                {
                    distSq = v.LengthSquared();
                    normal = v;
                }
                else distSq = 0.0f;
            }

            simplexSolver.ComputePoints(out p1, out p2);

            if (normal.LengthSquared() > JMath.Epsilon * JMath.Epsilon)
                normal.Normalize();

            simplexSolverPool.GiveBack(simplexSolver);

            return true;
        }
开发者ID:reidyd,项目名称:jitterphysics,代码行数:56,代码来源:GJKCollide.cs

示例9: JMatrix

        static JMatrix()
        {
            Zero = new JMatrix();

            Identity = new JMatrix();
            Identity.M11 = 1.0f;
            Identity.M22 = 1.0f;
            Identity.M33 = 1.0f;

            InternalIdentity = Identity;
        }
开发者ID:RainsSoft,项目名称:jitterphysics,代码行数:11,代码来源:JMatrix.cs

示例10: Absolute

 public static void Absolute(ref JMatrix matrix,out JMatrix result)
 {
     result.M11 = Math.Abs(matrix.M11);
     result.M12 = Math.Abs(matrix.M12);
     result.M13 = Math.Abs(matrix.M13);
     result.M21 = Math.Abs(matrix.M21);
     result.M22 = Math.Abs(matrix.M22);
     result.M23 = Math.Abs(matrix.M23);
     result.M31 = Math.Abs(matrix.M31);
     result.M32 = Math.Abs(matrix.M32);
     result.M33 = Math.Abs(matrix.M33);
 }
开发者ID:MagistrAVSH,项目名称:my-spacegame-engine,代码行数:12,代码来源:JMath.cs

示例11: Convert

		public static void Convert(JMatrix matrix, ref Matrix result)
		{
			result[0] = matrix.M11;
			result[1] = matrix.M12;
			result[2] = matrix.M13;
			result[4] = matrix.M21;
			result[5] = matrix.M22;
			result[6] = matrix.M23;
			result[8] = matrix.M31;
			result[9] = matrix.M32;
			result[10] = matrix.M33;
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:12,代码来源:JitterDatatypesMapping.cs

示例12: Pointcast

        /// <summary>
        /// Checks if given point is within a shape.
        /// </summary>
        /// <param name="support">The supportmap implementation representing the shape.</param>
        /// <param name="orientation">The orientation of the shape.</param>
        /// <param name="invOrientation">The inverse orientation of the shape.</param>
        /// <param name="position">The position of the shape.</param>
        /// <param name="point">The point to check.</param>
        /// <returns>Returns true if the point is within the shape, otherwise false.</returns>
        public static bool Pointcast(ISupportMappable support, ref JMatrix orientation,ref JVector position,ref JVector point)
        {
            JVector arbitraryPoint; 

            SupportMapTransformed(support, ref orientation, ref position, ref point, out arbitraryPoint);
            JVector.Subtract(ref point, ref arbitraryPoint, out arbitraryPoint);

            JVector r; support.SupportCenter(out r);
            JVector.Transform(ref r, ref orientation, out r);
            JVector.Add(ref position, ref r, out r);
            JVector.Subtract(ref point, ref r, out r);

            JVector x = point;
            JVector w, p;
            float VdotR;

            JVector v; JVector.Subtract(ref x, ref arbitraryPoint, out v);
            float dist = v.LengthSquared();
            float epsilon = 0.0001f;

            int maxIter = MaxIterations;

            VoronoiSimplexSolver simplexSolver = simplexSolverPool.GetNew();

            simplexSolver.Reset();

            while ((dist > epsilon) && (maxIter-- != 0))
            {
                SupportMapTransformed(support, ref orientation, ref position, ref v, out p);
                JVector.Subtract(ref x, ref p, out w);

                float VdotW = JVector.Dot(ref v, ref w);

                if (VdotW > 0.0f)
                {
                    VdotR = JVector.Dot(ref v, ref r);

                    if (VdotR >= -(JMath.Epsilon * JMath.Epsilon)) { simplexSolverPool.GiveBack(simplexSolver); return false; }
                    else simplexSolver.Reset();
                }
                if (!simplexSolver.InSimplex(w)) simplexSolver.AddVertex(w, x, p);

                if (simplexSolver.Closest(out v)) dist = v.LengthSquared();
                else dist = 0.0f;
            }

            simplexSolverPool.GiveBack(simplexSolver);
            return true;

        }
开发者ID:RainsSoft,项目名称:jitterphysics,代码行数:59,代码来源:GJKCollide.cs

示例13: GetBoundingBox

        /// <summary>
        /// Gets the axis aligned bounding box of the orientated shape. This includes
        /// the whole shape.
        /// </summary>
        /// <param name="orientation">The orientation of the shape.</param>
        /// <param name="box">The axis aligned bounding box of the shape.</param>
        public override void GetBoundingBox(ref JMatrix orientation, out JBBox box)
        {
            JBBox helpBox = JBBox.LargeBox;
            int length = this.Prepare(ref helpBox);

            box = JBBox.SmallBox;

            for (int i = 0; i < length; i++)
            {
                this.SetCurrentShape(i);
                base.GetBoundingBox(ref orientation, out helpBox);
                JBBox.CreateMerged(ref box, ref helpBox, out box);
            }
        }
开发者ID:RainsSoft,项目名称:Jitter,代码行数:20,代码来源:Multishape.cs

示例14: ToXNAMatrix

 public static Matrix ToXNAMatrix(JMatrix matrix)
 {
     return new Matrix(matrix.M11,
                     matrix.M12,
                     matrix.M13,
                     0.0f,
                     matrix.M21,
                     matrix.M22,
                     matrix.M23,
                     0.0f,
                     matrix.M31,
                     matrix.M32,
                     matrix.M33,
                     0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
 }
开发者ID:onefiftyone,项目名称:jitterphysics,代码行数:15,代码来源:Conversion.cs

示例15: SupportMapTransformed

        private static void SupportMapTransformed(ISupportMappable support,
            ref JMatrix orientation, ref JVector position, ref JVector direction, out JVector result)
        {
            // THIS IS *THE* HIGH FREQUENCY CODE OF THE COLLLISION PART OF THE ENGINE

            result.X = ((direction.X * orientation.M11) + (direction.Y * orientation.M12)) + (direction.Z * orientation.M13);
            result.Y = ((direction.X * orientation.M21) + (direction.Y * orientation.M22)) + (direction.Z * orientation.M23);
            result.Z = ((direction.X * orientation.M31) + (direction.Y * orientation.M32)) + (direction.Z * orientation.M33);

            support.SupportMapping(ref result, out result);

            float x = ((result.X * orientation.M11) + (result.Y * orientation.M21)) + (result.Z * orientation.M31);
            float y = ((result.X * orientation.M12) + (result.Y * orientation.M22)) + (result.Z * orientation.M32);
            float z = ((result.X * orientation.M13) + (result.Y * orientation.M23)) + (result.Z * orientation.M33);

            result.X = position.X + x;
            result.Y = position.Y + y;
            result.Z = position.Z + z;
        }
开发者ID:tpb3d,项目名称:TPB3D,代码行数:19,代码来源:XenoCollide.cs


注:本文中的Jitter.LinearMath.JMatrix类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。