Advertisement

'rotating' a normal?

Started by January 27, 2003 09:43 AM
15 comments, last by mickey 22 years ago
hello, i'm terribly sorry if i couldn't still get it,

can you pls modify my code, maybe this way things would be much brighter,

this is how i construct the quad for the front face of the model's bounding box,

D3DXVECTOR3 vMinBox1, vMaxBox1, vTriangle[4];ObjectB.GetBoundingBox(&vMinBox1, vMaxBox1);vMinBox1 += ObjectB.GetPos();vMaxBox1 += ObjectB.GetPos();vTriangle[0] = D3DXVECTOR3(vMinBox1.x, vMinBox1.y, vMinBox1.z);vTriangle[1] = D3DXVECTOR3(vMinBox1.x, vMaxBox1.y, vMinBox1.z);vTriangle[2] = D3DXVECTOR3(vMaxBox1.x, vMinBox1.y, vMinBox1.z);vTriangle[3] = D3DXVECTOR3(vMaxBox1.x, vMaxBox1.y, vMinBox1.z);  


SetAMatrixIdentityForWorldTrans();
RenderQuad();

okey that renders properly the quad, even i scaled and translated anywhere ObjectB,

can you write the code plz how i would construct the quad once i started rotating the model using these?

//Transforms vector (x, y, z, 1) by a given matrixD3DXVec3Transform(D3DXVECTOR4 *pOut,    CONST D3DXVECTOR3 *pV,    CONST D3DXMATRIX *pM);// or?// Transforms a 3-D vector by a given matrix, projecting the result back into w = 1.D3DXVec3TransformCoord(D3DXVECTOR3 *pOut,    CONST D3DXVECTOR3 *pSourceV,    CONST D3DXMATRIX *pSourceM);  


i have a slight idea why it doesn't work, but no idea how to make it work, i'd like to construct the triangle base from the model's min/max with the right orientation without using any transformations,

thanks,

[edited by - mickey on January 29, 2003 12:03:26 AM]
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
Don''t scale the bounding box or translate it to the models origin. Just use the bounding box the model would have if it was unscaled and poitioned at the origin. Then apply the same matrix you use to scale and position the model to those bounding box vertices... currently you seem to be adding the model translation to the bounding box verts and if you transforrm those it will end up in the wrong position.

Hope that helps a bit more.

I also see you have a triangle with 4 vertices!

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Advertisement
>>Then apply the same matrix you use to scale and position the model to those bounding box vertices

matrix? you mean the world matrix? i'm not modeling a bounding box, i'm setting up a quad to represent plane hence the 4 verts of my triangle ,

i already have the bounding box set up, i just want to create a quad that would orient with the model's boundinng box or the model itself... without applying any transformations, this way, i could get a better representation of the plane later on,

so when i rendered my quad, i just set a identity matrix for the world trans,

i have a screenshot of my problem on this thread incase you didn't come across it,

thanks and pls be patient,

[edited by - mickey on January 30, 2003 7:21:57 AM]
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
Where do you want the quad in relation to the model? Underneath it like a rug or shadow quad that spins when the model spins? You are going to have to apply a transform at some point. Once you have applied the transform (it will be the model space->world space transform) and got the coordinates back you will then be able to use the identity matrix to render on the screen... but you may as well just use the same model->world matrix for rendering.

Or am I missing something here?
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
>> Once you have applied the transform (it will be the model space->world space transform) and got the coordinates back you

get the coords back right? how? thru D3DXVec3Transform? that outputs a 4d vector or D3DXVec3TransformCoord that outputs a 3d vector?

and after this, would this be the ''3d vector'' that i would create the quad with the right orientation?

pls look

that screenshot, the quad should be at the back of the shop, not on the side, and aligned properly...,

also plz don''t forget to mention exatly the source vector i should pass in, (ie, the rotation vector i used for a rotation matrix and so on.. )

thanks for having the time to help me out, i tried the chatrooms and people are just telling me that ''it''s pretty straightforward'' and couldn''t help me much more but i really couldn''t see the way...,
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
Use the 3d vector version 4 times with each vertex of the quad, in the model-space of the vector (i.e. as if the model was not scaled, rotated or translated) with the model->world matrix. Then use those vectors to construct the quad.

Write some test code that spins the shop around a bit every frame, you''ll be able to see whether the quad spins the correct way and is positioned correctly relative to the shop. Then write some code that moves the shop around a bit every frame. Moving stuff is much easier to visualise in 3d on a 2d screen!

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Advertisement
ugh, this is getting crazy, pls bare with me..,

>>Use the 3d vector version 4 times with each vertex of the quad

use it 4 times?? huh?? what exatly do you mean? do i also assume that the 3d vector came from D3DXVec3TransformCoord()? not D3DXVec3Transform(), right?

but i still need to pass the right vector source parameter in it.., but what kind of vector? the rot?pos? and so on..?

i have to construct the right way the quad first before i could do some tests..,

i have here a description of the return value from D3DXVec3Transform()...
return value: Pointer to a D3DXVECTOR4 structure that is the transformed vector.

does this mean, say i feed the function the world matrix of objectB, and a i don't know source vector, i get a vector that already contains the right scale,rotation, and position from ObjectB?? my understanding doesn't make much sense to me...,



[edited by - mickey on January 30, 2003 10:10:02 AM]
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,

This topic is closed to new replies.

Advertisement