Horde3D
http://horde3d.org/forums/

Importing camera animations
http://horde3d.org/forums/viewtopic.php?f=2&t=1086
Page 1 of 2

Author:  Irdis [ 29.01.2010, 13:45 ]
Post subject:  Importing camera animations

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)?

Author:  marciano [ 29.01.2010, 22:29 ]
Post subject:  Re: Importing camera animations

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.

Author:  Irdis [ 02.02.2010, 11:59 ]
Post subject:  Re: Importing camera animations

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)?

Author:  Volker [ 02.02.2010, 12:33 ]
Post subject:  Re: Importing camera animations

Since you have to time the animation yourself using h3dSetModelAnimParams, you can play as much frames as you want.

Author:  marciano [ 02.02.2010, 23:28 ]
Post subject:  Re: Importing camera animations

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.

Author:  Irdis [ 03.02.2010, 12:35 ]
Post subject:  Re: Importing camera animations

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);

Author:  Volker [ 03.02.2010, 14:03 ]
Post subject:  Re: Importing camera animations

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).

Author:  Irdis [ 03.02.2010, 16:28 ]
Post subject:  Re: Importing camera animations

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?

Author:  marciano [ 03.02.2010, 22:17 ]
Post subject:  Re: Importing camera animations

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.

Author:  Irdis [ 16.02.2010, 10:32 ]
Post subject:  Re: Importing camera animations

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?

Author:  Irdis [ 22.02.2010, 21:15 ]
Post subject:  Re: Importing camera animations

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?

Author:  Volker [ 23.02.2010, 09:48 ]
Post subject:  Re: Importing camera animations

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.

Author:  marciano [ 24.02.2010, 21:56 ]
Post subject:  Re: Importing camera animations

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

Author:  Irdis [ 25.02.2010, 12:21 ]
Post subject:  Re: Importing camera animations

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.

Author:  Irdis [ 24.03.2010, 14:04 ]
Post subject:  Re: Importing camera animations

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.

Page 1 of 2 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/