Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Object matrix and scaling

Author
Message
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 16th Nov 2010 22:34
Hi, I'm trying to improve my physics plugin, I really need to know some of the finer details of how the object matrices are built in dark basic.

I can build a matrix the standard way and everything works great until I scale the object, then all the angles seem to break, here's the code:



The above sample creates, rotates and scales an object, I build a matrix and create another object and set the matrix directly.

Without scaling I can translate and rotate any way I like and it works, does anyone know why adding scaling is breaking it?
Thanks.

Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 16th Nov 2010 23:24 Edited at: 16th Nov 2010 23:37
If I remember right, with Direct3D you must combine your matrix in scale, rotation and translation order.


Try:
D3DXMATRIX matResult = matScale * (matRotateX * matRotateY * matRotateZ) * matTranslate;

ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 17th Nov 2010 16:46 Edited at: 17th Nov 2010 17:11
Thanks Todd, that helps alot.
I now understand why I can't set my actors world matrix with dbGetObjectWorldMatrix(), as this includes scaling which the physics is not interested in. This is fine for boxes, spheres etc, as I can just pass in scaled dimensions to the physics.

Its a bit different though for meshes, I need to scale the vertex positions before I pass them to the physics, I got this working, but only for objects that are scaled the same on all axis, I would be interested to know if you have tackled this problem yet and have any pointers.

If not, I'm sure I will figure it out in the next few days, thanks again Todd

EDIT: Actually, just looking at it, I think I am scaling the vertices correctly, but I do have a rotation problem when the object/limb has been scaled non uniformly, I'm sure I will figure it out.

Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 17th Nov 2010 18:10
Cool, glad that helped out

I really haven't got to a point where I need to start figuring out scaling yet. I would rather not have too. I'm hoping that by trying to wrap every function that I can from Bullet Physics, that solving how bullet see's a scaled dbpro object can be done in dbpro code.

Before scaling a mesh, I would figure you would just be able to get the original vertex position and then get the scaled values by multiplying it's x,y,z values with the different x,y,z scale values (ie: x scale * x position, y scale * y position, z scale * z position). Then send those new scaled values to the physics engine. Then actually scale the mesh after that so that the physics engine will match up to the scaled mesh... ?

ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 17th Nov 2010 20:52
Yeah, thats exactly how I have always scaled my vertices and it does work great most of the time, I am having problems with limb scaling with meshes although I have a couple of ideas what might be causing it.

Login to post a reply

Server time is: 2024-11-19 16:32:25
Your offset time is: 2024-11-19 16:32:25