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


C# Matrix4.MakeTransform方法代码示例

本文整理汇总了C#中Matrix4.MakeTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4.MakeTransform方法的具体用法?C# Matrix4.MakeTransform怎么用?C# Matrix4.MakeTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix4的用法示例。


在下文中一共展示了Matrix4.MakeTransform方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnKeyboardPress

        void OnKeyboardPress(KeyEvent eventArgs)
        {
            if (LKernel.GetG<InputSwallowerManager>().IsSwallowed())
                return;

            Kart kart = LKernel.GetG<PlayerManager>().MainPlayer.Kart;

            Vector3 pos;
            Quaternion quat;

            switch (eventArgs.key) {
                case KeyCode.KC_NUMPAD0:
                    pos = new Vector3(122.245f, 55f, 135.99f);
                    quat = new Quaternion(0.3107f, 0.001f, 0.9505f, 0.0029f);
                    break;
                default:
                    return;
            }

            Matrix4 mat = new Matrix4();
            mat.MakeTransform(pos, Vector3.UNIT_SCALE, quat);

            kart.Body.WorldTransform = mat;
            kart.Body.Activate();
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:25,代码来源:WTW_JumpAround.cs

示例2: MogreMotionState

 /// <param name="thing">The connected lthing, used for updating sounds. You can pass null to skip updating sounds.</param>
 public MogreMotionState(LThing thing, Vector3 position, Quaternion orientation, SceneNode node)
 {
     transform = new Matrix4(orientation);
     transform.MakeTransform(position, Vector3.UNIT_SCALE, orientation);
     this.node = node;
     this.owner = thing;
 }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:8,代码来源:MogreMotionState.cs

示例3: KartMotionState

        /// <param name="thing">The connected lthing, used for updating sounds. You can pass null to skip updating sounds.</param>
        public KartMotionState(Kart kart, Vector3 position, Quaternion orientation, SceneNode node)
            : base(kart, position, orientation, node)
        {
            transform = new Matrix4(orientation);
            transform.MakeTransform(position, Vector3.UNIT_SCALE, orientation);
            this.node = node;
            this.kart = kart;

            lastPosition = position;
            lastOrientation = orientation;
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:12,代码来源:KartMotionState.cs

示例4: Finish

        public override void Finish()
        {
            Quaternion quat;
            if (!QuatTokens.TryGetValue("orientation", out quat)) {
                Vector3 rot = GetVectorProperty("rotation", Vector3.ZERO);
                quat = GlobalEulerToQuat(new Degree(rot.x), new Degree(rot.y), new Degree(rot.z));
            }

            Vector3 pos = GetVectorProperty("position", Vector3.ZERO);

            Transform = new Matrix4();
            Transform.MakeTransform(pos, Vector3.UNIT_SCALE, quat);
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:13,代码来源:ShapeBlock.cs

示例5: OnMousePress_Right

        void OnMousePress_Right(MouseEvent eventArg1, MouseButtonID eventArg2)
        {
            if (LKernel.GetG<InputSwallowerManager>().IsSwallowed() || !IsActive)
                return;

            Vector3 pos = new Vector3(), norm = new Vector3();
            if (new MogreRaycaster().RaycastFromPoint(CameraNode.Position, -CameraNode.GetLocalZAxis(), ref pos, ref norm)) {
                var kart = LKernel.GetG<PlayerManager>().MainPlayer.Kart;
                kart.Body.Activate();

                Matrix4 mat = new Matrix4();
                mat.MakeTransform(pos, Vector3.UNIT_SCALE, kart.ActualOrientation);
                kart.Body.WorldTransform = mat;
            }
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:15,代码来源:FreeCamera.cs

示例6: SetState

        /// <summary>
        /// Changes the position, velocity, and orientation according to the remote instructions
        /// </summary>
        public void SetState(Vector3 newPosition, Vector3 newLinearVelocity, Quaternion newOrientation)
        {
            kartMotionState.actualPosition = newPosition;
            kartMotionState.actualOrientation = newOrientation;

            Matrix4 mat = new Matrix4();
            mat.MakeTransform(newPosition, Vector3.UNIT_SCALE, newOrientation);

            Body.WorldTransform = mat;
            Body.LinearVelocity = newLinearVelocity;
            Body.Activate();
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:15,代码来源:Kart.cs

示例7: CreateGroundPlane

        /// <summary>
        /// Create a static ground plane facing upwards.
        /// </summary>
        /// <param name="yposition">The Y position that the plane is located at.</param>
        void CreateGroundPlane(float yposition)
        {
            // make an infinite plane so we don't fall forever. TODO: hook up an event so when we collide with this, we respawn back on the track
            Matrix4 matrix = new Matrix4();
            matrix.MakeTransform(new Vector3(0, yposition, 0), Vector3.UNIT_SCALE, new Quaternion(0, 0, 0, 1));

            CollisionShape groundShape = new StaticPlaneShape(Vector3.NEGATIVE_UNIT_Y, 1);
            var groundInfo = new RigidBodyConstructionInfo(0, new DefaultMotionState(matrix), groundShape, Vector3.ZERO);
            var groundBody = new RigidBody(groundInfo);
            groundBody.UserObject = new CollisionObjectDataHolder(groundBody, PonykartCollisionGroups.Environment, "ground");
            groundBody.CollisionFlags = CollisionFlags.StaticObject | CollisionFlags.DisableVisualizeObject;
            world.AddRigidBody(groundBody, PonykartCollisionGroups.Environment, PonykartCollidesWithGroups.Environment);
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:17,代码来源:PhysicsMain.cs

示例8: TriggerRegion

        /// <summary>
        /// Creates a new trigger region. It automatically adds itself to the TriggerReporter's dictionary, so you don't have to do that.
        /// </summary>
        /// <param name="orientation">a degree vector</param>
        public TriggerRegion(string name, Vector3 position, Quaternion orientation, CollisionShape shape)
        {
            Name = name;
            CurrentlyCollidingWith = new HashSet<RigidBody>();

            // mogre
            var sceneMgr = LKernel.GetG<SceneManager>();

            Node = sceneMgr.RootSceneNode.CreateChildSceneNode(name);
            if (Settings.Default.EnableGlowyRegions) {
                // make a mesh for the region depending on what its type is
                switch (shape.ShapeType) {
                    case BroadphaseNativeType.BoxShape:
                        Entity = sceneMgr.CreateEntity(name, "primitives/box.mesh");
                        Node.SetScale((shape as BoxShape).HalfExtentsWithoutMargin * 2);
                        break;
                    case BroadphaseNativeType.CapsuleShape:
                        Entity = sceneMgr.CreateEntity(name, "primitives/cylinder.mesh");
                        Vector3 vec = new Vector3();
                        vec.y = (shape as CapsuleShape).HalfHeight * 2;
                        vec.x = vec.z = (shape as CapsuleShape).Radius * 2;
                        Node.SetScale(vec);
                        break;
                    case BroadphaseNativeType.CylinderShape:
                        Entity = sceneMgr.CreateEntity(name, "primitives/cylinder.mesh");
                        Vector3 vec2 = new Vector3();
                        vec2.y = (shape as CylinderShape).HalfExtentsWithoutMargin.y;
                        vec2.x = vec2.z = (shape as CylinderShape).Radius * 2;
                        Node.SetScale(vec2);
                        break;
                    case BroadphaseNativeType.SphereShape:
                        Entity = sceneMgr.CreateEntity(name, "primitives/sphere.mesh");
                        float dim = (shape as SphereShape).Radius * 2;
                        Node.SetScale(dim, dim, dim);
                        break;
                    default:
                        // for things like meshes, convex hulls, etc
                        Entity = sceneMgr.CreateEntity(name, "primitives/box.mesh");
                        break;
                }
                GlowColor = BalloonGlowColour.red;
                Entity.CastShadows = false;

                Node.AttachObject(Entity);
            }
            Node.Position = position;
            Node.Orientation = orientation;

            // physics
            Matrix4 transform = new Matrix4();
            transform.MakeTransform(position, Vector3.UNIT_SCALE, orientation);

            var motionState = new DefaultMotionState();
            motionState.WorldTransform = transform;

            // thanks to kloplop321 in #ogre3d for his help with this
             	Ghost = new GhostObject();
            Ghost.CollisionShape = shape;
            Ghost.WorldTransform = transform;
            Ghost.UserObject = new CollisionObjectDataHolder(Ghost, PonykartCollisionGroups.Triggers, name);

            Ghost.CollisionFlags |= CollisionFlags.NoContactResponse | CollisionFlags.CustomMaterialCallback;
            LKernel.GetG<PhysicsMain>().World.AddCollisionObject(Ghost, PonykartCollisionGroups.Triggers, PonykartCollidesWithGroups.Triggers);

            // then add this to the trigger reporter
            LKernel.GetG<TriggerReporter>().Regions.Add(name, this);
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:71,代码来源:TriggerRegion.cs

示例9: SetUpBodyInfo

        /// <summary>
        /// Set up all of the stuff needed before we create our body
        /// </summary>
        private void SetUpBodyInfo(ThingDefinition def)
        {
            // set up our collision shapes
            CollisionShape shape = LKernel.GetG<CollisionShapeManager>().CreateAndRegisterShape(this, def);

            // get the physics type and set up the mass of the body
            ThingEnum physicsType = def.GetEnumProperty("physics", null);
            float mass = physicsType.HasFlag(ThingEnum.Static) ? 0 : def.GetFloatProperty("mass", 1);

            // create our construction info thingy
            Vector3 inertia;
            shape.CalculateLocalInertia(mass, out inertia);

            // if it's static and doesn't have a sound, we don't need a mogre motion state because we'll be disposing of the root node afterwards
            if (def.GetBoolProperty("Static", false) && SoundComponents == null)
                MotionState = new DefaultMotionState();
            else
                MotionState = InitializationMotionState;

            Info = new RigidBodyConstructionInfo(mass, MotionState, shape, inertia);

            // physics material stuff from a .physmat file
            string physmat = def.GetStringProperty("PhysicsMaterial", "Default");
            LKernel.GetG<PhysicsMaterialFactory>().ApplyMaterial(Info, physmat);

            // we can override some of them in the .thing file
            if (def.FloatTokens.ContainsKey("bounciness"))
                Info.Restitution = def.GetFloatProperty("bounciness", PhysicsMaterial.DEFAULT_BOUNCINESS);
            if (def.FloatTokens.ContainsKey("friction"))
                Info.Friction = def.GetFloatProperty("friction", PhysicsMaterial.DEFAULT_FRICTION);
            if (def.FloatTokens.ContainsKey("angulardamping"))
                Info.AngularDamping = def.GetFloatProperty("angulardamping", PhysicsMaterial.DEFAULT_ANGULAR_DAMPING);
            if (def.FloatTokens.ContainsKey("lineardamping"))
                Info.LinearDamping = def.GetFloatProperty("lineardamping", PhysicsMaterial.DEFAULT_LINEAR_DAMPING);

            // choose which group to use for a default
            ThingEnum defaultGroup;
            if (physicsType.HasFlag(ThingEnum.Dynamic))
                defaultGroup = ThingEnum.Default;
            else if (physicsType.HasFlag(ThingEnum.Static))
                defaultGroup = ThingEnum.Environment;
            else // kinematic
                defaultGroup = ThingEnum.Default;

            // collision group
            ThingEnum collisionGroup = def.GetEnumProperty("CollisionGroup", defaultGroup);
            PonykartCollisionGroups pcg;
            if (!Enum.TryParse<PonykartCollisionGroups>(collisionGroup + String.Empty, true, out pcg))
                throw new FormatException("Invalid collision group!");
            CollisionGroup = pcg;

            // collides-with group
            ThingEnum collidesWith = def.GetEnumProperty("CollidesWith", defaultGroup);
            PonykartCollidesWithGroups pcwg;
            if (!Enum.TryParse<PonykartCollidesWithGroups>(collidesWith + String.Empty, true, out pcwg))
                throw new FormatException("Invalid collides-with group!");
            CollidesWith = pcwg;

            // update the transforms
            Matrix4 transform = new Matrix4();
            transform.MakeTransform(SpawnPosition, SpawnScale, SpawnOrientation);
            Info.StartWorldTransform = transform;
            MotionState.WorldTransform = transform;
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:67,代码来源:LThing.cs

示例10: OnKeyboardPress

        void OnKeyboardPress(KeyEvent eventArgs)
        {
            if (LKernel.GetG<InputSwallowerManager>().IsSwallowed())
                return;

            Kart kart = LKernel.GetG<PlayerManager>().MainPlayer.Kart;

            Vector3 pos;
            Quaternion quat;

            switch (eventArgs.key) {
                case KeyCode.KC_NUMPAD0:
                    pos = new Vector3(-50.8083f, -6.74291f, 324.711f) / 5f;
                    quat = new Quaternion(0.7039f, 0, 0.7102f, 0);
                    break;
                case KeyCode.KC_NUMPAD1:
                    pos = new Vector3(-282.546f, 20.7933f, 327.82f) / 5f;
                    quat = new Quaternion(0.7789f, 0, 0.627f, 0);
                    break;
                case KeyCode.KC_NUMPAD2:
                    pos = new Vector3(-354.992f, -3.4451f, -204.558f) / 5f;
                    quat = new Quaternion(1, 0, 0, 0);
                    break;
                case KeyCode.KC_NUMPAD3:
                    pos = new Vector3(-305.8f, 45.4037f, -693.169f) / 5f;
                    quat = new Quaternion(0.7143f, 0, -0.6998f, 0);
                    break;
                case KeyCode.KC_NUMPAD4:
                    pos = new Vector3(79.2f, 45.2845f, -696.161f) / 5f;
                    quat = new Quaternion(0.70514f, 0, -0.709f, 0);
                    break;
                case KeyCode.KC_NUMPAD5:
                    pos = new Vector3(283.799f, 14.8f, -350.52f) / 5f;
                    quat = new Quaternion(0, 0, 1, 0);
                    break;
                case KeyCode.KC_NUMPAD6:
                    pos = new Vector3(218.534f, 2.806f, -13.362f) / 5f;
                    quat = new Quaternion(0.8834f, 0, 0.4686f, 0);
                    break;
                case KeyCode.KC_NUMPAD7:
                    pos = new Vector3(85.0738f, -2.5893f, 114.471f) / 5f;
                    quat = new Quaternion(-0.0593f, 0, 0.9982f, 0);
                    break;
                default:
                    return;
            }

            // I copied all of the rotations wrong so we need to rotate them by 180 degrees around the Y axis
            quat = quat * new Quaternion(0, 0, 1, 0);

            Matrix4 mat = new Matrix4();
            mat.MakeTransform(pos, Vector3.UNIT_SCALE, quat);

            kart.Body.WorldTransform = mat;
            kart.Body.Activate();
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:56,代码来源:SAA_JumpAround.cs

示例11: tr_OnTrigger

        void tr_OnTrigger(TriggerRegion region, RigidBody otherBody, TriggerReportFlags flags, CollisionReportInfo info)
        {
            var pos = new Vector3(-305.8f, 45.4037f, -693.169f) / 5f;
            var quat = new Quaternion(0.7143f, 0, -0.6998f, 0);

            quat = quat * new Quaternion(0, 0, 1, 0);

            Matrix4 mat = new Matrix4();
            mat.MakeTransform(pos, Vector3.UNIT_SCALE, quat);

            Kart kart = (otherBody.UserObject as CollisionObjectDataHolder).GetThingAsKart();

            if (kart != null) {
                kart.Body.WorldTransform = mat;
                kart.Body.Activate();
            }
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:17,代码来源:SAA_JumpAround.cs


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