Jump to content

  • Log In with Google      Sign In   
  • Create Account

I dont understand localspace for a particle?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Anddos   Members   -  Reputation: 516

Like
0Likes
Like

Posted 29 December 2012 - 02:04 AM

I thought only meshs had a localspace?, how can a particle have a local space?

 

D3DXMatrixIdentity(&mWorld);
D3DXMatrixIdentity(&mInvWorld);

 

D3DXMatrixInverse(&mInvWorld, 0, &mWorld);

// Compute the change of coordinates matrix that changes coordinates
    // relative to world space so that they are relative to the particle
    // system's local space.

 

// Get camera position relative to world space system and make it
    // relative to the particle system's local system.
    D3DXVECTOR3 eyePosW = gCamera->pos();
    D3DXVECTOR3 eyePosL;
    D3DXVec3TransformCoord(&eyePosL, &eyePosW, &mInvWorld);

 

 

 


:)

Sponsor:

#2 haegarr   Crossbones+   -  Reputation: 4587

Like
2Likes
Like

Posted 29 December 2012 - 03:26 AM

A local space is one that is used as a reference for a given set of co-ordinate tuples, so to say. Whether the given set is a mesh, particle system, single particle, skeleton, bone, parented entity frame, ... is irrelevant for this purpose.

To re-interpret the co-ordinates given in a more-local space to a less-local (a.k.a. more-global) space, you multiply the co-ordinates with the transformation build from the placement of the co-ordinate frame of the more-local space with respect to the more-global space (in the following written for row vectors):
pn-1 := pn * Tn-1
This can be done a step further to the next more-global space
pn-2 := pn-1 * Tn-2 = pn * Tn-1 * Tn-2
up until stopping at a space that is in this sense super-ordinated to all the local spaces; then this one is called the global space (or "world").

This can be done in the other direction, too: You can re-interpret co-ordinates given in some more-global space in a more-local space. This is done by using the inverse transformation, because you just need to invert the equations given above. E.g.
pn-1 = pn * Tn-1 <==> pn-1 * Tn-1-1 = pn * Tn-1 * Tn-1-1
so that
pn = pn-1 * Tn-1-1

Something like that is done in the code snippet shown in the OP: You apply the inverse transformation to the camera's position. Assuming that the camera's position was given in global space before, you re-interpret it now in a local space. From the comments I see that the original transformation is the one that places the particle system in the world. So at the end you have transformed the world position of the camera so that is given now w.r.t. the local space of the particle system.

BTW: Notice please that I've written "re-interpret" above. This is because the "world" doesn't really change due to those transformations. You just alter the way you look at it.

Edited by haegarr, 29 December 2012 - 03:27 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS