Not logged inOpenClonk Forum
Up Topic General / General / 3D mesh rendering
1 2 Previous Next
Parent - By Clonk-Karl [de] Date 2009-12-31 03:00
Interesting. I'm wondering why this did compile with gcc actually. I see that you have committed a fix already.
Reply
Parent - By Clonk-Karl [de] Date 2009-12-31 03:23
In case anybody who can't compile the engine wants to play with this: Here is a build of the current mesh branch.
Reply
Parent - - By Clonk-Karl [de] Date 2010-01-13 21:20 Edited 2010-01-13 22:31
So I think I (partly; there is still a gotcha when entering a water basin sideways or from the bottom) know what's the problem with swimming currently - the proper solution is to always interpolate rotations the "short way". As far as I see this no longer allows interpolation between an arbitrary amount of animations. I therefore suggest to introduce an animation stack instead: The lowest two animations are combined, then the result is combined with the next animation, etc.

C4Script functions

I also suggest a somewhat extended script interface to simplify otherwise redundant code which calls AnimationSetState each frame:

bool AnimationPlay(int stackpos, string animation, array peval, array weval)

Starts the given animation at the given stack position. The animation is combined with the result from the combination up to the animation which is at the next smaller stack position. This animation has its associated weight (see below), and the previous animation uses (1 - weight). Afterwards, the result is combined with the animation with the next higher stack position in the animation stack. This means that the weight of the lowest level in the stack is unused. Also, stackpos == 0 is not allowed since this is reserved for ActMap animations. It is possible to set values smaller or larger than zero however (to combine before ar after the ActMap animation is combined). The function returns false if there is already an animation being played at the given stackpos.

bool AnimationStop(int stackpos)

Removes the animation at the given position from the stack.

bool AnimationSetState(int stackpos, array peval, array weval)

Changes the way the animation at the given position is currently being played.

Value evaluation

peval and weval can be constructed via helper functions, much like the arguments for FindObject(s). They define how the animation is being played. All of these are applicable to both peval (determines how to choose the current animation position) and weval (determines how to choose the current animation weight). Possibilities include:

Anim_Const(int value)

Set position or weight to the given value. This is what AnimationSetState currently does.

Anim_Linear(int start, int end, int length, int atend)

Interpolate linearly in time between start and end. This means that in the frame of the function call the value (position or weight) will be set to start, and after length frames it will be end. atend defines what to do after length frames. The following values are possible: ANIM_Loop (restart at start), ANIM_Hold (keep end until a new call to AnimationSetState is being done, or the animation is removed) or ANIM_Remove (remove the animation from the animation stack).

Anim_XDir(int start, int end, int length, int atend)

Base the animation speed on the object's current xdir. This is meant for the Walk and Run animations to synchronize the Clonk movement with its animation. length defines after having moved how many pixels in X direction the animation is supposed to reach end.

Anim_YDir(int start, int end, int length, int atend)

Same as Anim_XDir, but for vertical movement (scaling).

Anim_RSin(int start, int end)

Calculate the value like "start + Sin(Abs(Angle(0,0,GetXDir(),GetYDir())), end - start)", i.e. use start for horizontal movement and end for vertical movement. This is meant to be used for the swimming animation weights.

Anim_RCos(int start, int end)

Same as above, with Cos replaced by Sin.

Final notes

Let me know if any other position/weight evalution functions make sense to achieve required behaviour (hangling?) without resorting to a Frame=1 timer.

Note also that, using this functionality, it is possible to have the same animation multiple times within the stack (also allowing different animation position). This might make sense for example when blending from one animation to another, but getting back to the original animation before the blending has finished.

So let me know your opinion on this before I actually get to implementation :). Maybe stack is not the right term after all, since it is possible to insert/remove animations in the middle as well. It rather refers to the way how the animations are being combined... suggestions for other terms are welcome though.
Reply
Parent - - By Randrian [de] Date 2010-01-13 21:52
Well, sounds generally a good idea. But I can't really imagine how this stack will actually affect the blending, how this would influence the blending system as is is now. But when it can solve these problems with swimming animations, it sounds good. Also multiple animationsinstances of the same animation can be usefulll for crossblends.
The system with the automatic animationtimers also sounds very nice. Although walking would still need an effect (switching walk run and so on). Perhaps something like "call function foo when frame x is reached" could be nice for e.g. throwing when the animations hand is at a given position. Could also be made using timer...

Actions like hangling probalby require the implementation of "ground" frames, we talked about. They could perhaps realize the nonlinear movement of the clonk.

And Anim_XDir(int start, int end, int length, int atend) ? Wrong set of parameters? there doesn't appear "px".
Reply
Parent - By Newton [de] Date 2010-01-13 22:28
I still think that using SetObjDrawTransform would be a good solution for the rotation while swimming. As Günther? said before, the clonk could overload SetObjDrawTransform and add any new SetObjDrawTransform called without some magic extra parameter to the current transformation. At least for climbing and falling, we need even rotation too.
Parent - - By Clonk-Karl [de] Date 2010-01-13 22:30

> But I can't really imagine how this stack will actually affect the blending, how this would influence the blending system as is is now.


I don't think there will be too significant differences. For only two animations affecting a bone there will be no difference at all.

> Although walking would still need an effect (switching walk run and so on).


Hm, we could also introduce another animation function which allows to set the weight based directly on the object's xdir. Maybe rename the existing ones to Anim_X/Anim_Y and call these Anim_XDir/Anim_YDir.

> Actions like hangling probalby require the implementation of "ground" frames, we talked about. They could perhaps realize the nonlinear movement of the clonk.


Yeah, I have this also in mind.

> And Anim_XDir(int start, int end, int length, int atend) ? Wrong set of parameters? there doesn't appear "px".


Oops. That should be length of course. *fix*
Reply
Parent - By Randrian [de] Date 2010-01-13 22:36
Hmm well, I don't think we can eliminate the effects completly. For example turning has to be detected and made. The soft interplotation betwenn the animations stand and run can't be don by weighting them just by speed I think. Some "time blending" as it is now would be still needed. And also such things as to adjust the start offset of run. When starting to run from stand it would look a bit wierd, if the clonk doesn't start by pushing himself up, but to magically interpolate to the state, where he is in the air.
Reply
Parent - - By Bowserkoopa [at] Date 2009-12-27 16:03
But this should also be able for Cinema 4D. It's also very popular for Clonk Graphics. Not as much as Blender, but its also used.
Reply
Parent - - By Randrian [de] Date 2009-12-27 17:08
When there exists an Ogre Exporter for Cinema 4D, you can do your models in Cinema 4D as well.
Reply
Parent - - By Bowserkoopa [at] Date 2009-12-27 18:48
I don't know but isn't that only for C4D R9/10? I use R11
Reply
Parent - - By Randrian [de] Date 2009-12-27 18:50
I haven't worked with C4D yet, so I can't say. The Blenderexporter also isn't for the newest Alpha Version. But that's the task for the developers of the exporters, not ours.
Reply
Parent - By Bowserkoopa [at] Date 2009-12-27 18:55
Right, but would be nice for some people, that can't work good with blender.
Reply
Parent - By Nachtfalter [de] Date 2009-12-28 23:35
Afair currently not for 11/11.5.
Reply
Parent - By Clonk-Karl [de] Date 2010-01-10 01:55
A note on material scripts:

All material scripts (*.material files) are loaded into the same global material pool. I therefore suggest to prefix all materials used for an object with the object's name, separated by a slash from the material name, so for example instead of "Body" use "Clonk/Body". The idea behind this is to be able to share materials for multiple objects, and to be able to inherit materials (not all of this is implemented yet, but I hope it to be at some point). There is one catch however: To be able to use or inherit a material, it must be loaded already. This is only guaranteed if the material script file is in the object itself or one of the parent objects. Loading material scripts from System.c4g would be another nice thing for global materials that should always be available.
Reply
Parent - - By Clonk-Karl [de] Date 2010-03-05 18:53 Edited 2010-03-05 18:55
Meshes can now also be loaded from OGRE binary format. Please use this format instead of XML where possible as it is smaller in size and can be loaded significantly faster on engine startup. To export into OGRE binary format from Blender make sure the "OgreXMLConverter" button is pressed when exporting. There is also a standalone tool that ships with OGRE called OgreXMLConverter which converts existing meshes from XML into binary format.

Thank Isilkor for implementing this feature. Or buy him a pizza on the OCM.
Reply
Parent - By Isilkor Date 2010-03-06 15:05 Edited 2010-03-06 15:19

> To export into OGRE binary format from Blender make sure the "OgreXMLConverter" button is pressed when exporting.


If you get an error saying "Mesh header does not contain the expected version" or "Skeleton header does not contain the expected version" while loading your mesh, and you're using the latest version of your modelling tool's Ogre exporter, please file a bug in the bugtracker, attach the converted mesh or skeleton file, and assign that bug to me (if you have the permissions to do that), or pester me on IRC. Thanks!

[Edit]
Actually, do that if you have anything that loads from XML, but doesn't from binary.
Reply
Parent - By Newton [de] Date 2010-03-06 15:52
An article in the wiki about that would be great. Our artists guide is already pretty complete but this is missing
Up Topic General / General / 3D mesh rendering
1 2 Previous Next

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill