public static Comparison CompareTo(StaticMesh left, StaticMesh right) { int comparison = left.Id.CompareTo(right.Id); if (comparison > 0) return Comparison.Greater; else if (comparison < 0) return Comparison.Less; else return Comparison.Equal; }
public static Comparison CompareTo(StaticMesh 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 a static model from the ids provided.</summary> /// <param name="staticModelId">The id to represent this model as.</param> /// <param name="textures">An array of the texture ids for each sub-mesh of this model.</param> /// <param name="meshes">An array of each mesh id for this model.</param> /// <param name="meshNames">An array of mesh names for this specific instanc3e of a static model.</param> internal StaticModel(string staticModelId, string[] meshNames, string[] meshes, string[] textures) { if (textures.Length != meshes.Length && textures.Length != meshNames.Length) { throw new System.Exception("Attempting to create a static model with non-matching number of components."); } _id = staticModelId; _meshes = new AvlTree_Linked <StaticMesh>(StaticMesh.CompareTo); for (int i = 0; i < textures.Length; i++) { StaticMesh mesh = StaticModelManager.GetMesh(meshes[i]); mesh.Texture = TextureManager.Get(textures[i]); _meshes.Add(mesh); } _shaderOverride = null; _position = new Vector <float>(0, 0, 0); _scale = new Vector <float>(1, 1, 1); _orientation = Quaternion <float> .FactoryIdentity; }
public static int CompareTo(StaticMesh left, string right) { return left.Id.CompareTo(right); }
public static int CompareTo(StaticMesh left, StaticMesh right) { return left.Id.CompareTo(right.Id); }
private static void DrawStaticModelPart(StaticMesh staticMesh) { // Make sure something will render if (staticMesh.VertexBufferHandle == 0 || (staticMesh.ColorBufferHandle == 0 && staticMesh.TextureCoordinateBufferHandle == 0)) return; // Push current Array Buffer state so we can restore it later GL.PushClientAttrib(ClientAttribMask.ClientVertexArrayBit); if (GL.IsEnabled(EnableCap.Lighting)) { // Normal Array Buffer if (staticMesh.NormalBufferHandle != 0) { // Set up normals GL.BindBuffer(BufferTarget.ArrayBuffer, staticMesh.NormalBufferHandle); GL.NormalPointer(NormalPointerType.Float, 0, IntPtr.Zero); GL.EnableClientState(ArrayCap.NormalArray); } } else { // Color Array Buffer if (staticMesh.ColorBufferHandle != 0) { // Set up colors GL.BindBuffer(BufferTarget.ArrayBuffer, staticMesh.ColorBufferHandle); GL.ColorPointer(3, ColorPointerType.Float, 0, IntPtr.Zero); GL.EnableClientState(ArrayCap.ColorArray); } } // Texture Array Buffer if (GL.IsEnabled(EnableCap.Texture2D) && staticMesh.TextureCoordinateBufferHandle != 0) { // Select the texture and set up texture coordinates GL.BindTexture(TextureTarget.Texture2D, staticMesh.Texture.GpuHandle); GL.BindBuffer(BufferTarget.ArrayBuffer, staticMesh.TextureCoordinateBufferHandle); GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, IntPtr.Zero); GL.EnableClientState(ArrayCap.TextureCoordArray); } else // Nothing will render if this branching is reached. return; // Set up verteces GL.BindBuffer(BufferTarget.ArrayBuffer, staticMesh.VertexBufferHandle); GL.VertexPointer(3, VertexPointerType.Float, 0, IntPtr.Zero); GL.EnableClientState(ArrayCap.VertexArray); if (staticMesh.ElementBufferHandle != 0) { // Set up indeces GL.BindBuffer(BufferTarget.ElementArrayBuffer, staticMesh.ElementBufferHandle); GL.IndexPointer(IndexPointerType.Int, 0, IntPtr.Zero); GL.EnableClientState(ArrayCap.IndexArray); // Ready to render using an index buffer int elements = 0; //GL.DrawElements(PrimitiveType.Triangles, staticMesh.VertexCount, DrawElementsType.UnsignedInt, ref elements); GL.DrawElements(BeginMode.Triangles, staticMesh.VertexCount, DrawElementsType.UnsignedInt, ref elements); } else // Ready to render //GL.DrawArrays(PrimitiveType.Triangles, 0, staticMesh.VertexCount); GL.DrawArrays(BeginMode.Triangles, 0, staticMesh.VertexCount); GL.PopClientAttrib(); }
private static void CopyMeshes(StaticMesh mesh, ListLinked<StaticMesh, string> meshes) { mesh.Texture.ExistingReferences++; mesh.StaticMeshInstance.ExistingReferences++; meshes.Add(new StaticMesh(mesh.Id, mesh.Texture, mesh.StaticMeshInstance)); }