本文整理汇总了C#中SharpGL.OpenGL.Translate方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.Translate方法的具体用法?C# OpenGL.Translate怎么用?C# OpenGL.Translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.Translate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: openGLControl_OpenGLDraw
//.........这里部分代码省略.........
gl.Rotate(cord.getY(), 0.0f, 0.0f, 1.0f);
gl.Begin(OpenGL.GL_TRIANGLES);
gl.Vertex(2.75f, 0.0f, 0.0f);
gl.Vertex(3.25f, 0.0f, 0.25f);
gl.Vertex(3.25f, 0.0f, -0.25f);
gl.End();
//------------------Circles of planes is here-----------------------------------------------
gl.LoadIdentity();
gl.Begin(OpenGL.GL_LINE_LOOP);
for(int i = 0; i < 200; i++)
{
float theta = 2.0f * 3.1415926f * (float)i / 200f;//get the current angle
float x = 3f * (float)System.Math.Cos(theta);//calculate the x component
float y = 3f * (float)System.Math.Sin(theta);//calculate the y component
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(0f, y + 0.0f, x + 0.0f);//output vertex
}
gl.End();
gl.Begin(OpenGL.GL_LINE_LOOP);
for (int i = 0; i < 200; i++)
{
float theta = 2.0f * 3.1415926f * (float)i / 200f;//get the current angle
float x = 3f * (float)System.Math.Cos(theta);//calculate the x component
float y = 3f * (float)System.Math.Sin(theta);//calculate the y component
gl.Vertex(x + 0.0f, 0.0f, y + 0.0f);//output vertex
}
gl.End();
gl.Begin(OpenGL.GL_LINE_LOOP);
for (int i = 0; i < 200; i++)
{
float theta = 2.0f * 3.1415926f * (float)i / 200f;//get the current angle
float x = 3f * (float)System.Math.Cos(theta);//calculate the x component
float y = 3f * (float)System.Math.Sin(theta);//calculate the y component
gl.Vertex(x + 0.0f, y + 0.0f, 0.0f);//output vertex
}
gl.End();
/* //--------------Coordinate axis's is here--------------------------------------------
gl.LoadIdentity();
gl.Begin(OpenGL.GL_LINE_STRIP);
gl.Color(1.0f, 1.0f, 1.0f);
gl.Vertex(-4.0f, 0.5f, 1.5f);
gl.Vertex(2.5f, 0.5f, 1.5f);
gl.Vertex(2.5f, 0.5f, -4.5f);
gl.Vertex(2.5f, 0.5f, 1.5f);
gl.Vertex(2.5f, 4.0f, 1.5f);
gl.End();
*/ //------------Shpere is here-----------------------------
gl.LoadIdentity();
gl.Color(0.85f, 0.85f, 0.85f, 0.5f);
gl.Begin(OpenGL.GL_QUADS);
for (int i = 0; i < 1; i++)
{
this.draw_sphere(gl, 3);
}
gl.End();
//---------------3D Text prototype is here-------------------
gl.LoadIdentity();
gl.Translate(0.0f, 3.5f, -3.0f);
gl.Color(0.0f, 1.0f, 0.65f);
gl.Rotate(270.0f, 0.0f, 1.0f, 0.0f);
gl.DrawText3D("a", 0.2f,
1.0f, 0.1f, "osX: 0");
// Nudge the rotation.
rotation += 2.0f;
}
示例2: PushObjectSpace
public void PushObjectSpace(OpenGL gl)
{
gl.PushMatrix();
gl.Translate(pos.X, pos.Y, pos.Z);
if (material != null)
material.Push(gl);
}
示例3: Draw
public void Draw(OpenGL renderer)
{
renderer.MatrixMode(SharpGL.Enumerations.MatrixMode.Modelview);
renderer.LookAt(_eye.X * Radius, _eye.Y * Radius, _eye.Z * Radius, _center.X * Radius, _center.Y * Radius, _center.Z * Radius, _up.X, _up.Y, _up.Z);
renderer.Translate(_position.X, _position.Y, _position.Z);
}
示例4: 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
}
示例5: parentTranslation
private void parentTranslation(OpenGL gl, Bone bone)
{
if (!(bone.Parent is Model))
{
if (bone.Parent is Bone)
{
Bone parent = bone.Parent as Bone;
parentTranslation(gl, parent);
gl.Translate(parent.Translation.X,
parent.Translation.Y, parent.Translation.Z);
}
}
}
示例6: Rotate
/// <summary>
/// Apply the rotation transformation to the current object space.
/// </summary>
/// <param name="gl">The OpenGL render context</param>
public void Rotate(OpenGL gl)
{
Vertex negFocal = focalPoint * -1;
gl.Translate(focalPoint.X, focalPoint.Y, focalPoint.Z);
gl.Rotate(RotateX, RotateY, RotateZ);
gl.Translate(negFocal.X, negFocal.Y, negFocal.Z);
}
示例7: PushObjectSpace
/// <summary>
/// Push a new object space onto the stack and then apply a translation transformation.
/// </summary>
/// <param name="gl">The OpenGL render context</param>
/// <param name="translation">The translation transformation to apply.</param>
public void PushObjectSpace(OpenGL gl, Vertex translation)
{
gl.PushMatrix();
gl.Translate(translation.X, translation.Y, translation.Z);
Rotate(gl);
}
示例8: openGLControl_OpenGLDraw
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
{
_gl = openGLControl.OpenGL;
_gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
_gl.LoadIdentity();
_gl.LookAt(0, 0, _w, 0, 0, 0, 0, 1, 0); //-10, 10, _w, 0, 0, 0, 0, 1, 0
_gl.Rotate((float)_rotX, (float)_rotY, (float)_rotZ);
_gl.Translate(_transX, _transY, _transZ);
foreach (Polygon polygon in _polygons)
{
if (!polygon.IsEnabled) continue;
polygon.PushObjectSpace(_gl);
polygon.Render(_gl, SharpGL.SceneGraph.Core.RenderMode.Render);
polygon.PopObjectSpace(_gl);
}
}
示例9: DrawOperation
public static void DrawOperation(OpenGL gl, Project testProject, Vector rotation, List<List<double[]>> detailCache)
{
var bill = testProject.Settings;
gl.Translate(bill.Length / 2, bill.Height / 2, bill.Width / 2);//высчитывается из размера заготовки
gl.Rotate((float)rotation.Y, (float)rotation.X, 0); // вращение с зажатой средней кнопкой мыши
gl.Translate(-bill.Length / 2, -bill.Height / 2, -bill.Width / 2);
//var Bill = this.testProject.Settings;
Billet.Draw(gl, bill.Height, bill.Length, bill.Width); // заготовка
var operations = testProject.Operations;//колличество операций
var boltReg = new Regex("BoltHole");
var pocketReg = new Regex("Pocket");
if (detailCache.Count != operations.Count) detailCache.Clear();
for (var i = 0; i < operations.Count; i++)//главный цикл отрисовки
{
var shapeName = operations[i].Shape.Name;
if (boltReg.IsMatch(shapeName))
{
var bolt = (Model.Primitives.BoltHole)operations[i].Shape;
var boltlocation = operations[i].Location.LocationsList.GetEnumerator();
while (boltlocation.MoveNext())
{
if (bolt.Modified || boltlocation.Current.Modified || detailCache.Count<=i)
{
try
{
detailCache.RemoveAt(i);
}
catch{}
var location = new Point(boltlocation.Current.X, boltlocation.Current.Y);
detailCache.Insert(i, BoltHole.ReCalc(bolt, 0.5, location)); //здесь уже всё ок, кроме величины шага
boltlocation.Current.IsDrawn();
bolt.IsDrawn();//значит в кэше лежит актуальная информация
}
else
{
var location = new Point(boltlocation.Current.X, boltlocation.Current.Y);
BoltHole.Draw(gl, detailCache[i]); //здесь уже всё ок, кроме величины шага
}
}
}
if (!pocketReg.IsMatch(shapeName)) continue;
var poc = (Model.Primitives.Pocket)operations[i].Shape;
var poclocation = operations[i].Location.LocationsList.GetEnumerator();
while (poclocation.MoveNext())
{
if (poc.Modified || poclocation.Current.Modified || detailCache.Count <= i)
{
try
{
detailCache.RemoveAt(i);
}
catch { }
var location = new Point(poclocation.Current.X, poclocation.Current.Y);
var p = Pocket.ReCalc(poc, 0.5, location);
detailCache.Insert(i, p); //здесь уже всё ок, кроме величины шага
poclocation.Current.IsDrawn();
poc.IsDrawn();//значит в кэше лежит актуальная информация
}
else
{
var location = new Point(poclocation.Current.X, poclocation.Current.Y);
Pocket.Draw(gl, detailCache[i]); //здесь уже всё ок, кроме величины шага
}
}
}
//отрисовщик траекторий
gl.Begin(OpenGL.GL_LINE_STRIP);
gl.Color(1f, 0, 0);
var trajectorys = GCodeGenerator.TrajectoryStor.GetTrajectorys();
foreach (var point in trajectorys.SelectMany(operation => operation))
{
gl.Vertex(point.GetCoordinates());
}
}
示例10: RenderForHitTest
public override void RenderForHitTest(OpenGL gl, Dictionary<uint, Node> hitMap, ref uint currentName)
{
if (!Visible)
return;
gl.PushMatrix();
gl.Translate(TransformedPosition.X, TransformedPosition.Y,
TransformedPosition.Z);
gl.LoadName(currentName);
hitMap[currentName] = this;
sphere.Render(gl);
currentName++;
sphere.PopObjectSpace(gl);
// Render children
foreach (Bone bone in children)
{
bone.RenderForHitTest(gl, hitMap, ref currentName);
}
}
示例11: Render
public override void Render(OpenGL gl)
{
if (!Visible)
return;
gl.PushMatrix();
if (sphere.Material != null)
sphere.Material.Push(gl);
gl.Translate(TransformedPosition.X, TransformedPosition.Y,
TransformedPosition.Z);
sphere.Render(gl);
sphere.PopObjectSpace(gl);
//Render children and the lines connecting them
foreach (Bone bone in children)
{
DrawLine(gl, TransformedPosition, bone.TransformedPosition, Color, bone.Color);
bone.Render(gl);
}
}
示例12: OpenGLControl_OpenGLDraw
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args)
{
OpenGL gl = new OpenGL();
ballX -= balMovX;
ballY -= balMovY;
if (Convert.ToInt32(ballX) == -gameSizeX)
{
balMovX = -0.08f;
}
else if (Convert.ToInt32(ballX) == gameSizeX)
{
balMovX = 0.08f;
}
if (Convert.ToInt32(ballY) == -gameSizeY)
{
balMovY = -0.03f;
}
else if (Convert.ToInt32(ballY) == gameSizeY)
{
balMovY = 0.03f;
}
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.LoadIdentity();
gl.Translate(gameX, gameY, gameZ);
gameRect(gl);
Ball(gl);
Bed(gl,bed1X, bed1Y, bed1Z, 0.2f, 1.8f);
Bed(gl,bed2X, bed2Y, bed2Z, 0.2f, 1.8f);
gl.Flush();
}
示例13: drawModel
/// <summary>
/// Function to draw the model
/// </summary>
private void drawModel(OpenGL gl)
{
if(l_vboId != null)
{
gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY);
gl.EnableClientState(OpenGL.GL_COLOR_ARRAY);
// itering over each list of points
for(int k = 0; k < l_vboId.Count; k++)
{
gl.PushMatrix();
//transformations
gl.Scale(1.0f / f_scale, 1.0f / f_scale, 1.0f / f_scale);
gl.Translate(-v_center.X, -v_center.Y, -v_center.Z);
//vertexes
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, l_vboId[k][0]);
gl.VertexPointer(3, OpenGL.GL_FLOAT, 0, BUFFER_OFFSET_ZERO);
//color
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, l_vboId[k][1]);
gl.ColorPointer(3, OpenGL.GL_FLOAT, 0, BUFFER_OFFSET_ZERO);
//draw l_sizes[k] points
gl.DrawArrays(OpenGL.GL_POINTS, 0, l_sizes[k]);
gl.PopMatrix();
}
gl.DisableClientState(OpenGL.GL_VERTEX_ARRAY);
gl.DisableClientState(OpenGL.GL_COLOR_ARRAY);
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, 0);
}
}