Jump to content

  • Log In with Google      Sign In   
  • Create Account

Object orientation/position best storage method


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
2 replies to this topic

#1 zacaj   Members   -  Reputation: 643

Like
0Likes
Like

Posted 21 May 2012 - 03:13 PM

I have been working on a 3D game engine for fun and at the beginning of development I had the idea to store objects with an abstract "Transform" class instead of any definite type of position/orientation (xyz+quaterion, for example). This way you could have a normal QuaternionTransform that would be used for most objects, a PhysicsTransform for objects in a physics engine, a OrbitTransform, etc. All they need to provide is functions that give their current position, orientation (3x3 matrix) and transformation (4x4 matrix).
This had been working fine until I started working on the in game editor. I started by coding a "move" tool but after getting everything set up with picking working, etc I realized that this would work horribly with my Transform system. Any system for moving (let alone rotating!) my objects would have to conform to a single Transform type, etc. How would you move an OrbitTransform that is relative to another object 10 meters left?
So my question is, what is the standard method of dealing with this?

Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7504

Like
0Likes
Like

Posted 22 May 2012 - 12:00 AM

So my question is, what is the standard method of dealing with this?

You should consider to use only one transformation, all other transformations are derived from this one. Derived transformation will have some kind of offset matrix you can change individually. Example
class Entity {
  Matrix transform;
  Matrix renderOffset;
  Matrix orbitOffset;
  Matrix physicOffset;
  void getTransform() { return transform;}
  void getRenderTransform( return transform * renderOffset;}
  void geOrbitTransform( return transform * orbitOffset;}
  void getPhysicTransform( return transform * physicOffset;}
  void setTransform( ..)
  ..
}

Use some kind of caching/dirty flag when you fear a perfomance impact.

Edited by Ashaman73, 22 May 2012 - 12:01 AM.


#3 Krohm   Crossbones+   -  Reputation: 3119

Like
0Likes
Like

Posted 22 May 2012 - 12:32 AM

I started by coding a "move" tool but after getting everything set up with picking working, etc I realized that this would work horribly with my Transform system. Any system for moving (let alone rotating!) my objects would have to conform to a single Transform type, etc.

Blender has explicit notion of node transformations. Works just as expected and pours out a 4x4 matrix if memory serves.
Truth to be told, I am not currently supporting arbitrary transforms but only rigid. Non-rigid transforms have nasty properties when it comes to physics to the point of possibly involving per-frame processing. I am not going to support this any time soon.

How would you move an OrbitTransform that is relative to another object 10 meters left?

I would deprecate the concept entirely and use constraints of some kind of hierarchical animation. In my system - I admit - this is not supported unless in some specific situations. For a more general approach, I would enforce the orbit by using scripting on a fully kinematic object.




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