beginning

samsamsam

24-08-2008 18:19:40

hi
am new to all ogre as to ofusion...
i exported an building designed with 3dmax8 using ofusion,
i got *.mesh files and a *.material file, and a *.osm.
my problem is : should i add all these *.mesh to my ogre project?
coz they r many and i have many objects to add...
so is there another way to add this building as one entity?

Prophet

24-08-2008 20:22:57

For the sake of a quick reply; I guess you'll have to convert it to one single mesh inside 3ds Max. (Which I don't know how, yet). Perhaps grouping them can fix it?
Otherwise, yes.

feanor91

25-08-2008 09:41:38

Hello

the .osm is an xml file describing your scene. You can find on WIKI a C# code that permit you to load you scene via the .osm in OGRE. Or, if you work under .net, you can load my class or my oFusion viewer that you can found in topic under mogre forum.

Evak

25-08-2008 17:07:58

Ofusion comes with a scene loading library that loads the an osm creates a scene or scenes WYSIWYG with what you have in 3dsmax, including animation tracks etc.

So in source code you load your OSMs and can call the separate scenenodes in the scene by name and manipulate them using the Ogre API.

Prophet

25-08-2008 22:28:07

Hm, about the animation tracks. I'm not specially familiar with 3ds Max, but is it possible to export key-framed animations? (Like position) I've never managed to get a .skeleton (and Ogre complaints), so I'd given up. Great plug-in, btw!

Lioric

25-08-2008 23:27:56

Sure, any animation type is supported (even material properties animation) as keyframe (node animation), skeletal (skin, phy, CAT 1 & 2) pose (morpher modifier, up to 100 morph channels), and any vertex animation

Prophet

25-08-2008 23:40:04

Oh, I see. Thanks!

samsamsam

26-08-2008 00:08:00

hi
thank u all for ur help, its really pushing me forwards
but i want to ask, if there r examples which explain how to load my OSM and work with its entity...
or i ll crash u with my many questions :wink:

samsamsam

27-08-2008 03:49:23

hi
i loaded this libs to add all exported meshes using ofusion in one hit and it worked fine
http://www.ofusiontechnologies.com/oFus ... Lib_ce.zip
but i do have some problems in putting the object in the right place on the map,
i just want to know if mOSMScene->createScene(node)
takes the parent node as parameter or the node that i put my exported object in?
if it is for the parent so how i can put my object in a node i choose?
and if not why i have problems in node->setposition coz i dosn't take the position i choose?

Lioric

27-08-2008 04:07:28

See the oSceneLoader demo application, all you need to load your complete scene (with all the correct object positions) is just:


// Create the scene loader
OSMScene oScene;


// Initialises with the scene to be loaded
oScene.initialise("yourSceneFilename.osm");

// create and setup the scene in the root node
oScene.createScene();


mSceneMgr = oScene.getSceneManager();


You just need to pass the filename of the scene you want to load in the initialise method

samsamsam

27-08-2008 04:09:54

For the sake of a quick reply; I guess you'll have to convert it to one single mesh inside 3ds Max. (Which I don't know how, yet). Perhaps grouping them can fix it?
Otherwise, yes.

thanks Prophet but thats didn't work as i tryed, but problem is solved using this code:

http://www.ofusiontechnologies.com/oFusionCE/oSceneLoaderLib_ce.zip
it is really nice and easy, and u can add meshes in one hit.

samsamsam

27-08-2008 04:18:30

See the oSceneLoader demo application, all you need to load your complete scene (with all the correct object positions) is just:

.....

thanks for ur fast reply, but i don't have this demo, could u pls send me the URL? coz i what i want is to put my exported object in a node so i can control its position, scale, ....
and my code is:

OSMScene * mOSMScene= new OSMScene(mSceneMgr, mWindow);
mOSMScene->initialise("buid.osm");
SceneNode* child2= mSceneMgr->getRootSceneNode()->createChildSceneNode();
child2->setPosition(0,0,0);
mOSMScene->createScene(child2);


i don't have a demo, but i tryed to read the source code to know what i should do.

Prophet

27-08-2008 09:57:52

For the sake of a quick reply; I guess you'll have to convert it to one single mesh inside 3ds Max. (Which I don't know how, yet). Perhaps grouping them can fix it?
Otherwise, yes.

thanks Prophet but thats didn't work as i tryed, but problem is solved using this code:
We did some oFusion testing last night, and if you convert one of the objects to Editable Mesh and under Modify->Editable Mesh->Edit Geometry there is an "Attach"-button. Click that and add the others. That worked for us. Sorry for the misleading.

samsamsam

27-08-2008 10:41:01

hi:
thanks Prophet for ur help...
i exported a man to my application, but he is flying! :shock:
i mean he is parallel to earth, i know that i can rotate his node and fix that, but it should be a way that i can export it as he seems in 3dmax, is that right?

samsamsam

01-09-2008 02:59:30

See the oSceneLoader demo application, all you need to load your complete scene (with all the correct object positions) is just:


// Create the scene loader
OSMScene oScene;


// Initialises with the scene to be loaded
oScene.initialise("yourSceneFilename.osm");

// create and setup the scene in the root node
oScene.createScene();


mSceneMgr = oScene.getSceneManager();


You just need to pass the filename of the scene you want to load in the initialise method

hi:
i followed that way, to load an exported man from 3ds Max, i used the *.osm file, but to use animation methods, i noticed the i need to have the man as an Entity to apply the methods on it, the problem is that i get the man in my scene correctly without defining an entity, but now i need him as an Entity, so is there a way to do that with after i intialized the osm and attached it to node?

Evak

01-09-2008 04:37:29

I'm using Ofusion with in our ogre wrapper for blitzmax should be similar in whichever language you use since we tried to stick to ogres way of doing things. This is for a walking pair of mesh legs with stationary idle, walk and strafe anims.

Once you have loaded your OSM, you have to get your animated mesh from the scene manager, I believe you use callbacks for this.




'Grab the robot legs entity and node-
Global robot:TEntity = fG._scene.getEntity("Walkie")



then I have to get the animation tracks I added in ofusion before export.

'Get the robot leg's animations, enable standing by default-
Global animWalk:TAnimationState = Robot.getAnimationState("Walk")
Global animStrafe:TAnimationState = Robot.getAnimationState("Strafe")
Global animStand:TAnimationState = Robot.getAnimationState("Idle")
animStand.setEnabled(True)


have some basoc animation speed variables

Global animSpeed:Float =.03
Global strafeSpeed:Float =.5
Global walkSpeed:Float = 1



Here's the code to enable the animations with keyboard input etc.

'Instead of actual movement, set up animations-

'Check input to determine the states of the robot-
animStand.setEnabled(False)
animStrafe.setEnabled(False)
animWalk.setenabled(False)

'The following variables contain movement details:
Local Strafe:Int = KeyDown(KEY_D) - KeyDown(KEY_A)
Local Walk:Int = KeyDown(KEY_W) - KeyDown(KEY_S)

'Actually move the mesh:
robotnode.translate(Strafe * strafeSpeed, 0, Walk * -walkSpeed, TS_LOCAL)

'Lets reset animation type to keep animations synced together.
If KeyHit(KEY_D) Or KeyHit(KEY_A) Or ..
KeyHit(KEY_W) Or KeyHit(KEY_S) Then animStrafe.setTimePosition(0) ;animWalk.setTimePosition(0)

If (Strafe Or Walk) Then
If Strafe Then
animStrafe.setenabled(True)
animStrafe.addTime(animSpeed * strafe)
End If

If Walk Then
animWalk.setenabled(True)
animWalk.addTime(animSpeed * walk)
End If
Else
animWalk.setEnabled(False)
animStrafe.setEnabled(False)
animStand.setenabled(True)
animStand.addTime(animSpeed *.1)
EndIf


You need some simple timing code for the animation and movement

'Render one frame every 60 seconds-
fG.renderWorld()
Delay 1000 / 60

Until KeyHit(KEY_ESCAPE) Or AppTerminate()

samsamsam

01-09-2008 05:36:07

I'm using Ofusion with in our ogre wrapper for blitzmax should be similar in whichever language you use since we tried to stick to ogres way of doing things. This is for a walking pair of mesh legs with stationary idle, walk and strafe anims.

Once you have loaded your OSM, you have to get your animated mesh from the scene manager, I believe you use callbacks for this.




'Grab the robot legs entity and node-
Global robot:TEntity = fG._scene.getEntity("Walkie")



Evak: hi, thats my problem.
it is how to grab the entity,
my code is:


SceneNode* child2= mSceneMgr->getRootSceneNode()->createChildSceneNode();
child2->setPosition(0,0,0);
OSMScene * mOSMScene= new OSMScene(mSceneMgr, mWindow);
mOSMScene->initialise("man.osm");
mOSMScene->createScene(child2);

now as u said i want to get the man as an entity from the mOSMScene,
should i use the scenemanager?
.... didn't know what fG._scene is...

Evak

01-09-2008 06:24:50

Its the getentity command for the scenemanager in the API docs

http://www.ogre3d.org/docs/api/html/cla ... fbd286ddbc




fG._scene in my code is short for flowgraphics._scenemanager

fg is a static container interface we created for initializing and manipulating Ogre in fewer easier steps.

feanor91

01-09-2008 06:39:48

You know the SceneManager, with it, you know all what you need, if you know the name of your object, that is the name you give it under max. Look tutorials and OGRE API.

Prophet

01-09-2008 15:41:16

Or you can simply load the mesh created by oFusion directly into Ogre, the normal way.

samsamsam

02-09-2008 12:37:52

really thanks for ur replies,
i found where my problem was, i was trying to get the entity from the osm,
but it should be taken from the scene manager.
acually after i asked Evak, what fG._scene refer to, i said "what a stupid question". because if it wasn't from the osm, it should be the scene manager.
so simply as Evak said at the beginnig simply i get the entity by:
Entity *man = mSceneMgr->getEntity("body");
and to get the enitiy name simply i should read the osm file, i was afraid that it would be many entities in it, but it wasn't.
the man was presented as one entity, so the problem solved for now.
but ok what for the exported objects which defined in osm file as more than 20 entities??
u know that my first problem that when i export a building using ofusion i get many meshes to add, so i use osm file to add in one hit, it is ok till now, but with animation i really need one entity to get the animation, thats what i know,
it seems i ask too much, but i am folowing tutorials and try hard to solve,
it may be all animated objects will be as one entity, is it? :roll:
i don't have this problem now but just wondering.
thanks all for ur great help :)

samsamsam

05-09-2008 20:13:37

hi:
please i really need your help, i tryed hard.
i tryed to clone the entity, but that method didn't clone the subentities,
then at last i figured that i can solve my problem by cloning the whole node,
but there is no such method for the nodes, so can i clone the node with all its contents? please answer me if u can... :(

Evak

05-09-2008 22:33:34

This is really a ogre problem not an ofusion one. We have a clone object iterator that finds the parent, checks for and counts children and clones the whole lot adding a random number postfix so it can be a unique instance of the original object.

Unfortunately I'm not a coder and the function is quite complex since it also clones user defined properties and a whole bunch of other things, plus mouse drag and drop of position information. Also works with moveable objects like lights, cameras etc.

Kind of hard for me to sift through and understand what you need. Your best bet is probably to post in the main ogre forums. Now that you know how to grab an entity from the scene manager, you just have to explore some of the methods for finding children and navigating the heirarchy and copying the parent with all children.

samsamsam

08-09-2008 03:21:41

This is really a ogre problem not an ofusion one. We have a clone object iterator that finds the parent, checks for and counts children and clones the whole lot adding a random number postfix so it can be a unique instance of the original object.

Unfortunately I'm not a coder and the function is quite complex since it also clones user defined properties and a whole bunch of other things, plus mouse drag and drop of position information. Also works with moveable objects like lights, cameras etc.

Kind of hard for me to sift through and understand what you need. Your best bet is probably to post in the main ogre forums. Now that you know how to grab an entity from the scene manager, you just have to explore some of the methods for finding children and navigating the heirarchy and copying the parent with all children.

thanks Evak...
u helped me here much,
just to show how i solved my problem "in fact i turned around it",
i changed the osm file manualy, so i made all subentities as entities,
and that makes the parts of the results splite "wrong positions for the subentities",
so i corrected the positions of the subentities by calculating thier new positions according to the parent entity, "depending on positions in osm file", then now i have the entities in right places and i can clone them freely. "notice that these entities should be in same node, so when u mave the node thier related positions still right".
i know that i took the long way, but i was forced because am in hurry, and i didn't want to try some thing beside the ofusion, because it is easy and give effeciant results.

samsamsam

19-09-2008 02:24:10

hi:
i loaded skeletal animation "walking man", by this way:
mAnimationState = manEntity->getAnimationState("Walk");
mAnimationState->setLoop(true);
mAnimationState->setEnabled(true);

and the loaded *.osm file is simple just contains the entity man with information like position, scale and orientatio.
and the animation in *.skeleton file. every thing here is fine and simple.
now i made a simple animation "or moving" for a car with wheels rotating.
i exported it to my Ogre application. and this time the *.osm file contains information about animation, like:

<animations>
<animation name="Walk" loop="true" length="1">
<keyframe time="0">
<position x="-0.00445306" y="0.0547274" z="-6.43011" />
<rotation w="-1" x="-0" y="-0" z="0" />
<scale x="1" y="1" z="1" />
</keyframe>
</animations>

and the first way in loading animation in Ogre didn't work...
am sorry because my question maybe silly but am not an artist and am forced to do that by myself,
so question is: if the object isn't skeletal animated, how can i load its animation?
any help, or guid to something helps would be approciated.

Prophet

19-09-2008 08:37:11

You can use node animations. Like this:
SceneManager::AnimationIterator animationIt = mgr->getAnimationIterator();

while(animationIt.hasMoreElements()) {
Animation* animation = animationIt.getNext();

const Animation::NodeTrackList& trackList = animation->_getNodeTrackList();

Animation::NodeTrackList::const_iterator it = trackList.begin();
Animation::NodeTrackList::const_iterator iend = trackList.end();

for(; it != iend; ++it) {
const Ogre::NodeAnimationTrack* track = it->second;
track->getAssociatedNode()->resetToInitialState();
}

currentTime += evt.timeSinceLastFrame;
animation->apply(currentTime);
}
(I guess you get the idea)

samsamsam

20-09-2008 23:05:36

Prophet, thanks for ur reply...
that seems working, i added it and with excution step by step i saw that animation in line:

Animation* animation = animationIt.getNext();

really get the animations i want which is "Move",
now all i want is to enable it, i mean in ur code i didn't know how we activate the animation and make it work.
am telling u that coz i applied ur code and it worked for the entity that i loaded from *.osm file but it didn't for the entities that i cloned from that entity, so as it seems the original entity r animated and works fine, but the clons is shown as if they don't have animations !!!
so is my problem in cloning the entity? or i miss something?

Lioric

24-09-2008 18:43:55

You need to copy the animation tracks to your new entities (in the same 'animation' create a new 'animation track' that applies to the created entity node, and copy the keyframes)