# glmultmatrix question car model

This topic is 3018 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This the way i took in trying to make the front tire rotate when the car moves forward. I first calculated the center of the car:

Then center of car tire:

in Draw function, i am trying to do multmatrix:

glPushMatrix()

A = self.matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, self.carCenterX - self.xtireCenter, self.carCenterY - self.ytireCenter, self.carCenterZ - self.ztireCenter, 1)

glMultMatrixd(cast(A, POINTER(c_double)))

glMultMatrixd(cast(B, POINTER(c_double)))

draw the tire

C = self.matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, self.xtireCenter - self.carCenterX , self.ytireCenter - self.carCenterY, self.ztireCenter - self.carCenterZ, 1)

glMultMatrixd(cast(C, POINTER(c_double)))

glPopMatrix()

Basically i am translating the center of tire to center of the car, rotate the tire and then translating back where tire was originally.

But this seems to be not working.

##### Share on other sites
Sorry cant help you :) hehe I usually just cheat and use the rotation and translation matrices d3d comes with, and I actually suggest to you to use the matrix library in open gl, it would solve a lot of these problems unless you really want to do it the hard way...

##### Share on other sites
The solution is to ensure that the center of the tire is at zero 0 at the moment when the rotational matrix is applied; after rotation the center is to be moved back to its local position. If e.g. the center is located at p with the corresponding translation matrix L, then the effective rotation looks like
L * R * L-1
for column vectors as used by OpenGL. (You may have to consider early rotations, too, dependent on the car model transformations.)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 9
• 9
• 40
• ### Forum Statistics

• Total Topics
634130
• Total Posts
3015704
×