コード例 #1
0
        protected override void LoadContent()
        {
            //IMPORTANT POUR ZOMBIE
            CaméraJeu              = Game.Services.GetService(typeof(Caméra)) as Caméra;
            GestionCollisions      = Game.Services.GetService(typeof(CollisionManager)) as CollisionManager;
            GestionSons            = Game.Services.GetService(typeof(SoundManager)) as SoundManager;
            Watney                 = Game.Services.GetService(typeof(Pathfinder)) as Pathfinder;
            GestionnaireDeTextures = Game.Services.GetService(typeof(RessourcesManager <Texture2D>)) as RessourcesManager <Texture2D>;
            CarteJeu               = Game.Services.GetService(typeof(Carte)) as Carte;

            Delta = CarteJeu.Delta;

            DéplacementHaut   = new Vector3(0, 0, -Delta.Z);
            DéplacementBas    = new Vector3(0, 0, Delta.Z);
            DéplacementDroite = new Vector3(Delta.X, 0, 0);
            DéplacementGauche = new Vector3(-Delta.X, 0, 0);
            base.LoadContent();

            Habit = GestionnaireDeTextures.Find(NomTexture);

            SkinningData skinningData = Modèle.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            AnimationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips[NomAnim];

            AnimationPlayer.StartClip(clip);
        }
コード例 #2
0
        private static SkinningData[] ReadSkinningData(BinaryReader reader, long count, string[] stringList)
        {
            var result = new SkinningData[count];

            for (var i = 0; i < count; i++)
            {
                // Read 4 joints
                var joints = new string[4];
                for (var j = 0; j < 4; j++)
                {
                    joints[j] = stringList[reader.ReadInt16()];
                }

                // Read 4 weights
                var weights = new float[4];
                for (var j = 0; j < 4; j++)
                {
                    weights[j] = reader.ReadSingle();
                }

                result[i] = new SkinningData
                {
                    JointNames = joints,
                    Weights    = weights
                };
            }

            return(result);
        }
コード例 #3
0
ファイル: Deck.cs プロジェクト: MoysheBenRabi/setp
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font        = Content.Load <SpriteFont>("Courier New");

            // Load the model.
            characterModel = Content.Load <Model>("dude");
            sphereModel    = Content.Load <Model>("football");
            bubbleModel    = Content.Load <Model>("bubble");

            discModel = Content.Load <Model>("disc");

            Transforms = new Matrix[sphereModel.Bones.Count];
            sphereModel.CopyAbsoluteBoneTransformsTo(Transforms);

            // Look up our custom skinning information.
            SkinningData skinningData = characterModel.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips["Take 001"];

            animationPlayer.StartClip(clip);

            engine.Startup();
        }
コード例 #4
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load the model.
            currentModel = Content.Load <Model>("dude");

            // Look up our custom skinning information.
            skinningData = currentModel.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            boneTransforms = new Matrix[skinningData.BindPose.Count];

            // Load the baseball bat model.
            baseballBat = Content.Load <Model>("baseballbat");

            // Create an animation player, and start decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips["Take 001"];

            animationPlayer.StartClip(clip);

            // Load the bounding spheres.
            skinnedSpheres  = Content.Load <SkinnedSphere[]>("CollisionSpheres");
            boundingSpheres = new BoundingSphere[skinnedSpheres.Length];

            spherePrimitive = new SpherePrimitive(GraphicsDevice, 1, 12);
        }
コード例 #5
0
        protected override void LoadContent()
        {
            GestionInput           = Game.Services.GetService(typeof(InputManager)) as InputManager;
            GestionSons            = Game.Services.GetService(typeof(SoundManager)) as SoundManager;
            GestionCollisions      = Game.Services.GetService(typeof(CollisionManager)) as CollisionManager;
            CaméraJeu              = Game.Services.GetService(typeof(Caméra)) as Caméra;
            GestionnaireDeModèles  = Game.Services.GetService(typeof(RessourcesManager <Model>)) as RessourcesManager <Model>;
            GestionnaireDeTextures = Game.Services.GetService(typeof(RessourcesManager <Texture2D>)) as RessourcesManager <Texture2D>;
            LampeDePoche           = Game.Services.GetService(typeof(LampeTorche)) as LampeTorche;
            CalculerMonde();

            Modele = GestionnaireDeModèles.Find(NomModel);
            TransformationsModèle = new Matrix[Modele.Bones.Count];
            Habit = GestionnaireDeTextures.Find(NomTexture);

            SkinningData skinningData = Modele.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            AnimationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips[NomAnim];

            AnimationPlayer.StartClip(clip);
            base.LoadContent();
        }
コード例 #6
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            contentManager = new ContentManager(null)
            {
                RootDirectory = "Content"
            };

            // Load the model.
            currentModel = contentManager.Load <Model>("dude");

            // Look up our custom skinning information.
            SkinningData skinningData = currentModel.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips["Take 001"];

            animationPlayer.StartClip(clip);
        }
コード例 #7
0
        /// <summary>
        /// Helper to add a new skinned model to the scene with
        /// the same name key as the file for the model
        /// </summary>

        public Model AddSkinnedModel(String modelPath, String take = "Take 001")
        {
            Model skinnedModel = new Model(FindModel(modelPath));

            // Look up our custom skinning information.
            SkinningData skinningData = skinnedModel.modelTag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            skinnedModel.animationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips[take];

            skinnedModel.animationPlayer.StartClip(clip);

            // Add to the model list
            sceneModels.Add(modelPath, skinnedModel);

            return(sceneModels[modelPath]);
        }
コード例 #8
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont  = Content.Load <SpriteFont>("MessageFont");
            // Load the model.
            currentModel = Content.Load <Model>("dude");

            SkinningData skinningData = currentModel.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            setupKinect();
            // Look up our custom skinning information.

            // Create an animation player, and start decoding an animation clip.


            //v1
            //Dictionary<JointType, int> jointMap = LoadJointMapDude();
            //animationPlayer = new AnimationPlayer(currentModel, graphics.GraphicsDevice.RasterizerState, jointMap);

            //v2
            animationPlayer = new AnimationPlayer(skinningData, graphics.GraphicsDevice.RasterizerState);


            AnimationClip clip = skinningData.AnimationClips["Take 001"];

            animationPlayer.StartClip(clip);
        }
コード例 #9
0
ファイル: Game1.cs プロジェクト: andva/Eulerian-ShootEmUp
        private void LoadKillers()
        {
            rasmus     = Content.Load <Model>("Models/rasmusFinal");
            hampus     = Content.Load <Model>("Models/hampusFinal");
            valter     = Content.Load <Model>("Models/valterFinal");
            axel       = Content.Load <Model>("Models/axelFinal5");
            rifleModel = Content.Load <Model>("Models/rifleHands1");
            gunPos     = riflePos;
            currentWep = rifleModel;

            hampusSkinningData = hampus.Tag as SkinningData;
            rasmusSkinningData = rasmus.Tag as SkinningData;
            axelSkinningData   = axel.Tag as SkinningData;
            valterSkinningData = valter.Tag as SkinningData;
            if (hampusSkinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag. Har du satt SkinnedModelProcessor? ");
            }
            Globals.hampusSkinningData = hampusSkinningData;
            Globals.rasmusSkinningData = rasmusSkinningData;
            Globals.axelSkinningData   = axelSkinningData;
            Globals.valterSkinningData = valterSkinningData;
            rifleSkinningData          = rifleModel.Tag as SkinningData;
            if (rifleSkinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag. Har du satt SkinnedModelProcessor? ");
            }

            clipPlayer = new ClipPlayer(rifleSkinningData, fps);
            rifleClip  = rifleSkinningData.AnimationClips["Take 001"];

            shadowEffect = Content.Load <Effect>("Effects/ShadowEffect");
        }
コード例 #10
0
        /// <summary>
        /// Copies only the geometry (Mesh,
        /// MinimumBoundingBox, MinimumBoundingSphere, TriangleCount and Transforms)
        /// </summary>
        /// <param name="model">A source model from which to copy</param>
        public override void CopyGeometry(IModel model)
        {
            if (!(model is AnimatedModel))
            {
                return;
            }

            AnimatedModel srcModel = (AnimatedModel)model;

            skinnedModel = srcModel.SkinnedModel;

            vertices.AddRange(((IPhysicsMeshProvider)model).Vertices);
            indices.AddRange(((IPhysicsMeshProvider)model).Indices);

            // Look up our custom skinning information.
            skinningData = srcModel.skinnedModel.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new GoblinException("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);

            triangleCount        = srcModel.TriangleCount;
            boundingBox          = srcModel.MinimumBoundingBox;
            boundingSphere       = srcModel.MinimumBoundingSphere;
            UseInternalMaterials = srcModel.UseInternalMaterials;
        }
コード例 #11
0
        public ShipFbx(String modelName)
        {
            model = BeatShift.contentManager.Load <Model>("Models/Ships/" + modelName);


            SkinningData skd = GetSkinningDataFromTag();

            if (isAnimated)
            {
                clipPlayer = new ClipPlayer(skd, 24);
            }
            else
            {
                bones = new Matrix[model.Bones.Count];
                model.CopyAbsoluteBoneTransformsTo(bones);
            }

#if !DEBUG
            Utils.fixNullLightDirections(model);
#endif

            GC.Collect();

            //Override the default texture
            //Texture2D grayTexture;
            //grayTexture = content.Load<Texture2D>("tex5");
            //shipRenderer.Texture = grayTexture;
            //shipRenderer.TextureEnabled = true;
        }
コード例 #12
0
        //sets the first frame for the take and file (e.g. "Take 001", "dude")
        public void SetAnimation(string takeName, string fileNameNoSuffix)
        {
            AnimationDictionaryKey key = new AnimationDictionaryKey(takeName, fileNameNoSuffix);

            //have we requested a different animation and is it in the dictionary?
            //first time or different animation request
            if (this.oldKey == null || (!this.oldKey.Equals(key) && this.modelDictionary.ContainsKey(key)))
            {
                //set the model based on the animation being played
                this.Model = modelDictionary[key];

                //retrieve the animation player
                animationPlayer = animationPlayerDictionary[key];

                //retrieve the skinning data
                skinningData = skinningDataDictionary[key];

                //set the skinning data in the animation player and set the player to start at the first frame for the take
                animationPlayer.StartClip(skinningData.AnimationClips[key.takeName]);
            }


            //store current key for comparison in next update to prevent re-setting the same animation in successive calls to SetAnimation()
            this.oldKey = key;
        }
コード例 #13
0
        /// <summary>
        /// The main Process method converts an intermediate format content pipeline
        /// NodeContent tree to a ModelContent object with embedded animation data.
        /// </summary>
        public override ModelContent Process(NodeContent input, ContentProcessorContext context)
        {
            SkinningData skinningData = SkinningHelpers.GetSkinningData(input, context, SkinnedEffect.MaxBones);
            ModelContent model        = base.Process(input, context);

            model.Tag = skinningData;
            return(model);
        }
コード例 #14
0
        /// <summary>
        /// Load graphics content for the screen.
        /// </summary>
        public override void LoadContent()
        {
            spriteBatch = new SpriteBatch(m_core.GraphicsDevice);
            m_player    = new Player();
            m_floor     = new Floor();
            m_enemy     = new Enemy();
            //  m_building = new Building();

            GameCore.Camera.Player = m_player;

            font = m_core.Content.Load <SpriteFont>("gamefont");
            //m_player.Model = m_core.Content.Load<Model>("player/soldier2");
            m_player.Model = m_core.Content.Load <Model>("player/vojak_anim");
            m_floor.Model  = m_core.Content.Load <Model>("other/model2");
            //m_enemy.Model = m_core.Content.Load<Model>("player/zombie");
            //  m_building.Model = m_core.Content.Load<Model>("other/blok_1");


            // Look up our custom skinning information.
            SkinningData skinningDataPlayer = m_player.Model.Tag as SkinningData;

            if (skinningDataPlayer == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            m_player.Anim = new AnimationPlayer(skinningDataPlayer);


            AnimationClip clip = skinningDataPlayer.AnimationClips["Action"];

            m_player.Anim.StartClip(clip);


            // Load the model.
            m_enemy.Model = m_core.Content.Load <Model>("player/zombie2_bones");

            // Look up our custom skinning information.
            SkinningData skinningData = m_enemy.Model.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            //animationPlayer = new AnimationPlayer(skinningData);

            m_enemy.Anim = new AnimationPlayer(skinningData);


            AnimationClip clip2 = skinningData.AnimationClips["Animace"];

            m_enemy.Anim.StartClip(clip2);
        }
コード例 #15
0
        public AnimatedModel2(DrawableModel2 model)
        {
            _model = model;

            _modelSkinningData = _model.Model.Model.Tag as SkinningData;
            _animation         = new AnimationPlayer(_modelSkinningData);

            //SetNewEffect();
        }
コード例 #16
0
ファイル: GameModel.cs プロジェクト: mizzouse/Battalion
        public void Init()
        {
            SkinningData    = model.Tag as SkinningData;
            AnimationPlayer = new AnimationPlayer(SkinningData);

            LoadAnimations();

            AnimationPlayer.StartClip(Clips[CurrentAnimation]);
        }
コード例 #17
0
ファイル: Game.cs プロジェクト: YashC/IXVI
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            m_spriteBatch     = new SpriteBatch(GraphicsDevice);
            m_model           = Content.Load <Model> ("Models\\test.dgn.i.2010");
            m_gameState.Model = m_model;
            m_modelExtents    = m_model.GetBoundingBox();

            float   groundWidth   = 10.0f * (m_modelExtents.Max.X - m_modelExtents.Min.X);
            float   groundDepth   = 10.0f * (m_modelExtents.Max.Z - m_modelExtents.Min.Z);
            float   groundOriginX = m_modelExtents.Min.X + (groundWidth * 0.5f);
            float   groundOriginZ = m_modelExtents.Min.Z + (groundDepth * 0.5f);
            float   groundOriginY = m_modelExtents.Min.Y;
            Vector3 groundOrigin  = new Vector3(0.0f, 0.0f, 0.0f);

            //Copy model and transform to HUDComponent
            headsUpDisplay.Model      = m_model;
            headsUpDisplay.Transforms = new Matrix[m_model.Bones.Count];
            m_model.CopyAbsoluteBoneTransformsTo(headsUpDisplay.Transforms);


            m_quad = new Quad(groundOrigin, Vector3.Up, Vector3.Forward, m_gameState.FarClip, m_gameState.FarClip);

            // Allocate the transform matrix array.
            m_gameState.BoneTransforms = new Matrix[m_model.Bones.Count];

            //Avatar
            m_avatar = Content.Load <Model> ("Avatar\\dude");

            // Look up our custom skinning information.
            SkinningData skinningData = m_avatar.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);

            m_clip = skinningData.AnimationClips["Take 001"];
            animationPlayer.StartClip(m_clip);

            // TODO: Load any ResourceManagementMode.Automatic content
            m_texture    = Content.Load <Texture2D> (@"Textures\GreenOnBlackGrid");
            m_quadEffect = new BasicEffect(m_graphics.GraphicsDevice);
            m_quadEffect.EnableDefaultLighting();


            m_quadEffect.World          = Matrix.CreateTranslation(Vector3.Zero);
            m_quadEffect.TextureEnabled = true;
            m_quadEffect.Texture        = m_texture;

            //m_kinectVideo = new Texture2D (GraphicsDevice, 640, 480);
        }
コード例 #18
0
        public void PlayerLoad()
        {
            modelTransform = new Matrix[modelData.Bones.Count];
            modelData.CopyAbsoluteBoneTransformsTo(modelTransform);

            playerSkinningData = modelData.Tag as SkinningData;
            playerAnimation    = new AnimationPlayer(playerSkinningData);

            ChangeAnimationClip(clipNames[clipIndex], loopEnable, 0.0f);
        }
コード例 #19
0
        public void VertexPosition3DUVSkinned()
        {
            var skinning = new SkinningData(0, 0, 0.0f, 0.0f);
            var vertex   = new VertexPosition3DUVSkinned(Vector3D.UnitX, Vector2D.One, skinning);

            Assert.AreEqual(vertex.Format, VertexFormat.Position3DUVSkinned);
            Assert.AreEqual(Vector3D.UnitX, vertex.Position);
            Assert.AreEqual(Vector2D.One, vertex.UV);
            Assert.AreEqual(skinning, vertex.Skinning);
        }
コード例 #20
0
 public void CheckVertexPosition3DColorSkinned()
 {
     Assert.AreEqual(32, VertexPosition3DColorSkinned.SizeInBytes);
     var skinning = new SkinningData(0, 0, 0.0f, 0.0f);
     var vertex = new VertexPosition3DColorSkinned(Vector3D.UnitX, Color.White, skinning);
     Assert.AreEqual(vertex.Format, VertexFormat.Position3DColorSkinned);
     Assert.AreEqual(Vector3D.UnitX, vertex.Position);
     Assert.AreEqual(Color.White, vertex.Color);
     Assert.AreEqual(skinning, vertex.Skinning);
 }
コード例 #21
0
ファイル: Character.cs プロジェクト: Krzem0/AnimacjaModeli3D
        protected override void LoadContent()
        {
            //_character = Game.Content.Load<Model>("Models/Character_FBX/character_FBX");
            //_character = Game.Content.Load<Model>("Models/dude/dude");
            _character = Game.Content.Load <Model>("Models/creature_4d1");
            SetSkinnedEffect();
            skinningData    = _character.Tag as SkinningData;
            dragonAnimation = new DragonAnimation(skinningData);

            base.LoadContent();
        }
コード例 #22
0
        private void prepareAnimation()
        {
            skinningData = model.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException("This model does not contain a SkinningData tag.");
            }

            animationPlayer = new AnimationPlayer(skinningData);
        }
コード例 #23
0
 public BasicModel(Model m, Game1 game)
 {
     model        = m;
     this.game    = game;
     transforms   = new Matrix[model.Bones.Count];
     skinningData = model.Tag as SkinningData;
     if (skinningData != null)
     {
         animationPlayer = new AnimationPlayer(skinningData);
     }
 }
コード例 #24
0
        /// <summary>
        /// Constructs a new animation player.
        /// </summary>
        public AnimationPlayer(SkinningData skinningData)
        {
            if (skinningData == null)
                throw new ArgumentNullException("skinningData");

            skinningDataValue = skinningData;

            boneTransforms = new Matrix[skinningData.BindPose.Count];
            worldTransforms = new Matrix[skinningData.BindPose.Count];
            skinTransforms = new Matrix[skinningData.BindPose.Count];
        }
コード例 #25
0
ファイル: AAnimation.cs プロジェクト: 0000duck/MiniRTS
        public AAnimation(Entity entity, SkinningData skinningData)
        {
            this.Entity = entity;

            this.SkinningData   = skinningData;
            this.SkinTransforms = new Matrix[SkinningData.MaxBones];
            for (var i = 0; i < this.SkinTransforms.Length; i++)
            {
                this.SkinTransforms[i] = Matrix.Identity;
            }
        }
コード例 #26
0
ファイル: AnimatedModel.cs プロジェクト: nkirdis/ColladaXna
        /// <summary>
        /// Creates a new AnimatedModel instance based on the given model, which:
        /// a) already has to be loaded
        /// </summary>
        /// <param name="model"></param>
        public AnimatedModel(Model model)
        {
            this.model = model;

            skinningData = model.Tag as SkinningData;
            if (skinningData == null)
            {
                throw new InvalidOperationException("Model contains no animation data! Did you use the SkinnedModelProcessor?");
            }

            player = new AnimationPlayer(skinningData);
        }
コード例 #27
0
        public void CheckVertexPosition3DColorSkinned()
        {
            Assert.AreEqual(32, VertexPosition3DColorSkinned.SizeInBytes);
            var skinning = new SkinningData(0, 0, 0.0f, 0.0f);
            var vertex   = new VertexPosition3DColorSkinned(Vector3D.UnitX, Color.White, skinning);

            Assert.AreEqual(vertex.Format, VertexFormat.Position3DColorSkinned);
            Assert.AreEqual(Vector3D.UnitX, vertex.Position);
            Assert.AreEqual(Color.White, vertex.Color);
            Assert.AreEqual(skinning, vertex.Skinning);
            Assert.AreEqual(32, VertexPosition3DColorSkinned.SizeInBytes);
        }
コード例 #28
0
ファイル: Models.cs プロジェクト: mizzouse/Battalion
        //Rewrite to use some sort of file to get all paths and IDs
        //These IDs are the numbers a developer will need when choosing the modelID number on vehicles/weapons/items

        public void setSkinningData()
        {
            _skinningData = _model.Tag as SkinningData;

            _animation = new AnimationPlayer(_skinningData);

            AnimationClip clip = _skinningData.AnimationClips["Kick"];

            _clips.Add("Kick", clip);

            //_animation.Start();
        }
コード例 #29
0
        public static void TransformAnimatedModel(Model model, Microsoft.Xna.Framework.Game game, Matrix world)
        {
            SkinningData skinningData = (SkinningData)model.Tag;

            renderTarget = GfxComponent.CreateCustomRenderTarget(game.GraphicsDevice, 1, SurfaceFormat.Color, MultiSampleType.None, (int)TextureSize.X, (int)TextureSize.Y);
            depthBuffer  = GfxComponent.CreateDepthStencil(renderTarget);
            Texture2D tex;

            Color[] reverseTexture  = new Color[(int)(TextureSize.X * TextureSize.Y)];
            Color[] originalTexture = new Color[(int)(TextureSize.X * TextureSize.Y)];

            Vertices vertices;

            ModelAnimationPlayer player = new ModelAnimationPlayer(skinningData);

            foreach (AnimationClip clip in skinningData.AnimationClips.Values)
            {
                clip.vertices = new Dictionary <int, Vertices>[] { new Dictionary <int, Vertices>(), new Dictionary <int, Vertices>() };

                player.SetClip(clip);

                bool hasGoneThrough = false;
                int  lastKeyFrame   = 0;
                while (!hasGoneThrough)
                {
                    RenderToTarget(model, player, game, world, out tex);
                    vertices = GetVertices(tex, model);

                    if (vertices.Count != 1)
                    {
                        clip.vertices[(int)ModelDirection.Right][player.CurrentKeyframe] = vertices;

                        // flip the texture and the vertices
                        tex.GetData <Color>(originalTexture);
                        int left = 0;
                        for (int right = (int)TextureSize.X - 1; right >= 0; right--, left++)
                        {
                            for (int j = 0; j < TextureSize.Y; j++)
                            {
                                reverseTexture[left + j * (int)TextureSize.X] = originalTexture[right + j * (int)TextureSize.X];
                            }
                        }

                        tex.SetData <Color>(reverseTexture);
                        clip.vertices[(int)ModelDirection.Left][player.CurrentKeyframe] = GetVertices(tex, model);
                    }
                    lastKeyFrame = player.CurrentKeyframe;
                    player.StepClip();
                    hasGoneThrough = (player.CurrentKeyframe - lastKeyFrame < 1);
                }
            }
        }
コード例 #30
0
        public DragonAnimation(SkinningData skinningData)
        {
            _skinningData    = skinningData;
            _boneTransforms  = new Matrix[skinningData.BindPose.Count];
            _worldTransforms = new Matrix[skinningData.BindPose.Count];
            _skinTransforms  = new Matrix[skinningData.BindPose.Count];
            _boneTransforms  = skinningData.BindPose.ToArray();
            _cheek           = new KeyframedAnimation(CheekAnimation(), true);

            LegsInitialization();
            TailInitialization();
            SpinalColumnInitialization();
        }
コード例 #31
0
        public AnimatedMonster(Camera camera, Game1 game, String path)
        {
            this.camera        = camera;
            this.modelPosition = new Vector3(0.0f, 0.0f, 0.0f);
            this.modelRotation = new Vector3(0.0f, 0.0f, 0.0f);
            myModel            = game.Content.Load <Model>(path);
            SkinningData skinningData = myModel.Tag as SkinningData;

            animationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips["Take 001"];

            animationPlayer.StartClip(clip);
        }
コード例 #32
0
        public void SkinningSetting(string startPose)
        {
            mSkinningData = Model.Tag as SkinningData;
            if (mSkinningData == null)
            {
                throw new InvalidOperationException("This model does not contain a SkinningData tag.");
            }
            AnimationPlayer = new AnimationPlayer(mSkinningData);
            AnimationSpeed  = 0.04f;
            AnimationClip clip = mSkinningData.AnimationClips[startPose];

            AnimationPlayer.StartClip(clip);
            mTemppose = startPose;
        }
コード例 #33
0
ファイル: SkinnedModel.cs プロジェクト: JohanGl/Outworld-XNA
        public void Initialize(Model model)
        {
            this.model = model;

            // Look up our custom skinning information.
            skinningData = model.Tag as SkinningData;

            if (skinningData == null)
            {
                throw new InvalidOperationException("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);
        }
コード例 #34
0
 internal CpuSkinnedModel(List<CpuSkinnedModelPart> modelParts, SkinningData skinningData)
 {
     this.modelParts = modelParts;
     this.SkinningData = skinningData;
     this.Parts = new ReadOnlyCollection<CpuSkinnedModelPart>(this.modelParts);
 }
コード例 #35
0
ファイル: Actor.cs プロジェクト: reisergames/reactor-v1
        public void Load(string filename)
        {
            _model = REngine.Instance._content.Load<Model>(filename);
            Matrix = Matrix.CreateScale(1.0f);
            Scaling = new Vector3(1f, 1f, 1f);
            Matrix = BuildScalingMatrix(Matrix);
            #if XBOX
            _defaultEffect = REngine.Instance._resourceContent.Load<RShader>("Actor.Xbox");
            #elif MACOSX
            _defaultEffect = RShader.LoadEffectResource("Actor.ogl.mgfxo");
            #else
            _defaultEffect = RShader.LoadEffectResource("Actor.ogl.mgfxo");
            #endif
            _defaultEffect.effect.CurrentTechnique = _defaultEffect.effect.Techniques[0];
            _sphere = _model.Meshes[0].BoundingSphere;
            foreach (ModelMesh mesh in _model.Meshes)
            {
                _sphere = BoundingSphere.CreateMerged(_sphere, mesh.BoundingSphere);
                for (int i = 0; i < mesh.MeshParts.Count; i++)
                {
                    BasicEffect effect = (BasicEffect)mesh.MeshParts[i].Effect;

                    Texture t = effect.Texture;
                    mesh.MeshParts[i].Effect = _defaultEffect.effect.Clone();
                    mesh.MeshParts[i].Effect.Parameters["Texture"].SetValue(t);

                }
            }
            _skinningData = _model.Tag as SkinningData;
            _player = new AnimationPlayer(_skinningData);
            _player.StartClip(_skinningData.AnimationIndexes[0], 1.0f);
            _playing = true;
        }
コード例 #36
0
 public void VertexPosition3DUVSkinned()
 {
     var skinning = new SkinningData(0, 0, 0.0f, 0.0f);
     var vertex = new VertexPosition3DUVSkinned(Vector3D.UnitX, Vector2D.One, skinning);
     Assert.AreEqual(vertex.Format, VertexFormat.Position3DUVSkinned);
     Assert.AreEqual(Vector3D.UnitX, vertex.Position);
     Assert.AreEqual(Vector2D.One, vertex.UV);
     Assert.AreEqual(skinning, vertex.Skinning);
 }