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


C# Model.CopyBoneTransformsTo方法代码示例

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


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

示例1: LoadContent

        public void LoadContent(ContentManager content)
        {
            model = content.Load<Model>(asset);
            // allocate the array to the number of bones we have
            int boneCnt = model.Bones.Count;
            bindTransforms = new Matrix[boneCnt];
            bonesTransforms = new Matrix[boneCnt];
            absoTransforms = new Matrix[boneCnt];

            model.CopyBoneTransformsTo(bindTransforms);
            model.CopyBoneTransformsTo(bonesTransforms);
            model.CopyAbsoluteBoneTransformsTo(absoTransforms);

            PlayClip("Take 001");
        }
开发者ID:Kingofhearts102,项目名称:CSE473AnimationSteps,代码行数:15,代码来源:AnimatedModel.cs

示例2: CityEntity

        //Matrix[] rot; 

        public CityEntity(City city)
        {
            _city = city;

            Point = city.Point;
            model = MainApplication.ManagerInstance.Content.Load<Model>("Content\\Models\\Civ5\\med_european");
            Scale = new Vector3(0.007f);

            int boneCount = model.Bones.Count;
            boneVisible = Enumerable.Repeat<bool>(true, boneCount).ToArray();

            this.boneTransforms = new Matrix[boneCount];
            model.CopyBoneTransformsTo(this.boneTransforms);

            this.absoluteBoneTransforms = new Matrix[boneCount];
        }
开发者ID:mrommel,项目名称:MiRo.SimHexWorld,代码行数:18,代码来源:CityEntity.cs

示例3: DrawableModel

        public DrawableModel(Model model, Matrix worldMatrix)
        {
            this.model = model;
            this.worldMatrix = worldMatrix;
            modelTransforms = new Matrix[model.Bones.Count];

            originalTransforms = new Matrix[model.Bones.Count];
            model.CopyBoneTransformsTo(originalTransforms);

            LoadModelBoundingSphere();

            position = new Vector3();

            if (debug)
                WriteModelStructure(model);
        }
开发者ID:bradleat,项目名称:trafps,代码行数:16,代码来源:DrawableModel.cs

示例4: Car

        // Constructor
        public Car(ContentManager content, string fileName)
        {
            // Utgangsposisjon, fart og styringsutslaget.
            Speed = 0.0f;
            SteerAngle = 0.0f;

            // Les .x-objektet fra 3DS Max
            model = content.Load<Model>(fileName);

            // Juster objektet i forhold til koordinatsystemet fra 3DS Max
            Matrix rotation = Matrix.CreateRotationZ(-MathHelper.PiOver2);
            model.Bones[0].Transform = rotation * model.Bones[0].Transform;

            // Initier tabell for utgangtransformasjoner
            initialTransforms = new Matrix[model.Bones.Count];
            model.CopyBoneTransformsTo(initialTransforms);

            // Initier tabell for nåværende transformasjoner
            currentTransforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(currentTransforms);
            //ModelLister.DumpModel(model);
            velocity = new Vector3(0, 0, 0);
        }
开发者ID:Biskus,项目名称:rush,代码行数:24,代码来源:Car.cs

示例5: Draw

        public static void Draw(DetectionResult markerResult, Model model, double x, double y, double z, float zRotation = 0.0f, bool customLocation = false)
        {
            if (markerResult != null)
            {
                float aspectRatio = (float)SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.AspectRatio;

                SharedGraphicsDeviceManager.Current.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
                SharedGraphicsDeviceManager.Current.GraphicsDevice.BlendState = BlendState.Opaque;
                SharedGraphicsDeviceManager.Current.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

                Vector3 cameraPosition = new Vector3(0, 0, 150);

                Microsoft.Xna.Framework.Matrix[] transforms = new Microsoft.Xna.Framework.Matrix[model.Bones.Count];
                model.CopyBoneTransformsTo(transforms);
                // Draw the model. A model can have multiple meshes, so loop.
                foreach (ModelMesh mesh in model.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        Vector3 modelPosition = new Vector3((int)(customLocation ?  x : ((x < 5 ? (4 - x) * -1 : x - 4) * SCALE)), (int)(customLocation ? y : ((y < 5 ? (4 - y) * -1 : y - 4) * SCALE)), (int)(customLocation ? z : (z * SCALE)));
                        effect.EnableDefaultLighting();
                        effect.World = Microsoft.Xna.Framework.Matrix.CreateScale(SCALE / 2) *
                            (transforms[mesh.ParentBone.Index]
                            * mesh.ParentBone.Transform
                            * Matrix.CreateRotationZ(zRotation)
                            * Microsoft.Xna.Framework.Matrix.CreateTranslation(modelPosition)
                            * markerResult.Transformation.ToXnaMatrix()
                        );

                        effect.View = Microsoft.Xna.Framework.Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
                        effect.Projection = Microsoft.Xna.Framework.Matrix.CreatePerspectiveFieldOfView(Microsoft.Xna.Framework.MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f);
                    }
                    // Draw the mesh, using the effects set above.
                    mesh.Draw();
                }
            }
        }
开发者ID:ARChess,项目名称:ARChess,代码行数:37,代码来源:ModelDrawer.cs

示例6: LoadContent

        public void LoadContent(ContentManager content)
        {
            model = content.Load<Model>(asset);
            // allocate the array to the number of bones we have
            int boneCnt = model.Bones.Count;
            bindTransforms = new Matrix[boneCnt];
            bonesTransforms = new Matrix[boneCnt];
            absoTransforms = new Matrix[boneCnt];

            model.CopyBoneTransformsTo(bindTransforms);
            model.CopyBoneTransformsTo(bonesTransforms);
            model.CopyAbsoluteBoneTransformsTo(absoTransforms);

            AnimationClips clips = model.Tag as AnimationClips;
            if (clips != null && clips.SkelToBone.Count > 0)
            {
                skelToBone = clips.SkelToBone;

                inverseBindTransforms = new Matrix[boneCnt];
                skinTransforms = new Matrix[NumSkinBones];

                model.CopyAbsoluteBoneTransformsTo(inverseBindTransforms);

                for (int b = 0; b < inverseBindTransforms.Length; b++)
                    inverseBindTransforms[b] = Matrix.Invert(inverseBindTransforms[b]);

                for (int i = 0; i < skinTransforms.Length; i++)
                    skinTransforms[i] = Matrix.Identity;
            }

            foreach (AssetClip clip in assetClips.Values)
            {
                Model clipmodel = content.Load<Model>(clip.Asset);
                AnimationClips modelclips = clipmodel.Tag as AnimationClips;
                clip.TheClip = modelclips.Clips["Take 001"];
            }
            //PlayClip("Take 001");
        }
开发者ID:Kingofhearts102,项目名称:Project2-Cse473,代码行数:38,代码来源:AnimatedModel.cs

示例7: LoadContent

        /// <summary>
        /// This function is called to load content into this component
        /// of our game.
        /// </summary>
        /// <param name="content">The content manager to load from.</param>
        public void LoadContent(ContentManager content)
        {
            // Load the second model
            model = content.Load<Model>(asset);

            // Save off all of hte bone information
            int boneCnt = model.Bones.Count;
            bindTransforms = new Matrix[boneCnt];
            boneTransforms = new Matrix[boneCnt];

            model.CopyBoneTransformsTo(bindTransforms);
            model.CopyBoneTransformsTo(boneTransforms);

            // Find all of the doors and save the index for the bone
            for (int b = 0; b < boneCnt; b++)
            {
                if (model.Bones[b].Name.StartsWith("DoorInner") || model.Bones[b].Name.StartsWith("DoorOuter"))
                {
                    doors.Add(b);
                    doorState.Add(new DoorClass());
                }

            }

            effect = content.Load<Effect>("PhibesEffect1");
            effectT = content.Load<Effect>("PhibesEffect2");
        }
开发者ID:Cheaneyc,项目名称:473-project3,代码行数:32,代码来源:PrisonModel.cs

示例8: UnitEntity

        public UnitEntity(AbstractPlayerData player, Unit unit, string name)
        {
            Point = unit.Point;
            _unit = unit;
            _player = player;

            _model = MainApplication.ManagerInstance.Content.Load<Model>("Content\\Models\\" + name);
            _animations.Add("Idle", new ModelAnimation("Content\\Animations\\" + name + "\\Idle"));

            Status = ModelStatus.Standing;

            for (int i = 0; i < unit.Formation.Positions; ++i)
            {
                Vector3 startOffset = unit.Formation.GetPosition(i);

                _items.Add(new UnitItem(Position + startOffset, startOffset, Rotation));
            }

            _scaleMatrix = Matrix.CreateScale(Scale * 0.3f);

            int boneCount = _model.Bones.Count;

            this.boneTransforms = new Matrix[boneCount];
            _model.CopyBoneTransformsTo(this.boneTransforms);

            this.boneTransformsOriginal = new Matrix[boneCount];
            _model.CopyBoneTransformsTo(this.boneTransformsOriginal);

            this.absoluteBoneTransforms = new Matrix[boneCount];

            SetAnimation("Idle");
        }
开发者ID:mrommel,项目名称:MiRo.SimHexWorld,代码行数:32,代码来源:ModelEntity.cs

示例9: LoadContent

        protected override void LoadContent()
        {
            // Load Fonts
            startFont = Content.Load<SpriteFont>(@"fonts\Start");
            descriptionFont = Content.Load<SpriteFont>(@"fonts\Description");
            font = Content.Load<SpriteFont>(@"fonts\SpriteFont");

            String temp = "Score: " + score;

            mainscore = new Button(Content.Load<Texture2D>("widebutton"),//Texture
                new Vector2(Window.ClientBounds.Width-220, 20),//Position
                new Point(200, 50),//Framesize
                0, //Collision Offset
                font,
                Color.Black,
                temp);

            temp = "Happiness: " + happiness;

            happyscore = new Button(Content.Load<Texture2D>("widebutton"),//Texture
                new Vector2(Window.ClientBounds.Width - 220, 70),//Position
                new Point(200, 50),//Framesize
                0, //Collision Offset
                font,
                Color.Black,
                temp);

            mainscore.buttonhover = mainscore.buttonnorm = mainscore.buttonpressed = Content.Load<Texture2D>("widebutton");
            happyscore.buttonhover = happyscore.buttonnorm = happyscore.buttonpressed = Content.Load<Texture2D>("widebutton");

            enter = new Button(Content.Load<Texture2D>("buttonnorm"),//Texture
                new Vector2(Window.ClientBounds.Width / 2 - 50, 420),//Position
                new Point(100, 50),//Framesize
                0, //Collision Offset
                font,
                Color.Black,
                "Start!");

            enter.buttonhover = enter.buttonnorm = enter.buttonpressed = Content.Load<Texture2D>("buttonhover");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Add RPS
            rps = new RPS(this);

            //Add Matching
            matching = new Matching(this);

            //Add Cards
            cards = new Cards(this);

            //Save game to file class
            gameFile = new GameInfo(this);
            //Load in game info
            gameFile.getFile();

            //Load Food textures
            //apple = Content.Load<Texture2D>(@"Food/apple-icon");
            //cherries = Content.Load<Texture2D>(@"Food/Cherry");
            //banana = Content.Load<Texture2D>(@"Food/Banana");

            //Loading Model
            m = Content.Load<Model>("hippo7");
            modelTransforms = new Matrix[m.Bones.Count];
            originalTransforms = new Matrix[m.Bones.Count];
            m.CopyBoneTransformsTo(originalTransforms);

            //Load Tree
            tree = Content.Load<Model>("tree4-fbx");
            treemodelTransforms = new Matrix[tree.Bones.Count];
            treeoriginalTransforms = new Matrix[m.Bones.Count];
            tree.CopyBoneTransformsTo(treeoriginalTransforms);

            //Load Grass
            grass = Content.Load<Model>("grass_low_poly");
            grassmodelTransforms = new Matrix[grass.Bones.Count];
            grassoriginalTransforms = new Matrix[grass.Bones.Count];
            grass.CopyBoneTransformsTo(grassoriginalTransforms);

            //Loading Terrain
            t = new Terrain(this);
            t.Initialize();

            //Load Hippo
            h = new Hippo(this);
            h.Initialize();

            //Loading Height Texture
            Texture2D heightMap = Content.Load<Texture2D>("Untitled");

            // Load Sounds
            audioBackground = Content.Load<SoundEffect>(@"sound\jungle");
            backgroundInstance = audioBackground.CreateInstance();
            backgroundInstance.Volume = 0.35f;

            audioBackground2 = Content.Load<SoundEffect>(@"sound\background1");
            backgroundInstance2 = audioBackground2.CreateInstance();
            backgroundInstance2.Volume = 0.35f;

//.........这里部分代码省略.........
开发者ID:AnthonyNeace,项目名称:xna-final-project,代码行数:101,代码来源:Game1.cs

示例10: LoadContent

        /// <summary>
        /// This function is called to load content into this component
        /// of our game.
        /// </summary>
        /// <param name="content">The content manager to load from.</param>
        public void LoadContent(ContentManager content)
        {
            // Load the second model
            model = content.Load<Model>(asset);

            // Save off all of hte bone information
            int boneCnt = model.Bones.Count;
            bindTransforms = new Matrix[boneCnt];
            boneTransforms = new Matrix[boneCnt];

            model.CopyBoneTransformsTo(bindTransforms);
            model.CopyBoneTransformsTo(boneTransforms);

            // Find all of the doors and save the index for the bone
            for (int b = 0; b < boneCnt; b++)
            {
                if (model.Bones[b].Name.StartsWith("DoorInner") || model.Bones[b].Name.StartsWith("DoorOuter"))
                {
                    //Create and initialize doors
                    Door thisDoor = new Door();
                    thisDoor.boneNum = b;
                    thisDoor.boneName = model.Bones[b].Name;
                    thisDoor.doorState = Door.DoorState.DoorClosed;
                    switch(thisDoor.boneName.Substring(9,thisDoor.boneName.Length-9))
                    {
                        case "1":
                            thisDoor.location=new Vector3(218,0,1023);
                            break;
                        case "2":
                            thisDoor.location=new Vector3(-11,0,-769);
                            break;
                        case "3":
                            thisDoor.location=new Vector3(587,0,-999);
                            break;
                        case "4":
                            thisDoor.location=new Vector3(787,0,-763);
                            break;
                        case "5":
                            thisDoor.location=new Vector3(1187,0,-1218);
                            break;
                    }
                    doors.Add(thisDoor);
                }
            }
        }
开发者ID:ksuh90,项目名称:P3,代码行数:50,代码来源:PrisonModel.cs

示例11: object3d

 public object3d(Model modelToUse)
 {
     objectModel = modelToUse;
     originaltransforms = new Matrix[objectModel.Bones.Count];
     objectModel.CopyBoneTransformsTo(originaltransforms);
     transforms = new Matrix[objectModel.Bones.Count];           // probably not necessary but
     objectModel.CopyAbsoluteBoneTransformsTo(transforms);       // better safe than sorry
     pivotPoints = new Vector3[objectModel.Bones.Count];
 }
开发者ID:easdale2010,项目名称:3DManRunning,代码行数:9,代码来源:gameworld3d.cs

示例12: LoadContent

        /// <summary>
        /// This function is called to load content into this component
        /// of our game.
        /// </summary>
        /// <param name="content">The content manager to load from.</param>
        public void LoadContent(ContentManager content)
        {
            // Load the second model
            model = content.Load<Model>(asset);

            // Save off all of hte bone information
            int boneCnt = model.Bones.Count;
            bindTransforms = new Matrix[boneCnt];
            boneTransforms = new Matrix[boneCnt];

            model.CopyBoneTransformsTo(bindTransforms);
            model.CopyBoneTransformsTo(boneTransforms);

            // Find all of the doors
            for (int b = 0; b < boneCnt; b++)
            {
                if (model.Bones[b].Name.StartsWith("DoorInner") || model.Bones[b].Name.StartsWith("DoorOuter"))
                {
                    // What is the door number?
                    int dnum = int.Parse(model.Bones[b].Name.Substring(9));

                    // Add to a dictionary that converts door numbers to bone indices
                    doors[dnum] = new Door();
                    doors[dnum].Bone = b;
                }

            }
        }
开发者ID:Kingofhearts102,项目名称:Step7,代码行数:33,代码来源:PrisonModel.cs

示例13: LoadContent

        /// <summary>
        /// This function is called to load content into this component
        /// of our game.
        /// </summary>
        /// <param name="content">The content manager to load from.</param>
        public void LoadContent(ContentManager content)
        {
            // Load the second model
            model = content.Load<Model>(asset);

            // Save off all of hte bone information
            int boneCnt = model.Bones.Count;
            bindTransforms = new Matrix[boneCnt];
            boneTransforms = new Matrix[boneCnt];

            model.CopyBoneTransformsTo(bindTransforms);
            model.CopyBoneTransformsTo(boneTransforms);

            // Find all of the doors and save the index for the bone
            for (int b = 0; b < boneCnt; b++)
            {
                if (model.Bones[b].Name.StartsWith("DoorInner") || model.Bones[b].Name.StartsWith("DoorOuter"))
                {
                    doors.Add(b);
                }

            }

            // As supplied, all of the doors are closed. This code opens each door by
            // translating it up 2 meters.
               // foreach (int d in doors)
               // {
                //boneTransforms[d] = Matrix.CreateTranslation(0, 0, 0) * bindTransforms[d];
               // }
        }
开发者ID:Kingofhearts102,项目名称:PrisonSteps,代码行数:35,代码来源:PrisonModel.cs

示例14: CalculerDimensionModele

        public Vector3 CalculerDimensionModele(Model Modèle)
        {
            // Create variables to hold min and max xyz values for the model. Initialise them to extremes
             Vector3 modelMax = new Vector3(float.MinValue, float.MinValue, float.MinValue);
             Vector3 modelMin = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);

             Matrix[] transformationModele = new Matrix[Modèle.Bones.Count];
             Modèle.CopyBoneTransformsTo(transformationModele);

             foreach (ModelMesh mesh in Modèle.Meshes)
             {
            //Create variables to hold min and max xyz values for the mesh. Initialise them to extremes
            Vector3 meshMax = new Vector3(float.MinValue, float.MinValue, float.MinValue);
            Vector3 meshMin = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);

            // There may be multiple parts in a mesh (different materials etc.) so loop through each
            foreach (ModelMeshPart part in mesh.MeshParts)
            {
               // The stride is how big, in bytes, one vertex is in the vertex buffer
               // We have to use this as we do not know the make up of the vertex
               int stride = part.VertexBuffer.VertexDeclaration.VertexStride;

               byte[] vertexData = new byte[stride * part.NumVertices];
               part.VertexBuffer.GetData(part.VertexOffset * stride, vertexData, 0, part.NumVertices, 1); // fixed 13/4/11

               // Find minimum and maximum xyz values for this mesh part
               // We know the position will always be the first 3 float values of the vertex data
               Vector3 vertPosition = new Vector3();
               for (int ndx = 0; ndx < vertexData.Length; ndx += stride)
               {
                  vertPosition.X = BitConverter.ToSingle(vertexData, ndx);
                  vertPosition.Y = BitConverter.ToSingle(vertexData, ndx + sizeof(float));
                  vertPosition.Z = BitConverter.ToSingle(vertexData, ndx + sizeof(float) * 2);

                  // update our running values from this vertex
                  meshMin = Vector3.Min(meshMin, vertPosition);
                  meshMax = Vector3.Max(meshMax, vertPosition);
               }
            }

            // transform by mesh bone transforms
            meshMin = Vector3.Transform(meshMin, transformationModele[mesh.ParentBone.Index]);
            meshMax = Vector3.Transform(meshMax, transformationModele[mesh.ParentBone.Index]);

            // Expand model extents by the ones from this mesh
            modelMin = Vector3.Min(modelMin, meshMin);
            modelMax = Vector3.Max(modelMax, meshMax);
             }

             // Create and return the model bounding box
             return ValeurAbsolueVecteur(modelMax) + ValeurAbsolueVecteur(modelMin);
        }
开发者ID:karmoka,项目名称:DerniereFoisGuys,代码行数:52,代码来源:CubeCollision.cs


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