glrotate

OpenGl draw a cylinder with 2 points glRotated

最后都变了- 提交于 2019-12-13 08:22:36
问题 I want to show draw a cylinder that starts at point a and that points to I think the key is in the first glRotated, but this is my first time working with openGL a and b are btVector3 glPushMatrix(); glTranslatef(a.x(), a.y(), a.z()); glRotated(0, b.x(), b.y(), b.z()); glutSolidCylinder(.01, .10 ,20,20); glPopMatrix(); Any suggestions ?? 回答1: According to glutsolidcylinder(3) - Linux man page: glutSolidCylinder() draws a shaded cylinder, the center of whose base is at the origin and whose

How to change the Center-of-Rotation in OpenGL

喜欢而已 提交于 2019-12-12 11:14:43
问题 I have a 3D Model (OpenGL ES 1.1 iPhone SDK v3.0) that is somewhat complex ( i.e. Thousands of Vertexes and Faces ) and I'd like to rotate this model around the Y-axis at or near the center of the Model. The problem is that glRotate rotates my model around a point at/near the center of one of its bottom edges , NOT near the center of the Model . Imagine a car driving very tight circles around a light-post, and that is basically what I've got. I want the car to be impaled on the light-post and

OpenGl rotate custom implementation

半腔热情 提交于 2019-12-11 20:28:27
问题 I'm trying to code my custom implementation of Opengl glRotatef(angle,x,y,z) function. I wrote the rotation matrix, but when I try to use it, the effect is not the same as the original function. Here is my code; void mglRotate(float angle, float x, float y, float z) { float angle_rad = angle * (PI/180.0f); float c = cos(angle_rad); float s = sin(angle_rad); float t = 1 - c; float m[16] = { c+x*x*t,y*x*t+z*s,z*x*t-y*s,0, x*y*t-z*s,c+y*y*t,z*y*t+x*s,0, x*z*t+y*s,y*z*t-x*s,z*z*t+c,0, 0,0,0,1 };

OpenGL - Translate after rotate

吃可爱长大的小学妹 提交于 2019-12-11 09:45:15
问题 I am trying to translate an object in world space after rotating it at the origin. The problem is, after I rotate an object while it's at the origin, its local coordinate system rotates as well, so its axes are not parallel with the world coordinate axes anymore. So, for example, if I needed to translate an object to the point (3, 0, 5) after rotating the object around the y-axis, I would not be able to do this since the object's local coordinate system isn't the same as the world coordinate

Getting values of an object after a call to rotatef c++

╄→гoц情女王★ 提交于 2019-12-11 06:30:36
问题 I need to access the X,Y values of a vertex object after Ive rotated it (with glRotate3f). How is it possible? I need em to solve an object collision problem where collisions will be sending objects in an angle related direction based upon objects rotation degrees. edit:: Ok, Ive come close to find a way. Lets assume X and Y and degrees 0, 90 , 180, 270. I set a point as the center of the object, lets assume X=30, Y=70 and the X_size is 60 and Y_size is 140. If I make new_X = X cos(angle) - Y