![]() |
|
Weird "stretching" object - Printable Version +- iDevGames Forums (http://www.idevgames.com/forums) +-- Forum: Development Zone (/forum-3.html) +--- Forum: Graphics & Audio Programming (/forum-9.html) +--- Thread: Weird "stretching" object (/thread-3240.html) |
Weird "stretching" object - anthony - Jun 13, 2007 10:44 AM Hi, I am rendering a falling cube (it's from an ODE simulation), but for some weird reason the cube appears to "stretch", actually it looks like it gets longer. I don't have an exact value but say, it's 1 x 10 x 1 (width, height, length) as it falls and then shrinks too it's normal size 1 x 1 x 1. Falling: ![]() Proper size, once landed: ![]() (the small white square is just something i put in to mark the floor) I've checked the dimensions as it falls and they don't change. I've tried clearing all the buffers just in case the "stretch" is actually caused by a buffer not clearing properly but that hasn't made a difference. Does anyone have any ideas as to what might be causing the problem? Weird "stretching" object - LongJumper - Jun 13, 2007 10:55 AM Are you continually multiplying the transformation matrix as the frames go on? All of your drawing code posted may help... Weird "stretching" object - anthony - Jun 13, 2007 11:55 AM The way I'm drawing the cube is: 1. Get its position in the ODE world (x, y and z) 2. Get its rotational matrix from ODE and converting it to be an OpenGL matrix 3. I translate the cube using its x, y and z 4. And then glMultMatrixf () the rotational matrix I've pasted in the code below: Code: // the update...The Render() function. ODE coordinates are defined as the centre of the object's body so I've altered them to draw the cube correctly in OpenGL. I'm not sure if I'm using glTranslatef() correctly, but my reasoning was that I could draw the cube using a display list, I just haven't gotten around to it yet. Code: ...It's melting my face at the moment, I think I spent a bit too long at it today. I might have bitten off more than I can chew with the 3D graphics but this is the first time I've had a problem like this. Weird "stretching" object - anthony - Jun 13, 2007 12:00 PM Fixed it! The mistake I was making was that I was using the altered x, y and z as the drawing coordinates and _still_ translating - bah! Thanks LongJumper, if you hadn't asked for my drawing code I'd probably not have copped the problem at all!
Weird "stretching" object - LongJumper - Jun 14, 2007 10:59 AM Uhhh, glad I could help? Your API should be able to spit out an entire transformation matrix which contains the rotation + translation for one smooth glMultMatrix call instead of translate/mult. Not that it matters a whole lot.
|