Loading in Multiple 3D objects to allow for Animated Scaling

Hi All,

I have a 3DS model with JPG texture that I am loading into OF 006 via the ofx3DModelLoader addon.

It looks lovely:

[attachment=2:xqzfbktl]completeModel.jpg[/attachment:xqzfbktl]

I have also had the model broken up in to parts so that I can animate each bit individually within OF - scaling the mouth and moving the hat etc. Unfortunately, I haven’t been able to get the co-ordinate system from Cheetah 3D (http://www.cheetah3d.com/) (where it was modelled) to line up with the OF openGL co-ordinate system. Especially strange as Cheetah 3D also uses OpenGL for its positioning.

[attachment=1:xqzfbktl]modelInParts.jpg[/attachment:xqzfbktl]

The positioning of the objects in Cheetah3D is as follows:

[attachment=0:xqzfbktl]allPartsTogetherPos.jpg[/attachment:xqzfbktl]

I have positioned my separate objects in the same way as the complete model:

  
  
	float	xPos = ofGetWidth()/2.f;  
	float	yPos = ofGetHeight()/2.f;  
	float	zPos = 0.f;  
	  
    wizardModelEyes.setRotation(0, 180, 1, 0, 0);  
	wizardModelEyes.setPosition(xPos+9.354f, yPos+6.271f, zPos +0.f); //see EYES.PNG from Cheetah 3D  
	wizardModelEyes.setScale(4, 4, 4); //is scaling OK?  
	  
    wizardModelHat.setRotation(0, 180, 1, 0, 0);  
	wizardModelHat.setPosition(xPos+0.f, yPos+7.636f, zPos +0.f); //see HAT.PNG from Cheetah 3D  
	wizardModelHat.setScale(4, 4, 4); //is scaling OK?	  
  
	wizardModelHead.setRotation(0, 180, 1, 0, 0);  
	wizardModelHead.setPosition(xPos+0.f, yPos+11.696f, zPos +0.f); //see HEAD.PNG from Cheetah 3D  
	wizardModelHead.setScale(4, 4, 4); //is scaling OK?	  
	  
	wizardModelMouth.setRotation(0, 180, 1, 0, 0);  
	wizardModelMouth.setPosition(xPos+0.f, yPos+7.636f, zPos +0.f); //see MOUTH.PNG from Cheetah 3D  
	wizardModelMouth.setScale(4, 4, 4); //is scaling OK?	  

vs.

  
    wizardModel.setRotation(0, 180, 1, 0, 0);  
    wizardModel.setPosition(ofGetWidth()/2, ofGetHeight()/2, 0);  
    wizardModel.setScale(4,4,4);	  

But the positions are coming out completely wrong. How do I marry the two co-ordinate systems so I can animate relative scale and position?

You can find both OSX OF 006 projects to download below:

http://dl.getdropbox.com/u/370155/OFChe-…-eModel.zip

(Complete with Cheetah ScreenGrabs and the like)

and

http://dl.getdropbox.com/u/370155/OFChe-…-Models.zip

(Just the broken up model)

Cheers,

JGL

hey JGL!

I’ve been doing a similar thing, but modeling with Blender. I haven’t had any problems like that.

My suspicion is that maybe the 3ds export script in cheetah is losing the coordinate system.

Tried Exporting to 3ds, and then importing the 3ds file back into cheetah? does that line things up right?

*edit*
Never mind… I checked, and the 3ds files line up fine when imported into Blender. Trying to re-export and see…

-C

According to the 3D Artist here, the origin of OBJ files is controlled by a “pivot point” that is saved in the files. I tried adding an empty mesh and including it in the corner of both models, but it doesnt seem to have an effect.

I am going to look into the modelloader and see if its automatically centering things maybe?

The reason i had no problems before is that the models i was overlaying were more or less concentric, so there was no issue (yet)

Hi 5cameron, Am working with Joel on this… I made the wizard hat guy.

For my 2 pence worth I’ve opened the exported .3ds’s back in Cheetah and like Blender the parts are displayed with the correct translations in the global space.

Cheers,
JHP

How are the objects loaded into 3D space in OF from the addon? Is the draw position the centre of the model? The top left? GL co-ordinates or OF ones?

Hi,

i’ll try to bring some light here :wink: the FIRST node in a model is very important, it’s the scenne node, it contains the matrix (world matrix),

from all other “sub-models” will be draw realative to his Position.

I hope i could help.

btw, i’m not sure, but i think is the midlle in ofx3Dmodel.

Chears ,

CC

Hi Carlos and 5cameron,

Thanks for your reply Carlos. I understand the structure of 3D files, especially their complexity in terms of animation, meshes, and submodels. I am going to try to run some tests with basic models to see where the ofx3DModelLoader loads into OF space.

If anyone else has had experience with loading multiple files into OF with ofx3DModelLoader or with animating those files relative to each other, it would be great to hear from them here.

Best,

JGL

Where it is loaded into OF depends on where the axis was when it was made in a 3D program.
So for example if you make a letter T as a 3D model in Maya if the base of the T is at 0,0,0 in Maya then when you export that is your 0,0,0 point.
When you load that T into OF the base of the T would be drawn at the top left corner of the screen (if no other transformations are applied).

The scale and rotation are also similar - ie set by the program that made them - thats why different models can come in at vastly different scales.

In terms of animation - if I remember correctly the 3DS code that the ofx3DModelLoader is built on supports some form of animated mesh.

Theo