예제 #1
0
        public void Load()
        {
            _camera = new Camera();
              _camera.PositionSpeed = 5;
              _camera.Move(_camera.Up, 400);
              _camera.Move(_camera.Backward, 1500);
              _camera.Move(_camera.Backward, 300);

              _terrain = StaticModelManager.GetModel("Terrain");
              _terrain.Scale = new Vector(500, 20, 500);
              //_terrain.RotationAmmounts = new Vector(0, 0, 0);
              _terrain.Position = new Vector(0, 0, 0);

              _sprites = new Sprite(TextureManager.Get("Menu"));
              _sprites.Scale.X = 50;
              _sprites.Scale.Y = 50;
              _sprites2 = new Sprite(TextureManager.Get("Menu"));
              _sprites2.Scale.X = 50;
              _sprites2.Scale.Y = 50;
              _sprites3 = new Sprite(TextureManager.Get("Menu"));
              _sprites3.Scale.X = 50;
              _sprites3.Scale.Y = 50;

              _isReady = true;
        }
예제 #2
0
 public CharacterSprite(Sprite sprite, CharacterData data)
 {
     Data = data;
       Sprite = sprite;
 }
예제 #3
0
        public static void DrawSprite(Sprite sprite)
        {
            SetOrthographicMatrix();

              GL.MatrixMode(MatrixMode.Modelview);
              GL.LoadIdentity();

              //Matrix4 cameraTransform = _currentCamera.GetMatrix();
              //GL.LoadMatrix(ref cameraTransform);

              //GL.Translate(-_currentCamera.Position.X, -_currentCamera.Position.Y, -_currentCamera.Position.Z);

              GL.Translate(sprite.Position.X, sprite.Position.Y, sprite.Position.Z);
              //GL.Rotate(1, -_currentCamera.Forward.X, -_currentCamera.Forward.Y, -_currentCamera.Forward.Z);
              //GL.Rotate(-1, 0, _currentCamera.Forward.Y, 0);
              GL.Rotate(sprite.Rotation, 0, 0, 1);
              GL.Scale(sprite.Scale.X, sprite.Scale.Y, 1);

              // Set up verteces
              GL.BindBuffer(BufferTarget.ArrayBuffer, sprite.GpuVertexBufferHandle);
              GL.VertexPointer(3, VertexPointerType.Float, 0, IntPtr.Zero);
              // Enable the client state so it will use this array buffer pointer
              GL.EnableClientState(ArrayCap.VertexArray);

              // Select texture and set up texture coordinates
              GL.BindTexture(TextureTarget.Texture2D, sprite.Texture.GpuHandle);
              GL.BindBuffer(BufferTarget.ArrayBuffer, sprite.GPUTextureCoordinateBufferHandle);
              GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, IntPtr.Zero);
              GL.EnableClientState(ArrayCap.TextureCoordArray);

              // Select the vertex buffer as the active buffer (I don't think this is necessary but I haven't tested it yet).
              GL.BindBuffer(BufferTarget.ArrayBuffer, sprite.GpuVertexBufferHandle);
              // There is no index buffer, so we shoudl use "DrawArrays()" instead of "DrawIndeces()".
              GL.DrawArrays(BeginMode.Triangles, 0, sprite.VertexCount);
        }