Ejemplo n.º 1
0
        //Animated model constructor
        public LoadModel(Model Model, Vector3 Position, Vector3 Rotation,
            Vector3 Scale, GraphicsDevice GraphicsDevice,
            ContentManager Content, LightsAndShadows.Light light)
        {
            this.baseWorld = Matrix.CreateScale(Scale) * Matrix.CreateRotationX(Rotation.X)
            *Matrix.CreateRotationY(Rotation.Y)*
            Matrix.CreateRotationZ(Rotation.Z)*
            Matrix.CreateTranslation(Position);
            shadowCasters = new List<ShadowCasterObject>();
            //Console.WriteLine(Position);
            this.Model = Model;
            this.graphicsDevice = GraphicsDevice;
            this.content = Content;
            this.Position = Position;
            this.playerTarget = Vector3.Zero;
            this.Rotation = Rotation;
            this.Scale = Scale;
            this.light = light;
            modelTransforms = new Matrix[Model.Bones.Count];
            Model.CopyAbsoluteBoneTransformsTo(modelTransforms);
            SkinningData skinningData = Model.Tag as SkinningData;
            if (skinningData == null)
                throw new InvalidOperationException
                    ("This model does not contain a SkinningData tag.");
            this.skinningData = Model.Tag as SkinningData;
            Player = new AnimationPlayer(skinningData);
            buildBoundingSphereAnimated();

            foreach (ModelMesh mesh in Model.Meshes)
            {
                if (!mesh.Name.Contains("Bounding"))
                    foreach (ModelMeshPart meshpart in mesh.MeshParts)
                    {

                        ShadowCasterObject shad = new ShadowCasterObject(
                            //meshpart.VertexDeclaration,
                                                       meshpart.VertexBuffer,
                                                       meshpart.VertexOffset,
                            //meshpart.VertexStride,
                                                       meshpart.IndexBuffer,
                            //meshpart.BaseVertex,
                                                       meshpart.NumVertices,
                                                       meshpart.StartIndex,
                                                       meshpart.PrimitiveCount,
                                                       modelTransforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(Position));
                        this.shadowCasters.Add(shad);
                    }
            }
        }
Ejemplo n.º 2
0
 //Animated model constructor
 public LoadModel(Model Model, Vector3 Position, Vector3 Rotation,
     Vector3 Scale, GraphicsDevice GraphicsDevice,
     ContentManager Content)
 {
     this.baseWorld = Matrix.CreateScale(Scale) * Matrix.CreateFromYawPitchRoll(
        Rotation.Y, Rotation.X, Rotation.Z)
        * Matrix.CreateTranslation(Position);
     Console.WriteLine(Position);
     this.Model = Model;
     this.graphicsDevice = GraphicsDevice;
     this.content = Content;
     this.Position = Position;
     this.playerTarget = Vector3.Zero;
     this.Rotation = Rotation;
     this.Scale = Scale;
     modelTransforms = new Matrix[Model.Bones.Count];
     Model.CopyAbsoluteBoneTransformsTo(modelTransforms);
     SkinningData skinningData = Model.Tag as SkinningData;
     if (skinningData == null)
         throw new InvalidOperationException
             ("This model does not contain a SkinningData tag.");
     this.skinningData = Model.Tag as SkinningData;
     Player = new AnimationPlayer(skinningData);
     buildBoundingSphereAnimated();
 }