Exemple #1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            S.init(graphics, Content);
            S.Proj = Matrix.CreatePerspectiveFieldOfView(1, S.gd.Viewport.AspectRatio, 0.1f, 1000f);
            Dictionary <string, BVHContent> bla = BVHPlayer.bvhDic;


            attackDirCylinder = new NCylinder(
                0.3f, 0.01f, 5, 6, Color.Red);

            S.player = new BVHPlayer(new BVHContent(
                                         File.ReadAllText(filename),
                                         null,
                                         MainForm.saveRootMovement));

            S.player.Bvh.Skeleton.calc_cylinder_matrices(S.player.Bvh);
            S.player.animate = false;

            axis = new Axis(S.gd, 500, S.View, S.Proj);

            gc = new GroundedClip(
                Vector3.UnitY * 180,
                0.2f, S.player,
                false, 0.17f);

            Game1.Draw3DEvent += gc.Draw;
            Game1.UpdateEvent += gc.Update;

            S.camera = new Camera3D(gc);
        }
Exemple #2
0
        public void Draw(BaseClip bc)
        {
            world = Matrix.CreateScale(bc.Scale)
                    * Matrix.CreateRotationX(bc.RotationX)
                    * Matrix.CreateRotationY(bc.RotationY)
                    * Matrix.CreateRotationZ(bc.RotationZ)
                    * Matrix.CreateTranslation(bc.Position);

            // S.gd.BlendState = BlendState.Opaque;
            S.be.EnableDefaultLighting();
            //S.be.VertexColorEnabled = false;
            //S.be.Techniques[0].Passes[0].Apply();

            foreach (ModelMesh mesh in mdl.Meshes)
            {
                foreach (BasicEffect be in mesh.Effects)
                {
                    be.View       = S.be.View;
                    be.Projection = S.be.Projection;
                    be.World      = bones[mesh.ParentBone.Index] * world;
                    //be.Alpha = 0;
                }

                mesh.Draw();
            }

            S.gd.BlendState = BlendState.Opaque;
        }
Exemple #3
0
        public void Draw(BaseClip owner)
        {
            #region Calculate World Matrix
            world = Matrix.CreateScale(owner.Scale)
                    * Matrix.CreateRotationX(owner.RotationX)
                    * Matrix.CreateRotationY(owner.RotationY)
                    * Matrix.CreateRotationZ(owner.RotationZ)
                    * Matrix.CreateTranslation(owner.Position);
            #endregion

            S.be.LightingEnabled = true;

            S.gd.SetVertexBuffer(cylinder.vBuffer);
            S.gd.Indices = cylinder.iBuffer;

            for (int i = 0; i < bvh.Skeleton.BoneCount; i++)
            {
                S.be.World = bvh.Skeleton.CylinderScaleOffset[i] *
                             absBoneMX[i] * world;
                S.be.CurrentTechnique.Passes[0].Apply();

                /*S.gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList,
                 *   cylinder.vertices, 0, cylinder.vertices.Length,
                 *   cylinder.indices, 0, cylinder.indices.Length / 3,
                 *   VertexPositionColorNormal.VertexDeclaration);*/
                S.gd.DrawIndexedPrimitives(PrimitiveType.TriangleList,
                                           0, 0, cylinder.vCount, 0, cylinder.iCount / 3);
            }

            S.gd.SetVertexBuffer(null);
            S.gd.Indices = null;


            S.be.World = world;
            S.be.CurrentTechnique.Passes[0].Apply();

            /* S.gd.DrawUserPrimitives(PrimitiveType.LineList,
             *             linesClone, b * 2, 1, VPC.VertexDeclaration);*/

            //S.gd.DrawUserPrimitives(PrimitiveType.LineList,
            //     linesClone, 0, linesClone.Length / 2, .VertexDeclaration);

            S.be.LightingEnabled = true;
        }