|
Saii Hallard
Registered User
Join date: 11 Dec 2006
Posts: 16
|
11-11-2007 01:31
I'm getting too much code trying to solve this relative simple thing, so i'd like to ask if someone know a simple solution.
Two cubes, randomly moved and/or rotated. Unlinked. But next to eachother.
Cuba A can be moved and rotated and cube B must stay 'attached' to cube B on the same side as it started. Start data (pos and rotation from cube A and B) will be stored. So, basically act like they are linked. If for some reason a gap is formed between cube A and B it must reposition itself by using the start values before the movement.
What i like to know is how to solve the last point, so to reposition the cubes relative to eachother, but on another vector and rotation.
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
11-11-2007 04:06
You want to store B's initial positional offset from A, for which B will need to know A's initial position (a_pos) and rotation (a_rot):
vector b_offset = ( b_pos - a_pos ) / a_rot;
I gather that the two will always maintain the same rotation, so that is all you need to store. Every time A moves, it will have to communicate it's new position and rotation to B, probably via a private chat channel. Or, and this is a recent addition to LSL, B can get data on A using llGetObjectDetails, provided that it is given A's instance kay.
When B will find it's new position and rotation thusly:
vector new_pos = b_offset * a_rot + a_pos; rotation new_rot = a_rot;
|
|
Saii Hallard
Registered User
Join date: 11 Dec 2006
Posts: 16
|
Thanks
11-11-2007 08:12
Thanks Deanna, your sample made it clear again. Cube B can have a different rotation, but that's just as easy. Got it running 
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
One minor nicety...
11-11-2007 08:31
If the delay between A moving and B moving bothers you, you can reduce it by using a timer.
A sends new position, rotation, and a *time* to B before it moves. B computes its new position and rotation.
At *time*, they both move.
|