@MrValentine wrote:
Hello
![]()
So just playing about to get a 3D camera going and I hit a snag, I want to enable err... disable back face culling, but err I don't think my thing is using two faces anyway... the tutorial I am following is using Vertices so err, new concepts for me... a bit...
Since renderstate is switched to Rasterizer... [XNA used Renderstate, looked up the Docs here to find the changes]
protected override void Initialize() { RasterizerState rs = new RasterizerState(); rs.CullMode = CullMode.None; base.Initialize(); }
Which, does not work, but again this is just me having a quick go and just trying to see two faces on that thing if it is easy... but vertices is not a strong point for me here, I am more used to creating a model and texturing it...
Anyway, if there is a way to draw two faces on this thing with a simple fix, please do let me know
My Struct:
// Vertex data VertexPositionTexture[] verts;
My verts: [LoadContent()]
// Initialize vertices verts = new VertexPositionTexture[4]; verts[0] = new VertexPositionTexture( new Vector3(-1, 1, 0), new Vector2(0, 0)); verts[1] = new VertexPositionTexture( new Vector3(1, 1, 0), new Vector2(1, 0)); verts[2] = new VertexPositionTexture( new Vector3(-1, -1, 0), new Vector2(0, 1)); verts[3] = new VertexPositionTexture( new Vector3(1, -1, 0), new Vector2(1, 1)); // Set vertex data in VertexBuffer vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionTexture), verts.Length, BufferUsage.None); vertexBuffer.SetData(verts); // Initialize the BasicEffect effect = new BasicEffect(GraphicsDevice); // Load texture texture = Content.Load<Texture2D>("Trees");
And my Draw():
// Set the vertex buffer on the GraphicsDevice GraphicsDevice.SetVertexBuffer(vertexBuffer); //Set object and camera info effect.World = worldRotation * worldTranslation * worldRotation; effect.View = camera.view; effect.Projection = camera.projection; effect.Texture = texture; effect.TextureEnabled = true; // Begin effect and draw for each pass foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawUserPrimitives<VertexPositionTexture> (PrimitiveType.TriangleStrip, verts, 0, 2); }
I should probably add, this is using the GameComponent class... something I am still new to.
I was thinking to just duplicate the verts data and create a mirrored version offset from where the existing one is... but pretty sure I will mess it up, so just seeing if there is a snappy method someone may know.
Thanks.
Before posting this I tried creating another struct called vertsa and essentially:
vertsa = new VertexPositionTexture[4]; vertsa[0] = new VertexPositionTexture( new Vector3(-2, 2, 1), new Vector2(0, 0)); vertsa[1] = new VertexPositionTexture( new Vector3(2, 2, 1), new Vector2(2, 0)); vertsa[2] = new VertexPositionTexture( new Vector3(-2, -2, 1), new Vector2(0, 1)); vertsa[3] = new VertexPositionTexture( new Vector3(2, -2, 1), new Vector2(1, 1));
But, I am still lost as to how to turn this thing around... note that I intentionally made it twice the size... I just want to rotate it by 180 on the y axis...
I suspect the effect bit to be involved in rotating it but, unsure right now as it is just past 05:00 now
Anyone know how I rotate it?
EDIT
A temporary measure, but yet again I suffer the facing issue...
vertsa = new VertexPositionTexture[4]; vertsa[0] = new VertexPositionTexture( new Vector3(-1, 1, 1), new Vector2(1, 1)); vertsa[1] = new VertexPositionTexture( new Vector3(1, 1, 1), new Vector2(0, 1)); vertsa[2] = new VertexPositionTexture( new Vector3(-1, 1, -1), new Vector2(1, 0)); vertsa[3] = new VertexPositionTexture( new Vector3(1, 1, -1), new Vector2(0, 0));
Which results in:
Posts: 4
Participants: 2