public override void render(ref Frustum frustum) { Frustum.InFrustumCheck primitiveInFrustum = frustum.CubeInFrustum(pos, 1.0f); if (primitiveInFrustum == Frustum.InFrustumCheck.IN) { GL.PushMatrix(); GL.Translate(this.pos.X, this.pos.Y, this.pos.Z); //GL.EnableClientState(ArrayCap.ColorArray); GL.EnableClientState(ArrayCap.VertexArray); GL.BindBuffer(BufferTarget.ArrayBuffer, vbo.vboID); GL.BindBuffer(BufferTarget.ElementArrayBuffer, vbo.eboID); GL.VertexPointer(3, VertexPointerType.Float, vbo.sizeOfVertices, new IntPtr(0)); //GL.ColorPointer(4, ColorPointerType.UnsignedByte, vbo.sizeOfVertices, new IntPtr(12)); //Debug.Trace(color.ToString()); //GL.Color4(this.color.R, this.color.G, this.color.B, this.color.A); GL.Color3(this.color.R, this.color.G, this.color.B); //GL.Color3(255, 255, 255); GL.DrawElements(BeginMode.Triangles, vbo.numElements, DrawElementsType.UnsignedShort, IntPtr.Zero); GL.DisableClientState(ArrayCap.VertexArray); //GL.DisableClientState(ArrayCap.ColorArray); GL.Color4(1.0, 1.0, 1.0, 1.0); GL.PopMatrix(); Game.Instance.polyCount += 6; } }
public override void render(ref Frustum frustum) { Frustum.InFrustumCheck primitiveInFrustum = frustum.CubeInFrustum(pos, 1.0f); if (primitiveInFrustum == Frustum.InFrustumCheck.IN) { GL.Disable(EnableCap.Lighting); GL.PushMatrix(); GL.Translate(this.pos.X, this.pos.Y, this.pos.Z); GL.Color4(this.color.R, this.color.G, this.color.B, this.color.A); GL.Begin(BeginMode.Quads); GL.Vertex3(1, 1, -1); // Top Right Of The Quad (Top) GL.Vertex3(-1, 1, -1); // Top Left Of The Quad (Top) GL.Vertex3(-1, 1, 1); // Bottom Left Of The Quad (Top) GL.Vertex3(1, 1, 1); // Bottom Right Of The Quad (Top) GL.Vertex3(1, -1, 1); // Top Right Of The Quad (Bottom) GL.Vertex3(-1, -1, 1); // Top Left Of The Quad (Bottom) GL.Vertex3(-1, -1, -1); // Bottom Left Of The Quad (Bottom) GL.Vertex3(1, -1, -1); // Bottom Right Of The Quad (Bottom) GL.Vertex3(1, 1, 1); // Top Right Of The Quad (Front) GL.Vertex3(-1, 1, 1); // Top Left Of The Quad (Front) GL.Vertex3(-1, -1, 1); // Bottom Left Of The Quad (Front) GL.Vertex3(1, -1, 1); // Bottom Right Of The Quad (Front) GL.Vertex3(1, -1, -1); // Top Right Of The Quad (Back) GL.Vertex3(-1, -1, -1); // Top Left Of The Quad (Back) GL.Vertex3(-1, 1, -1); // Bottom Left Of The Quad (Back) GL.Vertex3(1, 1, -1); // Bottom Right Of The Quad (Back) GL.Vertex3(-1, 1, 1); // Top Right Of The Quad (Left) GL.Vertex3(-1, 1, -1); // Top Left Of The Quad (Left) GL.Vertex3(-1, -1, -1); // Bottom Left Of The Quad (Left) GL.Vertex3(-1, -1, 1); // Bottom Right Of The Quad (Left) GL.Vertex3(1, 1, -1); // Top Right Of The Quad (Right) GL.Vertex3(1, 1, 1); // Top Left Of The Quad (Right) GL.Vertex3(1, -1, 1); // Bottom Left Of The Quad (Right) GL.Vertex3(1, -1, -1); // Bottom Right Of The Quad (Right) GL.End(); GL.Color4(1.0, 1.0, 1.0, 1.0); GL.PopMatrix(); GL.Enable(EnableCap.Lighting); Game.Instance.polyCount += 6; } }
public void Render(ref Frustum frustum) { Frustum.InFrustumCheck nodeInFrustum = frustum.CubeInFrustum(mainNode.BoundingBox3D); if (((nodeInFrustum != Frustum.InFrustumCheck.OUT) && (mainNode.HasChilds()))) { bool checkFrustum = true; // if all boundingbox corner where inside the frustum, there is no need to check the childs too if (nodeInFrustum == Frustum.InFrustumCheck.IN) { checkFrustum = false; } Core.pushState(); //GL.Scale(terrainRef.scale); //GL.Translate(terrainRef.position); GL.Disable(EnableCap.Lighting); GL.Color4(1.0, 1.0, 1.0, 0); GL.EnableClientState(ArrayCap.VertexArray); GL.EnableClientState(ArrayCap.TextureCoordArray); if (terrainRef.TextureID != -1) { Texture.Bind(terrainRef.TextureID); GL.Enable(EnableCap.Texture2D); } CheckNodeInsideFrustum(ref frustum, ref mainNode, checkFrustum); if (terrainRef.TextureID != -1) { GL.Disable(EnableCap.Texture2D); } GL.DisableClientState(ArrayCap.TextureCoordArray); GL.DisableClientState(ArrayCap.VertexArray); Core.popState(); } return; }