Game development

From: THERE IS NO GOD BUT (RENDLE)20 Sep 2008 09:12
To: Mikee 5 of 8
I can give you some tips on C# which would apply to game development. I had a brief look at the XNA 1.0 beta ages ago and decided life was too short. And 3D maths does my fucking head in.
From: Mikee20 Sep 2008 18:00
To: ALL6 of 8
Ok, here's a question. Maybe someone can answer for me.

I am drawing a plane which will eventually be used as sky. I don't want it to be a flat plane, though, I want to 'pull' the corners down.

Here's what I'm doing to draw the sky..

C# code:
 
using System;
using System.Collections.Generic;
 
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
 
using QuickStart;
using QuickStart.Graphics;
using QuickStart.Physics;
 
namespace QuickStart.Entities
{
    public class SkyPlane : BaseEntity
    {
 
        public VertexBuffer VertexBuffer
        {
            get { return this.vertexBuffer; }
        }
        private VertexBuffer vertexBuffer;
 
        public IndexBuffer IndexBuffer
        {
            get { return this.indexBuffer; }
        }
        private IndexBuffer indexBuffer;
 
        public VertexDeclaration VertexDeclaration
        {
            get { return this.vertDeclaration; }
        }
        private VertexDeclaration vertDeclaration;
 
        public Effect TerrainEffect
        {
            get { return this.terrainEffect; }
        }
        private Effect terrainEffect;
 
        public Material Material
        {
            get { return this.material; }
        }
        private Material material;
 
        private Vector3 offset;
        private int squaresize = 60;
        private int[] indices;
        private int width = 0;
        private int height = 0;
 
        public SkyPlane(QSGame game)
            : base(game)
        {
            this.terrainEffect = game.Content.Load<Effect>("./Effects/Terrain");
            this.terrainEffect.CurrentTechnique = terrainEffect.Techniques["MultiTextured"];
            this.vertDeclaration = new VertexDeclaration(this.Game.GraphicsDevice, VertexPositionTexture.VertexElements);
        }
        public void Initialize(Vector3 offset, float viewDistance)
        {
            this.width = (int) viewDistance / this.squaresize;
            this.height = (int) viewDistance / this.squaresize;
            this.offset = offset;
            CreateVertexBuffer();
            CreateIndexBuffer();
            this.material = this.Game.Content.Load<Material>("Material/Terrain");
        }
        public void CreateVertexBuffer()
        {
            vertexBuffer = new VertexBuffer(this.Game.GraphicsDevice, typeof(VertexPositionTexture), width * height, BufferUsage.WriteOnly);
 
            VertexPositionTexture[] vertices = new VertexPositionTexture[width * height];
             for (int x = 0; x < width; x++)
             {
                 for (int y = 0; y < height; y++)
                 {
                     vertices[x + y * width].Position = new Vector3((x * this.squaresize), 0, (y * this.squaresize)) + this.offset;
                 }
             }
             vertexBuffer.SetData(vertices);
         }
         public void CreateIndexBuffer()
         {
             int numberOfIndexes = (width - 1) * (height - 1) * 6;
             indexBuffer = new IndexBuffer(this.Game.GraphicsDevice, typeof(int), numberOfIndexes, BufferUsage.WriteOnly);
             int counter = 0;
             indices = new int[numberOfIndexes];
             for (int y = 0; y < height - 1; y++)
             {
                 for (int x = 0; x < width - 1; x++)
                 {
                     int lowerLeft = x + y * width;
                     int lowerRight = (x + 1) + y * width;
                     int topLeft = x + (y + 1) * width;
                     int topRight = (x + 1) + (y + 1) * width;
 
 
                     indices[counter++] = topLeft;
                     indices[counter++] = lowerRight;
                     indices[counter++] = lowerLeft;
 
 
                     indices[counter++] = topLeft;
                     indices[counter++] = topRight;
                     indices[counter++] = lowerRight;
                 }
             }
             indexBuffer.SetData(indices);
         }
        public override void QueryForRenderChunks(ref RenderPassDesc desc)
        {
 
            RenderChunk chunk = this.Game.Graphics.AllocateRenderChunk();
 
            chunk.Indices = indexBuffer;
            chunk.VertexStreams.Add(vertexBuffer);
            chunk.Declaration = vertDeclaration;
            chunk.WorldTransform = Matrix.Identity;
            chunk.VertexCount = width * height;
            chunk.StartIndex = 0;
            chunk.VertexStreamOffset = 0;
            chunk.PrimitiveCount = indices.Length / 3;
            chunk.Material = this.material;
            chunk.Type = PrimitiveType.TriangleList;
 
            base.QueryForRenderChunks(ref desc);
        }
    }
}
 
 


Note that QueryForRenderChunks if what the framework calls repeatedly to get a "chunk" to send to the graphics card.


So, this draws me a grid from the vector 'offset' to 'viewDistance' and the size of each square is viewDistance/sqaresize.

How could I pull the corners of the plane down? :/
EDITED: 20 Sep 2008 18:01 by MIKEE
From: Mikee20 Sep 2008 20:09
To: ALL7 of 8
Huzzah.

From: Mikee26 Sep 2008 12:24
To: ALL8 of 8

I'm gonna have a play with "axiom" (an Ogre port) and Mogre (an Ogre wrapper).

 

Decided I can't be arsed with getting things to work on an xbox anymore, and for PC only development Ogre seems a lot more established than any XNA framework out there.

 

On a side note, I finally understand things a bit better :) I can do vertex and pixel shaders and I can make a skydome with clouds and sunset/rise and stars and whatnot :)

 

Now i've just gotta make the game :?