106
Otros / Re:Programacion Pseint
« en: Abril 29, 2012, 01:48:30 am »
Si lo que quieres es publicar ejemplos de Pseint en un hilo, lo que haces es, al copiarlo lo seleccionas y precionas el boton del (#).
Saludos!
Saludos!
Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.
private void gl_Paint(object sender, PaintEventArgs e)
{
if (!loaded)
return;
if (GList == null)
return;
loaded = false;
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
Glu.Perspective(MathHelper.PiOver2, 1F, 0.1F, 20000F);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
Glu.LookAt(eyeX, eyeY, eyeZ, lookX, lookY, lookZ, 0, 1, 0);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.PushMatrix();
if (lucesON)
{
float[] mat_diffuse = { 1f, 1f, 1f };
GL.Material(MaterialFace.Front, MaterialParameter.Diffuse, mat_diffuse);
//light loading
//1ª recalculamos color para cada punto:
GL.ShadeModel(ShadingModel.Smooth);
//2ª ponemos las luces:
float[] light_position1 = { 500f, 500f, 1500f, 0f };
float[] light_color_white = { 0f, 0f, 0f, 0f };
float[] material_color_white = { 0f, 0f, 0f, 1f };
GL.Enable(EnableCap.Lighting);
GL.Enable(EnableCap.Light0);
GL.Light(LightName.Light0, LightParameter.Position, light_position1);
GL.Light(LightName.Light0, LightParameter.Specular, light_color_white);
//3ª definimos la reflexion:
//reflexion ambiental
GL.Material(MaterialFace.Front, MaterialParameter.Ambient, material_color_white);
//brillo en las figuras
GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Shininess, 128);
//enabling GL-options
}
else
{
GL.Disable(EnableCap.Lighting);
GL.Disable(EnableCap.Light0);
}
GL.Enable(EnableCap.DepthTest);
GL.Enable(EnableCap.ColorMaterial);
//este es el que hace que se vean todas las capas
GL.Enable(EnableCap.CullFace);
//finalmente ejecuto lo que compile
for (int i = 0; i < GList.Count; i++)
GL.CallList(GList[i]);
GL.PopMatrix();
GL.Finish();
gl.SwapBuffers();
loaded = true;
}
private void rePaintAll(){
GList.Clear();
GList.Add(0);
GL.InitNames();
GL.PushName(-1);
foreach (Line line in lines)
{
decimal[] from = FactoryMatrix.xVxM(line.matrix, line.from);
decimal[] to = FactoryMatrix.xVxM(line.matrix, line.to);
GL.NewList(GList.Count, ListMode.Compile);
if (line.isLineaGuia)
{
GL.LineWidth(2);
}
else
{
GL.LineWidth(3);
}
GL.Begin(BeginMode.Lines);
GL.Color3(line.color);
GL.Vertex3(Decimal.ToDouble(from[0]), Decimal.ToDouble(from[1]), Decimal.ToDouble(from[2]));
GL.Vertex3(Decimal.ToDouble(to[0]), Decimal.ToDouble(to[1]), Decimal.ToDouble(to[2]));
GL.End();
GL.EndList();
GList.Add(GList.Count);
}
foreach (Objeto obj in huevadas){
if (!obj.oculto){
GL.NewList(GList.Count, ListMode.Compile);
GL.PushMatrix();
GL.Color3(obj.color);
IntPtr q = Glu.NewQuadric();
//MessageBox.Show("count "+GList.Count+ " obj "+obj.count);
GL.LoadName(obj.count+1);
int calidad = 10;
if (obj.tipoResolucion.Equals("Alta"))
calidad = 25;
if (obj.tipoResolucion.Equals("Media"))
calidad = 15;
if (obj.tipoResolucion.Equals("Baja"))
calidad = 10;
if (obj.tipoObjeto.Equals("esfera"))//esfera
{
//traslado el baricentro
GL.Translate(obj.centro[0], obj.centro[1], obj.centro[2]);
Glu.Sphere(q, obj.radio, calidad, calidad);
GL.Translate(-obj.centro[0], -obj.centro[1], -obj.centro[2]);
}
if (obj.tipoObjeto.Equals("cilindro"))//cilindro
{
//traslado el baricentro
GL.Translate(0, 0, -obj.altura / 2);
GL.Translate(obj.centro[0], obj.centro[1], obj.centro[2]);
GL.Rotate(-90, 1, 0, 0); //rote el universo, las coordenadas y-z se me cambian.
Glu.Cylinder(q, obj.radio, obj.radio, obj.altura, calidad, calidad);
GL.Rotate(90, 1, 0, 0);
GL.Translate(-obj.centro[0], -obj.centro[1], -obj.centro[2]);
GL.Translate(0, 0, obj.altura / 2);
}
if (obj.tipoObjeto.Equals("cono"))//cono
{
GL.Translate(0, 0, -obj.altura / 4);
GL.Translate(obj.centro[0], obj.centro[1], obj.centro[2]);
GL.Rotate(-90, 1, 0, 0);
Glu.Cylinder(q, obj.radio, 0, obj.altura, calidad, calidad);
GL.Rotate(90, 1, 0, 0);
GL.Translate(-obj.centro[0], -obj.centro[1], -obj.centro[2]);
GL.Translate(0, 0, obj.altura / 4);
}
GL.PopMatrix();
GL.EndList();
GList.Add(GList.Count);
}
}
gl_Paint(gl, null);
}
List<Objeto> huevadas = new List<Objeto>();
y en español esa respuesta seria???Eso fue divertido.
using Glu = OpenTK.Graphics.Glu;
No tengo visibilidad de Glu dentro de OpenTK.Graphics.