Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualmcmonkey

Posted 08 January 2013 - 11:17 PM


I want to render semi-dynamic 3D models... the built in Model class won't work.
So I thought I'd use a simple array of Vertices and render triangles from that...

I've looked all around the internet, and cannot figure out how to do it.

Here's what I'm currently trying:

        public static VertexPositionNormalTexture[] MapMesh = new VertexPositionNormalTexture[1];
        public static void GenMesh()
        {
            MapMesh = new VertexPositionNormalTexture[3];
            MapMesh[0].Position = new Vector3(-0.5f, -0.5f, 0f);
            MapMesh[1].Position = new Vector3(0, 0.5f, 0.1f);
            MapMesh[2].Position = new Vector3(0.5f, -0.5f, 0f);
        }
        public static void DrawMesh(GraphicsDevice device)
        {
            device.DrawUserPrimitives(PrimitiveType.TriangleList, MapMesh, 0, MapMesh.Length/3);
            Models.drawmodel(Models.cube, new Vector3(-1, -1, -5), Vector3.Zero, Textures.textures[Console.constext], Vector3.One);
        }

GenMesh is called once, DrawMesh is called in the Draw loop somewhere shortly after the code

// effect is a BasicEffect.
                effect.View = (camera.ViewMatrix);
                effect.Projection = (camera.ProjectionMatrix);
                effect.World = (Matrix.Identity);
                effect.TextureEnabled = true;
                effect.Texture = Textures.White;
                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                }

the drawmodel(Models.cube bit is just so I can make sure I've pointed the camera at the right spot.

All I see is the cube, no triangle.

- Also, I have CullMode set to None.


What am I missing here?

 


#2mcmonkey

Posted 07 January 2013 - 09:48 PM


I want to render semi-dynamic 3D models... the built in Model class won't work.
So I thought I'd use a simple array of Vertices and render triangles from that...

I've looked all around the internet, and cannot figure out how to do it.

Here's what I'm currently trying:

        public static VertexPositionNormalTexture[] MapMesh = new VertexPositionNormalTexture[1];
        public static void GenMesh()
        {
            MapMesh = new VertexPositionNormalTexture[3];
            MapMesh[0].Position = new Vector3(-0.5f, -0.5f, 0f);
            MapMesh[1].Position = new Vector3(0, 0.5f, 0.1f);
            MapMesh[2].Position = new Vector3(0.5f, -0.5f, 0f);
        }
        public static void DrawMesh(GraphicsDevice device)
        {
            device.DrawUserPrimitives(PrimitiveType.TriangleList, MapMesh, 0, MapMesh.Length/3);
            Models.drawmodel(Models.cube, new Vector3(-1, -1, -5), Vector3.Zero, Textures.textures[Console.constext], Vector3.One);
        }

GenMesh is called once, DrawMesh is called in the Draw loop somewhere shortly after the code

// effect is a BasicEffect.
                effect.View = (camera.ViewMatrix);
                effect.Projection = (camera.ProjectionMatrix);
                effect.World = (Matrix.Identity);
                effect.TextureEnabled = true;
                effect.Texture = Textures.White;
                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                }

the drawmodel(Models.cube bit is just so I can make sure I've pointed the camera at the right spot.

All I see is the cube, no triangle.

- Also, I have CullMode set to None.


What am I missing here?

 


#1mcmonkey

Posted 04 January 2013 - 07:56 PM


I want to render semi-dynamic 3D models... the built in Model class won't work.
So I thought I'd use a simple array of Vertices and render triangles from that...

I've looked all around the internet, and cannot figure out how to do it.

Here's what I'm currently trying:

        public static VertexPositionNormalTexture[] MapMesh = new VertexPositionNormalTexture[1];
        public static void GenMesh()
        {
            MapMesh = new VertexPositionNormalTexture[3];
            MapMesh[0].Position = new Vector3(-0.5f, -0.5f, 0f);
            MapMesh[1].Position = new Vector3(0, 0.5f, 0.1f);
            MapMesh[2].Position = new Vector3(0.5f, -0.5f, 0f);
        }
        public static void DrawMesh(GraphicsDevice device)
        {
            device.DrawUserPrimitives(PrimitiveType.TriangleList, MapMesh, 0, MapMesh.Length/3);
            Models.drawmodel(Models.cube, new Vector3(-1, -1, -5), Vector3.Zero, Textures.textures[Console.constext], Vector3.One);
        }

GenMesh is called once, DrawMesh is called in the Draw loop somewhere shortly after the code

// effect is a BasicEffect.
                effect.View = (camera.ViewMatrix);
                effect.Projection = (camera.ProjectionMatrix);
                effect.World = (Matrix.Identity);
                effect.TextureEnabled = true;
                effect.Texture = Textures.White;
                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                }

the drawmodel(Models.cube bit is just so I can make sure I've pointed the camera at the right spot.

All I see is the cube, no triangle.

- Also, I have CullMode set to None.


What am I missing here?

 


PARTNERS