本文整理汇总了C#中OpenGL.Translate方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.Translate方法的具体用法?C# OpenGL.Translate怎么用?C# OpenGL.Translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL
的用法示例。
在下文中一共展示了OpenGL.Translate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SampleRendering
private void SampleRendering(OpenGL gl, float rX, float rY, float rZ)
{
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
gl.LoadIdentity(); // Reset The View
gl.Translate(-1.5f, 0.0f, -6.0f); // Move Left And Into The Screen
gl.Rotate(rtri, rX, rY, rZ); // Rotate The Pyramid On It's Y Axis
gl.Begin(OpenGL.GL_TRIANGLES); // Start Drawing The Pyramid
gl.Color(1.0f, 0.0f, 0.0f); // Red
gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Front)
gl.Color(0.0f, 1.0f, 0.0f); // Green
gl.Vertex(-1.0f, -1.0f, 1.0f); // Left Of Triangle (Front)
gl.Color(0.0f, 0.0f, 1.0f); // Blue
gl.Vertex(1.0f, -1.0f, 1.0f); // Right Of Triangle (Front)
gl.Color(1.0f, 0.0f, 0.0f); // Red
gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Right)
gl.Color(0.0f, 0.0f, 1.0f); // Blue
gl.Vertex(1.0f, -1.0f, 1.0f); // Left Of Triangle (Right)
gl.Color(0.0f, 1.0f, 0.0f); // Green
gl.Vertex(1.0f, -1.0f, -1.0f); // Right Of Triangle (Right)
gl.Color(1.0f, 0.0f, 0.0f); // Red
gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Back)
gl.Color(0.0f, 1.0f, 0.0f); // Green
gl.Vertex(1.0f, -1.0f, -1.0f); // Left Of Triangle (Back)
gl.Color(0.0f, 0.0f, 1.0f); // Blue
gl.Vertex(-1.0f, -1.0f, -1.0f); // Right Of Triangle (Back)
gl.Color(1.0f, 0.0f, 0.0f); // Red
gl.Vertex(0.0f, 1.0f, 0.0f); // Top Of Triangle (Left)
gl.Color(0.0f, 0.0f, 1.0f); // Blue
gl.Vertex(-1.0f, -1.0f, -1.0f); // Left Of Triangle (Left)
gl.Color(0.0f, 1.0f, 0.0f); // Green
gl.Vertex(-1.0f, -1.0f, 1.0f); // Right Of Triangle (Left)
gl.End(); // Done Drawing The Pyramid
gl.LoadIdentity();
gl.Translate(1.5f, 0.0f, -7.0f); // Move Right And Into The Screen
gl.Rotate(rquad, rX, rY, rZ); // Rotate The Cube On X, Y & Z
gl.Begin(OpenGL.GL_QUADS); // Start Drawing The Cube
gl.Color(0.0f, 1.0f, 0.0f); // Set The Color To Green
gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Top)
gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Top)
gl.Vertex(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top)
gl.Vertex(1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top)
gl.Color(1.0f, 0.5f, 0.0f); // Set The Color To Orange
gl.Vertex(1.0f, -1.0f, 1.0f); // Top Right Of The Quad (Bottom)
gl.Vertex(-1.0f, -1.0f, 1.0f); // Top Left Of The Quad (Bottom)
gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Bottom)
gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Bottom)
gl.Color(1.0f, 0.0f, 0.0f); // Set The Color To Red
gl.Vertex(1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front)
gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front)
gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Front)
gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Front)
gl.Color(1.0f, 1.0f, 0.0f); // Set The Color To Yellow
gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Back)
gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Back)
gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Back)
gl.Vertex(1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Back)
gl.Color(0.0f, 0.0f, 1.0f); // Set The Color To Blue
gl.Vertex(-1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left)
gl.Vertex(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Left)
gl.Vertex(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Left)
gl.Vertex(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Left)
gl.Color(1.0f, 0.0f, 1.0f); // Set The Color To Violet
gl.Vertex(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Right)
gl.Vertex(1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right)
gl.Vertex(1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Right)
gl.Vertex(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Right)
gl.End(); // Done Drawing The Q
gl.Flush();
rtri += 1.0f;// 0.2f; // Increase The Rotation Variable For The Triangle
rquad -= 1.0f;// 0.15f; // Decrease The Rotation Variable For The Quad
}
示例2: TransformProjectionMatrix
/// <summary>
/// This is the main function of the camera, perform a Frustrum (in this case)
/// transformation.
/// </summary>
public override void TransformProjectionMatrix(OpenGL gl)
{
// Perform the transformation.
gl.Translate(Position.X, Position.Y, Position.Z);
gl.Frustum(left, right, bottom, top, near, far);
}
示例3: Transform
/// <summary>
/// Transform calls the OpenGL transformation functions using the current
/// values, normally in the order translate, scale, rotate.
/// </summary>
public virtual void Transform(OpenGL gl)
{
if(transformationOrder == TransformationOrder.TranslateRotateScale)
{
gl.Translate(translate.X, translate.Y, translate.Z);
gl.Rotate(rotate.X, rotate.Y, rotate.Z);
}
else
{
gl.Rotate(rotate.X, rotate.Y, rotate.Z);
gl.Translate(translate.X, translate.Y, translate.Z);
}
gl.Scale(scale.X, scale.Y, scale.Z);
}