Jump to content
• Advertisement

# I dont understand localspace for a particle?

This topic is 2172 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

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

#### Share this post

##### Share on other sites
Advertisement
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

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
• Advertisement

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013187
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!