Sign in to follow this  
Followers 0
Anddos

I dont understand localspace for a particle?

1 post in this topic

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);

 

 

 

0

Share this post


Link to post
Share on other sites
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
2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0