From: Ben H. <be...@ex...> - 2003-07-10 14:49:44
|
The problem you have isn't with CsGL but rather with the OpenGL API. glRotate excepts as its parameters an angle of rotation and a vector around which to rotate. You are currently giving a vector of rotation of (1.0f, 1.0f, 0.0f). This is not a unit vector. Because it isn't a unit vector I am not surprised that this operation is causing a scaling issue. I would normalize that vector and see if that works. -ben www.exocortex.org > -----Original Message----- > From: csg...@li... > [mailto:csg...@li...] On Behalf Of > Michael Shafrir > Sent: Thursday, July 10, 2003 8:59 AM > To: csg...@li... > Subject: [Csgl-users] Trouble with CsGL and rotating. > > > I am writing an app in C# (VS.NET). I am using CsGL for > some basic OpenGL stuff. I want to draw an x,y, and z axes in > the control, and then rotate the view so that it looks 3D - > if you draw the axes and don't rotate them, you wouldn't be > able to see the Z axis. > > Here's my code, which I based mainly on > (http://www.componentsnotebook.com/notebooks/csharp/csgl.aspx) > . You will see that I called GL.glRotatef(10.0f, 1.0f, 1.0f, > 0.0f); at one point. I picked 1.0 for the angle arbitrarily; > however, no matter what angle I choose, it only seems to make > the axes smaller. Please help, and if there are any questions > ask away! > > Btw, this is how the axes look before I rotate: > http://www.terptrader.com/normalaxis.png > And after I rotate: http://www.terptrader.com/rotatedaxis.png > My goal is to have the axes look 3D, like in this picture: > http://wonkosite.ausbone.net/vrml/axis.gif > > > > If you could help I would really appreciate it because I am > completely stumped right now. > > > > private void drawAxis() > > { > > double left = 0.05 * Size.Width; > > double right = 0.95 * Size.Width; > > double bottom = 0.05 * Size.Height; > > double top = 0.95 * Size.Height; > > double origin_x = Size.Width / 2; > > double origin_y = Size.Height / 2; > > > > // draw X axis > > GL.glBegin( GL.GL_LINES ); > > GL.glVertex3d( left, origin_x, 0 ); > > GL.glVertex3d( right, origin_x, 0 ); > > GL.glEnd(); > > > > // draw Y axis > > GL.glBegin( GL.GL_LINES ); > > GL.glVertex3d( origin_y, bottom, 0 ); > > GL.glVertex3d( origin_y, top, 0 ); > > GL.glEnd(); > > > > // draw Z axis > > GL.glBegin( GL.GL_LINES ); > > GL.glVertex3d( origin_x, origin_y, 0.0 ); > > GL.glVertex3d( origin_x, origin_y, 1.0 ); > > GL.glEnd(); > > > > GL.glFlush(); > > } > > > > public override void glDraw() > > { > > GL.glRotatef(0.5f, 0.0f, 1.0f, 0.0f); > > drawAxis(); > > } > > > > protected override void InitGLContext() > > { > > GL.glClearColor( 1.0f, 1.0f, 1.0f, 0.0f ); > > GL.glColor3f( 0.0f, 0.0f, 0.0f ); > > GL.glPointSize( 4.0f ); > > } > > > > > > protected override void OnSizeChanged(EventArgs e) > > { > > base.OnSizeChanged(e); > > > > GL.glClear(GL.GL_COLOR_BUFFER_BIT | > GL.GL_DEPTH_BUFFER_BIT); > // Clear Screen And Depth Buffer > > GL.glMatrixMode(GL.GL_PROJECTION); > > GL.glLoadIdentity(); > > GL.glOrtho( 0.0, Size.Width, 0.0, > Size.Height, 1.0, -1.0 ); > > GL.glMatrixMode(GL.GL_MODELVIEW); > > } > > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Parasoft > Error proof Web apps, automate testing & more. > Download & eval WebKing and get a free book. > www.parasoft.com/bulletproofapps > _______________________________________________ > Csgl-users mailing list > Csg...@li... > https://lists.sourceforge.net/lists/listinfo/csgl-users > |