/// <summary>Creates an instance of a sprite.</summary> /// <param name="texture">The texture to have this sprite mapped to.</param> public Sprite(Texture texture) { if (_gpuVertexBufferHandle == 0) GenerateVertexBuffer(); _position = new Vector(0, 0, -10); _scale = new Point(1, 1); _rotation = 0f; _texture = texture; GenerateTextureCoordinateBuffer(); }
public static Comparison CompareTo(Texture left, string right) { int comparison = left.Id.CompareTo(right); if (comparison > 0) return Comparison.Greater; else if (comparison < 0) return Comparison.Less; else return Comparison.Equal; }
/// <summary>Creates an instance of a sprite.</summary> /// <param name="texture">The texture to have this sprite mapped to.</param> /// <param name="textureMappings">The texture mappings for this sprite.</param> public Sprite(Texture texture, float[] textureMappings) { if (_gpuVertexBufferHandle == 0) GenerateVertexBuffer(_verteces); _position = new Vector(0, 0, -10); _scale = new Point(1, 1); _rotation = 0f; _texture = texture; if (textureMappings.Length != 12) throw new Exception("Invalid number of texture coordinates in sprite constructor."); GenerateTextureCoordinateBuffer(textureMappings); }
/// <summary>Creates an instance of a sprite.</summary> /// <param name="texture">The texture to have this sprite mapped to.</param> public Sprite(Texture texture) { if (_gpuVertexBufferHandle == 0) GenerateVertexBuffer(_verteces); _position = new Vector(0, 0, -10); _scale = new Point(1, 1); _rotation = 0f; _texture = texture; if (_gpuTextureMappingBufferHandleDefault == 0) { GenerateTextureCoordinateBuffer(_textureMappingsDefault); _gpuTextureMappingBufferHandleDefault = _gpuTextureMappingBufferHandle; } else _gpuTextureMappingBufferHandle = _gpuTextureMappingBufferHandleDefault; }
/// <summary>Creates an instance of a sprite.</summary> /// <param name="texture">The texture to have this sprite mapped to.</param> /// <param name="textureMappings">The texture mappings for this sprite.</param> public CharacterSprite(Texture texture, int id, int xAdvance, int x, int y, int width, int height, int xOffset, int yOffset) { _texture = texture; _id = id; _xAdvance = xAdvance; _xOffset = xOffset; _yOffset = yOffset; _originalWidth = width; _originalHeight = height; _kearnings = new List_Array<Link<int, int>>(1); if (_gpuVertexBufferHandle == 0) GenerateVertexBuffer(_verteces); GenerateTextureCoordinateBuffer( new float[] { (x + width) / (float)_texture.Width, y / (float)_texture.Height, x / (float)_texture.Width, y / (float)_texture.Height, (x + width) / (float)_texture.Width, (y + height) / (float)_texture.Height, x / (float)_texture.Width, (y + height) / (float)_texture.Height, (x + width) / (float)_texture.Width, (y + height) / (float)_texture.Height, x / (float)_texture.Width, y / (float)_texture.Height }); }
/// <summary>Creates an instance of a StaticMesh.</summary> /// <param name="filePath">The file path of the model that the data came from.</param> /// <param name="id">The name associated with this mash when in was created.</param> /// <param name="vertexBufferHandle">The number reference of the vertex buffer on the GPU (default is 0).</param> /// <param name="colorBufferHandle">The number reference of the color buffer on the GPU (default is 0).</param> /// <param name="textureCoordinatesHandle">The number reference of the texture coordinate buffer on the GPU (default is 0).</param> /// <param name="normalBufferHandle">The number reference of the normal buffer on the GPU (default is 0).</param> /// <param name="elementBufferHandle">The number reference of the element buffer on the GPU (default is 0).</param> /// <param name="vertexCount">The number of verteces making up the mesh.</param> internal StaticMesh( string filePath, string id, int vertexBufferHandle, int colorBufferHandle, int textureCoordinatesHandle, int normalBufferHandle, int elementBufferHandle, int vertexCount, Texture originalTexture) { _existingReferences = 0; _filePath = filePath; _id = id; _vertexBufferHandle = vertexBufferHandle; _colorBufferHandle = colorBufferHandle; _textureCoordinateBufferHandle = textureCoordinatesHandle; _normalBufferHandle = normalBufferHandle; _elementBufferHandle = elementBufferHandle; _vertexCount = vertexCount; _texture = originalTexture; }
internal StaticMesh(string id, Texture texture, StaticMeshInstance staticMesh) { _id = id; _texture = texture; _staticMesh = staticMesh; }
/// <summary>Draws triangles from provided float arrays.</summary> /// <param name="verteces">The list of vertex positions (x, y, z) to draw.</param> /// <param name="colors">The list of vertex colors (r, g, b, a) to draw.</param> /// <param name="textureCoordinates">The list of vertex texture mappings (u, v) to draw.</param> /// <param name="texture">The parameter this drawing will be mapped to.</param> public static void DrawTriangles(float[] verteces, float[] colors, float[] textureCoordinates, Texture texture) { GL.EnableClientState(ArrayCap.ColorArray); GL.EnableClientState(ArrayCap.VertexArray); GL.EnableClientState(ArrayCap.TextureCoordArray); GL.VertexPointer(3, VertexPointerType.Float, 0, verteces); GL.ColorPointer(4, ColorPointerType.Float, 0, colors); GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, textureCoordinates); GL.BindTexture(TextureTarget.Texture2D, texture.GpuHandle); GL.DrawArrays(BeginMode.Triangles, 0, verteces.Length / 3); }
public static int CompareTo(Texture left, string right) { return left.Id.CompareTo(right); }
public static int CompareTo(Texture left, Texture right) { return left.Id.CompareTo(right.Id); }