本文整理汇总了C#中SharpGL.OpenGL.Rotate方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.Rotate方法的具体用法?C# OpenGL.Rotate怎么用?C# OpenGL.Rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.Rotate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: openGLControl_OpenGLDraw
/// <summary>
/// Handles the OpenGLDraw event of the openGLControl control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RenderEventArgs"/> instance containing the event data.</param>
public void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
{
// Get the OpenGL object.
gl = openGLControl.OpenGL;
// Clear the color and depth buffer.
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
// Load the identity matrix.
gl.LoadIdentity();
// Rotate around the Y axis.
//gl.Rotate(rotation, 0.0f, 1.0f, 0.0f);
cord = ComInput.Coordinates.Instance;
this.ModelRotater(gl);
gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);
// Draw a coloured parallelepiped.
gl.Begin(OpenGL.GL_QUADS);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-2.0f, -0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(2.0f, -0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(2.0f, 0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-2.0f, 0.25f, -1.0f);
//-------------------------------------
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(-2.0f, -0.25f, -1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(-2.0f, -0.25f, 1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(-2.0f, 0.25f, 1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(-2.0f, 0.25f, -1.0f);
//-------------------------------------
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-2.0f, -0.25f, 1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(2.0f, -0.25f, 1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(2.0f, 0.25f, 1.0f);
gl.Color(0.0f, 1.0f, 0.0f);
gl.Vertex(-2.0f, 0.25f, 1.0f);
//-------------------------------------
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(2.0f, -0.25f, 1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(2.0f, -0.25f, -1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(2.0f, 0.25f, -1.0f);
gl.Color(1.0f, 0.0f, 0.0f);
gl.Vertex(2.0f, 0.25f, 1.0f);
//-------------------------------------
gl.Color(0.0f, 1.0f, 1.0f);
gl.Vertex(-2.0f, 0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 1.0f);
gl.Vertex(2.0f, 0.25f, -1.0f);
gl.Color(0.0f, 1.0f, 1.0f);
gl.Vertex(2.0f, 0.25f, 1.0f);
gl.Color(0.0f, 1.0f, 1.0f);
gl.Vertex(-2.0f, 0.25f, 1.0f);
//--------------------------------------
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(-2.0f, -0.25f, -1.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(2.0f, -0.25f, -1.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(2.0f, -0.25f, 1.0f);
gl.Color(0.0f, 0.0f, 1.0f);
gl.Vertex(-2.0f, -0.25f, 1.0f);
gl.End();
//.........这里部分代码省略.........
示例2: 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
}
示例3: 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);
}
示例4: 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);
}
}
示例5: 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());
}
}
示例6: ModelRotater
// private float angleX = 0.0f, angleY = 0.0f, angleZ = 0.0f, x = 1;
// private int counter = 0;
private void ModelRotater(OpenGL testObject)
{
testObject.Rotate(cord.getX(), 1.0f, 0.0f, 0.0f); //cord.getX()
testObject.Rotate(cord.getZ(), 0.0f, 1.0f, 0.0f); //cord.getZ()
testObject.Rotate(cord.getY(), 0.0f, 0.0f, 1.0f); //cord.getY()
int h, w;
h = openGLControl.Size.Height / 4;
w = (openGLControl.Size.Width * 4) / 5;
string text = "x: " + cord.getX().ToString(); // +", " + ComInput.osY.ToString() + ", " + ComInput.osZ.ToString();
testObject.DrawText(w, h, 1, 1, 1, "faceName", 20, text);
h = openGLControl.Size.Height / 5;
text = "y: " + cord.getY().ToString();
testObject.DrawText(w, h, 1, 1, 1, "faceName", 20, text);
h = (openGLControl.Size.Height * 3) / 20;
text = "z: " + cord.getZ().ToString();
testObject.DrawText(w, h, 1, 1, 1, "faceName", 20, text);
h = openGLControl.Size.Height / 10;
text = "Work time: " + ComInput.fl.ToString();
testObject.DrawText(w, h, 1, 1, 1, "faceName", 20, text);
}