static void Cubek(float width) { /*задняя*/ GL.Normal3(0, 0, -width); GL.Color3(Color.Red); GL.Begin(PrimitiveType.Polygon); GL.Vertex3(0, 0, 0); GL.Vertex3(width, 0, 0); GL.Vertex3(width, width, 0); GL.Vertex3(0, width, 0); GL.End(); /*левая*/ GL.Normal3(-width, 0, 0); GL.Color3(Color.Orange); GL.Begin(PrimitiveType.Polygon); GL.Vertex3(0, 0, 0); GL.Vertex3(0, 0, width); GL.Vertex3(0, width, width); GL.Vertex3(0, width, 0); GL.End(); /*нижняя*/ GL.Normal3(0, -width, 0); GL.Color3(Color.Coral); GL.Begin(PrimitiveType.Polygon); GL.Vertex3(0, 0, 0); GL.Vertex3(0, 0, width); GL.Vertex3(width, 0, width); GL.Vertex3(width, 0, 0); GL.End(); /*верхняя*/ GL.Normal3(0, width, 0); GL.Color3(Color.RoyalBlue); GL.Begin(PrimitiveType.Polygon); GL.Vertex3(0, width, 0); GL.Vertex3(0, width, width); GL.Vertex3(width, width, width); GL.Vertex3(width, width, 0); GL.End(); /*правая*/ GL.Normal3(width, 0, 0); GL.Color3(Color.Orange); GL.Begin(PrimitiveType.Polygon); GL.Vertex3(width, 0, 0); GL.Vertex3(width, 0, width); GL.Vertex3(width, width, width); GL.Vertex3(width, width, 0); GL.End(); /*передняя*/ GL.Normal3(0, 0, width); GL.Color3(Color.Sienna); GL.Begin(PrimitiveType.Polygon); GL.Vertex3(0, 0, width); GL.Vertex3(width, 0, width); GL.Vertex3(width, width, width); GL.Vertex3(0, width, width); GL.End(); /*ребра*/ /* * GL.Color3(Color.Black); * GL.Begin(BeginMode.LineLoop); * GL.Vertex3(0, 0, 0); * GL.Vertex3(0, width, 0); * GL.Vertex3(width, width, 0); * GL.Vertex3(width, 0, 0); * GL.End(); * * GL.Begin(BeginMode.LineLoop); * GL.Vertex3(width, 0, 0); * GL.Vertex3(width, 0, width); * GL.Vertex3(width, width, width); * GL.Vertex3(width, width, 0); * GL.End(); * * GL.Begin(BeginMode.LineLoop); * GL.Vertex3(0, 0, width); * GL.Vertex3(width, 0, width); * GL.Vertex3(width, width, width); * GL.Vertex3(0, width, width); * GL.End(); * * GL.Begin(BeginMode.LineLoop); * GL.Vertex3(0, 0, 0); * GL.Vertex3(0, 0, width); * GL.Vertex3(0, width, width); * GL.Vertex3(0, width, 0); * GL.End(); */ }
static void DrawCube(float angle, float width, float height, float depth, float positionX, float positionY, float positionZ, float polygons, Color[] colors6, bool outerLight = true) { float l = outerLight ? -1 : 1; float stepX = width / polygons; float stepY = height / polygons; float stepZ = depth / polygons; /*задняя*/ GL.Begin(PrimitiveType.Polygon); GL.Color3(colors6[0]); GL.Normal3(0f, 0f, 1f * l); for (float w = 0; w < width; w += stepX) { for (float h = 0; h < height; h += stepY) { //Vector3 vector = getSurfaceNormal( // new Vector3(positionX + w, positionY + h, positionZ), // new Vector3(positionX + w + stepX, positionY + h, positionZ), // new Vector3(positionX + w + stepX, positionY + h + stepY, positionZ)); //GL.Normal3(vector.X, vector.Y, vector.Z); GL.TexCoord2(w / width, h / height); GL.Vertex3(positionX + w, positionY + h, positionZ); GL.TexCoord2(w / width + 1.0f / polygons, h / height); GL.Vertex3(positionX + w + stepX, positionY + h, positionZ); GL.TexCoord2(w / width + 1.0f / polygons, h / height + 1.0f / polygons); GL.Vertex3(positionX + w + stepX, positionY + h + stepY, positionZ); GL.TexCoord2(w / width, h / height + 1.0f / polygons); GL.Vertex3(positionX + w, positionY + h + stepY, positionZ); } } GL.End(); /*левая*/ GL.Normal3(1f * l, 0f, 0f); GL.Color3(colors6[1]); GL.Begin(PrimitiveType.Polygon); for (float d = 0; d < depth; d += stepZ) { for (float h = 0; h < height; h += stepY) { //Vector3 vector = getSurfaceNormal( // new Vector3(positionX, positionY + h, positionZ + d), // new Vector3(positionX, positionY + h + stepY, positionZ + d), // new Vector3(positionX, positionY + h + stepY, positionZ + d + stepZ)); //GL.Normal3(vector.X, vector.Y, vector.Z); GL.Vertex3(positionX, positionY + h, positionZ + d); GL.Vertex3(positionX, positionY + h + stepY, positionZ + d); GL.Vertex3(positionX, positionY + h + stepY, positionZ + d + stepZ); GL.Vertex3(positionX, positionY + h, positionZ + d + stepZ); } } GL.End(); /*нижняя*/ GL.Normal3(0f, 1f * l, 0f); GL.Color3(colors6[2]); GL.Begin(PrimitiveType.Polygon); for (float d = 0; d < depth; d += stepZ) { for (float w = 0; w < width; w += stepX) { GL.Vertex3(positionX + w, positionY, positionZ + d); GL.Normal3(0f, 1f * l, 0f); GL.Vertex3(positionX + w + stepX, positionY, positionZ + d); GL.Normal3(0f, 1f * l, 0f); GL.Vertex3(positionX + w + stepX, positionY, positionZ + d + stepZ); GL.Normal3(0f, 1f * l, 0f); GL.Vertex3(positionX + w, positionY, positionZ + d + stepZ); } } GL.End(); /*верхняя*/ GL.Normal3(0f, -1f * l, 0f); GL.Color3(colors6[3]); GL.Begin(PrimitiveType.Polygon); for (float d = 0; d < depth; d += stepZ) { for (float w = 0; w < width; w += stepX) { GL.Vertex3(positionX + w, positionY + height, positionZ + d); GL.Vertex3(positionX + w + stepX, positionY + height, positionZ + d); GL.Vertex3(positionX + w + stepX, positionY + height, positionZ + d + stepZ); GL.Vertex3(positionX + w, positionY + height, positionZ + d + stepZ); } } GL.End(); /*передняя*/ GL.Normal3(0f, 0f, -1f * l); GL.Color3(colors6[4]); GL.Begin(PrimitiveType.Polygon); for (float w = 0; w < width; w += stepX) { for (float h = 0; h < height; h += stepY) { GL.TexCoord2(w / width, h / height); GL.Vertex3(positionX + w, positionY + h, positionZ + depth); GL.TexCoord2(w / width + 1.0f / polygons, h / height); GL.Vertex3(positionX + w + stepX, positionY + h, positionZ + depth); GL.TexCoord2(w / width + 1.0f / polygons, h / height + 1.0f / polygons); GL.Vertex3(positionX + w + stepX, positionY + h + stepY, positionZ + depth); GL.TexCoord2(w / width, h / height + 1.0f / polygons); GL.Vertex3(positionX + w, positionY + h + stepY, positionZ + depth); } } GL.End(); /*правая*/ GL.Normal3(-1f * l, 0f, 0f); GL.Begin(PrimitiveType.Polygon); GL.Color3(colors6[5]); for (float d = 0; d < depth; d += stepZ) { for (float h = 0; h < height; h += stepY) { GL.Vertex3(positionX + width, positionY + h, positionZ + d); GL.Vertex3(positionX + width, positionY + h + stepY, positionZ + d); GL.Vertex3(positionX + width, positionY + h + stepY, positionZ + d + stepZ); GL.Vertex3(positionX + width, positionY + h, positionZ + d + stepZ); } } GL.End(); }
private void DrawText(string text) { GL.Begin(PrimitiveType.Quads); float glyphWidth = (float)Settings.GlyphWidth / (float)_textureWidth; float glyphHeight = (float)Settings.GlyphHeight / (float)_textureHeight; float letterWidth = 0.5f; float letterHeight = 1f; float lettersToDraw = text.Length; float widthOfLabel = letterWidth * lettersToDraw; float pos_x = -(widthOfLabel / 2); float pos_y = -(letterHeight / 2); for (int n = 0; n < text.Length; n++) { char idx = text[n]; float tex_x = (float)(idx % Settings.GlyphsPerLine) * glyphWidth; float tex_y = (float)(idx / Settings.GlyphsPerLine) * glyphHeight; // bottom left GL.TexCoord2( tex_x, tex_y + glyphHeight); GL.Vertex2( pos_x, pos_y); // bottom right GL.TexCoord2( tex_x + glyphWidth, tex_y + glyphHeight); GL.Vertex2( pos_x + letterWidth, pos_y); // top right GL.TexCoord2( tex_x + glyphWidth, tex_y); GL.Vertex2( pos_x + letterWidth, pos_y + letterHeight); // top left GL.TexCoord2( tex_x, tex_y); GL.Vertex2( pos_x, pos_y + letterHeight); pos_x += letterWidth; } GL.End(); }