Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

12000 Posts in 1588 Topics- by 3508 Members - Latest Member: PienueDut

26. May 2012, 11:57:06 am
Xith3D CommunityGeneral CategoryFeature Requests & Brilliant Ideas (Moderators: Marvin Fröhlich, 'n ddrylliog)Prescaling and Positioning
Pages: [1]
Print
Author Topic: Prescaling and Positioning  (Read 2051 times)
Patheros
Getting respectable
***
Offline Offline

Posts: 267


Dead Dolphin


View Profile WWW Email
« on: 10. February 2007, 12:19:06 am »

I think it would be useful to be able to load an object and have the loader scale, possibly position, and maybe even rotate the object as its loading it. Probably the most logical way to do this is to optionally pass the loader a transformation.

Right now I'm using a custom obj loader, but the only real special functionality is setting the scale.
Logged

"I like my method, what was my method again?" - Jon
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 10. February 2007, 12:36:43 am »

I think it would be useful to be able to load an object and have the loader scale, possibly position, and maybe even rotate the object as its loading it. Probably the most logical way to do this is to optionally pass the loader a transformation.

Right now I'm using a custom obj loader, but the only real special functionality is setting the scale.

Well, I think, this would bloat the loader API a bit. Scaling the model is done in only one additional call:
Code:
Model model = new OBJLoader().loadModel( "bla.obj" );
model.getTransform().setScale( 2.0f );

But I also had this idea some time ago and implemented it into the org.xith3d.loaders.models.util.ExtensionLoader. So if it is ok for you, you could just use the ExtensionLoader, which takes parameters for translation, rotation and scale.

Code:
Model model = new ExtensionLoader().loadModel( "bla.obj", 2.0f );

Marvin
Logged
Patheros
Getting respectable
***
Offline Offline

Posts: 267


Dead Dolphin


View Profile WWW Email
« Reply #2 on: 10. February 2007, 03:36:47 pm »

First: This does look like what I have right now and should probably work.
Code:
Model model = new ExtensionLoader().loadModel( "bla.obj", 2.0f );


Second: is there a way to get:
Code:
Model model = new OBJLoader().loadModel( "bla.obj" );
model.getTransform().setScale( 2.0f );
to scale and rotate (and possible transform too) the object? Something like?
Code:
Transform3D rotate = new Transform3D();
rotate.rotXYZ(.1f,.2f,.3f);
Model model = null;
model = OBJLoader.getInstance().loadModel( "bla.obj" );
model.getTransform().setScale( 2.0f );
model.getTransform().add(rotate);


Third: For static transformations of objects (ones that apply to the model all the time) I think it would be more efficient to apply the transformation to each point before the model is constructed.
Logged

"I like my method, what was my method again?" - Jon
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 10. February 2007, 03:47:07 pm »

First: This does look like what I have right now and should probably work.

Cool.

Second: is there a way to get:
Code:
Model model = new OBJLoader().loadModel( "bla.obj" );
model.getTransform().setScale( 2.0f );
to scale and rotate (and possible transform too) the object? Something like?
Code:
Transform3D rotate = new Transform3D();
rotate.rotXYZ(.1f,.2f,.3f);
Model model = null;
model = OBJLoader.getInstance().loadModel( "bla.obj" );
model.getTransform().setScale( 2.0f );
model.getTransform().add(rotate);

In general you shouldn't apply rotation, translation and scale to one TransformGroup at a time. But in principle the ExtensionLoader takes all these at a time. They are applied in the order (rotation, translation, scale).

But you can use Amos' Transform class to do everything in one line (which internally creates three TranformGroups).

Third: For static transformations of objects (ones that apply to the model all the time) I think it would be more efficient to apply the transformation to each point before the model is constructed.

This is done by the GeometricMath class. You can retrieve all the Shape3D objects from the model by the model.getShapeNodes() method. Then transform them with the appropriate methods of the GeometricMath class.

Marvin
Logged
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #4 on: 10. February 2007, 05:39:23 pm »

SO.

Positioning/Rotating/Scaling at LOAD TIME should be done (IMHO) directly on the Geometry. So that no unnecessary time is spent on transforming the Shape at RENDERING TIME.
Some of these functionalities are already implemented in the GeometricMath class, it should be completed and methods added to the Model class.
Then we could even have an (XML-based) file format for models which specify the "real" model file (e.g. OBJ, Cal3D) and the modifications applied (e.g. scale, rotate, translate). Of course this file would be edited with a graphical editor (Xith3D+HUD) so that it'd be really easy to get your models right Smiley
Additionnally, this format could be extended with some JOODE-binding stuff (say, you have several XML files with a body, an arm, a hand and so on, you create another one to bind them all with a JOODE skeleton). But we're far from it.

And whoops Patheros already said that :
Third: For static transformations of objects (ones that apply to the model all the time) I think it would be more efficient to apply the transformation to each point before the model is constructed.

Last thing :
But you can use Amos' Transform class to do everything in one line (which internally creates three TranformGroups).
That's false. Now the Transform class is optimized and have only ONE Transform3D. It just multiplies matrices when needed (to add a Transformation to another).

Well, it depends the way you use it, of course, e.g. :
Code:
new Transform(node).setScale(scale).addTranslation(pos).addRotation(rot);
Will use only one Transform3D, whereas :
Code:
new Transform().setScale(scale).add(new Transform().setTranslation(pos)).add(new Transform().setRotation(rot));
will use three.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #5 on: 10. February 2007, 05:50:20 pm »

But you can use Amos' Transform class to do everything in one line (which internally creates three TranformGroups).
That's false. Now the Transform class is optimized and have only ONE Transform3D. It just multiplies matrices when needed (to add a Transformation to another).

Well, it depends the way you use it, of course, e.g. :
Code:
new Transform(node).setScale(scale).addTranslation(pos).addRotation(rot);
Will use only one Transform3D, whereas :
Code:
new Transform().setScale(scale).add(new Transform().setTranslation(pos)).add(new Transform().setRotation(rot));
will use three.

Hey, cool. That brings a better sense to the Transform class Smiley.

Marvin
Logged
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #6 on: 10. February 2007, 06:09:24 pm »

For sure Smiley
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic