Modify existing Animation objects?

Started by neo187, October 12, 2011, 02:11:43 PM

Previous topic - Next topic

neo187

Hi Egon

For this visual map editor that I am making, I'd like to implement an interface for creating a keyframe animation by browsing for mesh files, ordering them into a sequence, playing the animation back in the editor, and come back later to edit it...

Currently if I have an object selected I get retrieve its attached animation if any, I can get the number of subsequences and their names, play each subsequence by name... but say I wanted the user to be able to add a new sequence at a later time, they would have to work within the number of frames assigned when the Animation object was created (Animation(int keyframeCount)) and if they accidentally assign more I think I read that an exception is thrown... currently there is no way to update this keyframe number after the object has been created?

I don't get what the getSequenceBorders(int seq) method does exactly, but would there be a way to get a list of the meshes per sequence? getKeyFrames() only returns them all....and the Mesh objects could not have a get/setName like Object3D? So as to maybe show the name of the file opened for each keyframe?

And final question, I read that for the Animations to play on AE following the guidelines on the wiki you need to replace obj.build() with calcNormals(), and that's all right?

Thanks for reading this!


EgonOlsen

You can get the meshes of a sequence by combining getKeyFrames() with the getSequenceBorders()-method. The latter (poorly documented, i admin) returns an int[2]-array that contains the start (inclusive) and end (exclusive) indices  of the sequence with that number. The meshes inbetween define the sequence. As for editing an animation...it's limited. It would be better to create a new Animation with the edited data instead of editing the old one.

EgonOlsen

Quote from: neo187 on October 12, 2011, 02:11:43 PM
And final question, I read that for the Animations to play on AE following the guidelines on the wiki you need to replace obj.build() with calcNormals(), and that's all right?
Yes and no. The thing is, that jPCT-AE does something that desktop jPCT doesn't do: It automagically detects which mode (static/dynamic) has to be used when compiling the object. This happens when calling build(). If you build an object without an Animation or a vertex controller assigned, it will be compiled static...so you can't animate it afterwards. This is a problem if you use the same object to get a mesh for your animation that you use for creating the animation object itself, i.e. if you use the first object in a set for both. In that case, you'll call build() to prepare the mesh for the animation on an object that doesn't have an animation assigned and jPCT-AE then switches to static compilation. To avoid this, don't call build() but calcNormals() and calcBoundingBox() instead and use build() only on the final object that should contain the animation after it has been assigned to it. You can do it that way in desktop jPCT too.

neo187

#3
Thanks for your exhaustive answers. Always very helpful. I managed to complete most of what I had in mind. I can't really find a way to enable the user to remove an existing sequence as the current Animation.remove() method removes that data but not the actual array entry so that it will keep showing up the Animation info but if accessed or checked it just gives a big crash....

Thats a bit of a let down but the editor is functional nonetheless...

PS

I've sent you a PM!