Transform and rotate group of objects?

Post Reply
paulgriffiths
Posts: 13
Joined: Sun Dec 25, 2016 11:31 am

Transform and rotate group of objects?

Post by paulgriffiths »

I'm building a game consisting of multiple worlds in the same space. You can move between worlds by going through portals.
I need a way of transforming and rotating all objects simultaneously possibly apart from the portal(frame objects, 4 boxes).

This can happen at any time

Any ideas appreciated.

Thank you.
Paul.
paulgriffiths
Posts: 13
Joined: Sun Dec 25, 2016 11:31 am

Re: Transform and rotate group of objects?

Post by paulgriffiths »

Image

Here's a screen shot may help a little.

The portal view is to another world with it's own physics which you can walk in to.
Now what I would also like is have the portal go to the existing world but you end up in a different position. Kind of trippy!

So, is it possible to do the following:

1. Update physics.
2. Check for mouse picking.
3. Shift all the physics objects apart from the gate.
5. Check for picking with mouse again.
6. Shift back the objects.

I can do the opengl graphics the portal consisting of 8 custom clipping planes pointing from center camera point and the corners of the portal. 4 clips so you only render outside the portal for the main world, and another 4 clips so only render within the portal for the portal world.
An idea I invented which works great!

Bullet is new to me.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Transform and rotate group of objects?

Post by drleviathan »

Why bother to actually move the objects in the world? Maybe you could do something like this:

1. Update physics.
2. Compute initial ray.
3. Do {
4. Check for mouse picking along ray.
5. If mouse hits portal compute reflected ray
6. } while mouse hits portal
7. Handle picked object
paulgriffiths
Posts: 13
Joined: Sun Dec 25, 2016 11:31 am

Re: Transform and rotate group of objects?

Post by paulgriffiths »

drleviathan wrote:Why bother to actually move the objects in the world? Maybe you could do something like this:

1. Update physics.
2. Compute initial ray.
3. Do {
4. Check for mouse picking along ray.
5. If mouse hits portal compute reflected ray
6. } while mouse hits portal
7. Handle picked object
I wish to move the objects because the portal view may be the main view but in a different location.

As I wrote:
paulgriffiths wrote:The portal view is to another world with it's own physics which you can walk in to.
Now what I would also like is have the portal go to the existing world but you end up in a different position. Kind of trippy!
Last edited by paulgriffiths on Mon Dec 26, 2016 9:22 pm, edited 1 time in total.
paulgriffiths
Posts: 13
Joined: Sun Dec 25, 2016 11:31 am

Re: Transform and rotate group of objects?

Post by paulgriffiths »

Here's a screenshot with the clipping working on a cube:

Image
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Transform and rotate group of objects?

Post by drleviathan »

If you really want to move all the objects in the physics simulation then you could: for each object: compute the new transform and directly call btCollisionObject::setWorldTransform() on it.

The math looks like this:

Code: Select all

T2 = dT * T1
Where:

Code: Select all

T2 = new transform
T1 = old transform
dT = delta transform applied to all objects
I think dT can be obtained from the portal:

Code: Select all

dT = inverse(Tportal)
A problem with this method is that if you do many portal operations the relative transforms of objects will start to drift from numerical error. At 32-bits I'd expect this to start becoming noticeable after 10 to 20 operations, depending on the size of your world: larger worlds will drift faster.

You could probably reduce this problem by using 64-bit math. Alternatively you could remember the each object's transform in the original frame and then operate like this for objects that have not moved since the last portal operation:

Code: Select all

T0 = original transform
dT0 = last portal operation
T2 = dT * T0
For objects that have moved recently you would first compute a new T0 and then perform the portal operation:

Code: Select all

newT0 = inverse(dT0) * T1
T2 = dT * newT0
Another problem you might have is that it would be possible to "walk" the world far from the origin after multiple portal operations and you could wander into distances that start to introduce more numerical error and even instabilities in the constraint solver. To solve this you could effectively perform the normal portal operation and then backshift everything by the portal's translation. That is, you use a modified dT:

Code: Select all

dT = inverse(translationPartOf(Tportal)) * inverse(Tportal)
and then after operating on all the other objects you would slam the portal's translation to zero:

Code: Select all

newTportal = rotationPartOf(Tportal)
Post Reply