Horde3D

Next-Generation Graphics Engine
It is currently 14.05.2024, 04:02

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 29.01.2010, 13:45 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Hello.

I've got a question: it is possible to modify collada converter, so it will import cameras, as it is written in wiki. But how to import animations for cameras?
Converter doesn't create anim files for cameras, and rewritting the converter logic would be quite difficult.

For example, I have one rather complex scene. I create a dummy linked with camera, that contains all the camera's animation. Dummies are not imported, but it seems that their animation does (judging from the .anim size). And, as the scene has other animated objects, all animations are stored in a single file. Is it possible to load animation only for the specified object (camera)?


Top
 Profile  
Reply with quote  
PostPosted: 29.01.2010, 22:29 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
ColladaConv is actually meant for exporting models (single assets like a character, building or prop), not complete scenes. That's why it does not handle cameras and lights.

However, with your idea of using a dummy, you are on the right track to get what you want. But as dummy you need to use an empty mesh (with no triangles), a joint or a small cube with some "nodraw" shader. You can then attach a camera to that mesh/joint in your game code.


Top
 Profile  
Reply with quote  
PostPosted: 02.02.2010, 11:59 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Is it possible to play only part of animation? I know, that horde has animation blending, which is used in knight's sample. But, for example, in max scene I have 400 frames. I have different camera animations from 0 to 100, from 250 to 300, from 320 to 400. Now (somehow) this track is exported. Can I now play only a part of this animation? So that the camera will only move to the position, that was in the 100 frame? Or do I need to export animations separated from each other (create new scenes with different camera animations in max)?


Top
 Profile  
Reply with quote  
PostPosted: 02.02.2010, 12:33 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Since you have to time the animation yourself using h3dSetModelAnimParams, you can play as much frames as you want.


Top
 Profile  
Reply with quote  
PostPosted: 02.02.2010, 23:28 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
You can also export several collada files from the same max scene. In the collada exporter you can specify the animation range.
Hide your geometry before exporting to make the resulting dae files smaller and faster to process.


Top
 Profile  
Reply with quote  
PostPosted: 03.02.2010, 12:35 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Well, I modified the converter so it exports camera animations to another anim file. It seems that the generated file is correct. But when I try to attach this animation to camera I get:
...
2.144 Invalid node handle in h3dSetupModelAnimStage
2.155 Invalid node handle in h3dSetModelAnimParams
...

I tried to use this animation with the box from the scene, but the result is the same. Is the generated anim file corrupted, or am I doing something wrong?

Attempt to attach animation to box:

In init:

h3dFindNodes( env, "Box75", H3DNodeTypes::Mesh );
bx = h3dGetNodeFindResult( 0 );

h3dSetupModelAnimStage( bx, 0, CameraAnim1Res, 0, "", false );

The box is found correctly.

in mainloop:

_animTime += 1.0f / _curFPS;
h3dSetModelAnimParams( bx, 0, _animTime * 24.0f, 1.0);


Top
 Profile  
Reply with quote  
PostPosted: 03.02.2010, 14:03 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
h3dSetupModelAnimStage requires the node to be a Model node,... so you have to search for the model not the mesh in the scene graph. If you following marcianos proposal to use a box with an empty mesh you have to attach the camera to the model node as a child. Then use h3dSetupModelAnimStage on the Model node (not the mesh).


Top
 Profile  
Reply with quote  
PostPosted: 03.02.2010, 16:28 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
And if I want Horde to directly animate cameras from generated .anim file I'll have to write an extension that overloads h3dSetupModelAnimStage and h3dSetupModelAnimParams?


Top
 Profile  
Reply with quote  
PostPosted: 03.02.2010, 22:17 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Extensions can't overload these functions at the moment (you can only create new scene nodes and resource types) so you would need to modify the engine code directly if you want that feature. However, I would suggest to try using an invisible dummy model to which the camera is attached first. A different approach would be to handle that in a different module of your application, something like a cutscene system.


Top
 Profile  
Reply with quote  
PostPosted: 16.02.2010, 10:32 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Somehow, now I can get camera animations from Max. But the problem is that in max camera position is -816 (x), and in horde roughly the same position is -29. How do I transform the world coordinates, used by camera, to local coordinates of the scene?


Top
 Profile  
Reply with quote  
PostPosted: 22.02.2010, 21:15 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Umm, well, how do I conсretize my problem...

In Max scene the camera is located in:
Pos: -816.165cm (X), -233.806cm (Y), 160.773cm (Z).
Rot: 88.723 (x), -0.053 (y), -74.578 (z)
In my horde project, where camera was set manually in editor to roughly recreate the same position as in the max scene:

_x = -19.7841f;
_y = 24.4296f;
_z = 49.7239f;
_rx = -2.10008f;
_ry = -72.3003f;

Now, if I set horde camera's position to be the same, as in Max, I get black screen, because my scene is far away from the camera.

Scene position in horde (info from editor)
tx="-13.236"
ty="22.8656"
tz="47.7172"
sx="0.0104439"
sy="0.0104439"
sz="0.0104439"

So, what should I do to get the camera's position in horde be the same, as in the Max? Because otherwise all the exported camera animation would be broken.
Should I transform the position and scale of the scene? In horde or in Max? Will it help somehow?


Top
 Profile  
Reply with quote  
PostPosted: 23.02.2010, 09:48 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
I would avoid having a scale in the camera transformation. Apart from that it seems that it is not just a scaling problem. So I guess the transformations might be relative to a parent node either in Horde or 3D Max. But as I don't have much experience with 3D Max I can't really help you.


Top
 Profile  
Reply with quote  
PostPosted: 24.02.2010, 21:56 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Can you check the scene hierarchy in Max and Horde: is the camera attached to some parent node which might apply some transformation?


Top
 Profile  
Reply with quote  
PostPosted: 25.02.2010, 12:21 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
I think that the problem is with the scale of the scene.

sx="0.0104439"
sy="0.0104439"
sz="0.0104439"

When I made it 1, 1, 1 I got the needed position. I got all my lights screwed, so I need to set them again in new places, but it's another problem))

marciano wrote:
Can you check the scene hierarchy in Max and Horde: is the camera attached to some parent node which might apply some transformation?

No, both in Max and in horde camera belongs to the root element.


Top
 Profile  
Reply with quote  
PostPosted: 24.03.2010, 14:04 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Well, camera animations from max can now be played in horde. But there is a new problem: if fps in one second was 30 and in the next second it is 60 the animation accelerates for a moment and then goes normally with 60 fps. I use a forward pipeline, 16x antialiasing and v-sync. The moment animation hastes is when visible polygons are reduced from about 200k to 85k.

I use the following formula for camera animation: speedOffset += 1.0f / (FPS /_speed) ;

If speedoffset is greater than 1, then the current frame is switched to the next or the previous (one big positive feature of this formula is that you are able to move through the same animation frames backwards) and speedoffset -=1. If not, there is linear interpolation between frames.

Any idea how to fix that problem? (Should I take your animation algorithm? Won't there be the same moment when animation accelerates?)

P.S How to enable engine's internal custom timer? I didn't find a function for that. The reset function in h3dGetStat doesn't enable the timer.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group