コード例 #1
0
        public InstancedSkinnedModel(ContentReader reader)
        {
            this.model = reader.ReadObject<Model>();
            this.instancedSkinningData = new InstancedSkinningData(reader);

            GraphicsDevice device = ((IGraphicsDeviceService)reader.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService))).GraphicsDevice;

            // Create InstancedSkinnedModelMeshes from the ModelMeshes
            foreach (ModelMesh mesh in this.model.Meshes)
            {
                meshes.Add(new InstancedSkinnedModelMesh(mesh, this.instancedSkinningData.AnimationTexture, device));
            }
        }
コード例 #2
0
        public InstancedSkinnedModel(ContentReader reader)
        {
            this.model = reader.ReadObject <Model>();
            this.instancedSkinningData = new InstancedSkinningData(reader);

            GraphicsDevice device = ((IGraphicsDeviceService)reader.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService))).GraphicsDevice;

            // Create InstancedSkinnedModelMeshes from the ModelMeshes
            foreach (ModelMesh mesh in this.model.Meshes)
            {
                meshes.Add(new InstancedSkinnedModelMesh(mesh, this.instancedSkinningData.AnimationTexture, device));
            }
        }
コード例 #3
0
        /// <summary>
        /// Constructor for the Dwarf
        /// </summary>
        /// <param name="position"></param>
        /// <param name="skinningData"></param>
        public Dwarf(Vector3 position, InstancedSkinningData skinningData)
        {
            this.animationData = skinningData;

            //Choose random body parts - having the same dwarf everywhere would be boring!
            this.bodyPart = BodyParts[random.Next(0, 3)];
            this.legPart = LegParts[random.Next(0, 3)];
            this.headPart = HeadParts[random.Next(0, 3)];

            //Mess with the scale some - dwarves come in all shapes and sizes!
            float scale = (float)(random.NextDouble() * 0.4) + 0.8f;
            this.translation = position;

            //Precompute the matrix for translation and scale - rotation will be done dynamically
            this.translationScaleMatrix = Matrix.CreateScale(scale) * Matrix.CreateTranslation(this.translation);

            //Create the bounding sphere for this dwarf
            this.boundingSphere = new BoundingSphere(translation, 1f);
        }