Note that there are some explanatory texts on larger screens.

plurals
  1. POrotating tire rims of car opengl transformations
    primarykey
    data
    text
    <p>Here is the draw function which draws the parts of the car, in this function car rims is checked and flag is checked, and i need to rotate the tire rim as i move the car. Something is not working since the rims are rotated but taken out from the car model, when i press up arrow key, but the car does move.</p> <p>I also initialized self.fFlag = "false" in initialize function:</p> <pre><code>def on_draw(self): # Clears the screen and draws the car # If needed, extra transformations may be set-up here glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) for name in self.parts: colors = self.colors color = colors.get(name, colors["default"]) glColor3f(*color) if (name == 'Front Driver tire rim') &amp; (self.fFlag == "true"): bodyFace = self.mini.group(name) glPushMatrix() glRotatef(45,1,0,0) # Drawing the rim for face in bodyFace: if len(face) == 3: glBegin(GL_TRIANGLES) elif len(face) == 4: glBegin(GL_QUADS) else: glBegin(GL_POLYGON) for i in face: glNormal3f(*self.mini.normal(i)) glVertex3f(*self.mini.vertex(i)) glEnd() glPopMatrix() self.fFlag == "false" else: bodyFace = self.mini.group(name) for face in bodyFace: if len(face) == 3: glBegin(GL_TRIANGLES) elif len(face) == 4: glBegin(GL_QUADS) else: glBegin(GL_POLYGON) for i in face: glNormal3f(*self.mini.normal(i)) glVertex3f(*self.mini.vertex(i)) glEnd() def on_key_release(self, symbol, modifiers): """Process a key pressed event. """ if symbol == key.UP: # Move car forward # TODO glTranslatef(0,-1,0) self.fFlag = "true" self.on_draw() pass </code></pre> <p>Edited: I am trying to make the car rims to rotate when i press the up arrow key, which moves the car forward.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload