Notifications
Clear all

[Closed] Set vertex keyframes with C++ SDK

Hello,

I have a tool that imports meshes of a fixed number of vertices into Max. I would like to extend this tool to import snapshots of these meshes at different points in time, and apply them as vertex keyframes.

Can someone suggest the best way to do this? By best I mean the simplest way to code & understand, but with high performance as these meshes are relatively complex.

Underneath I believe Max creates controllers for each transformed vertex, and these controllers contain the keyframes. I have no idea how to do this with the SDK though, but even if I did, would this really be the best way, since I have a snapshot of the entire mesh at each timepoint? I would probably need to diff the mesh at each frame to prevent an unreasonably large number of controllers & frames would I not?
Maybe something like morph targets would be more suitable, but I don’t have enough experience with either to say…

Any random thoughts on this would be helpful!

sj

(The tool is written with the managed wrapper (C#) for the C++ SDK)

22 Replies

I’m looking for something similar, what I want to do is to programmatically keyframe all vertexes through c++ over time.

Either through manipulating the Pointcache modifier from c++, or by adding the keyframes directly on the vertex position controller.

I have not solved it yet, but if I solve it (or get help here or other places) then I’ll let you know.

Hi stigatle,

Here is where I have got up to. From the documentation and looking around in Max, it seems vertices are animated with Point3 keyframe controllers, which are attached to the Master Point Controller of each object. Each animated vertex has a keyframe controller, which has the index in the Master Point Controller’s subcontrollers list, as the vertex it animates.

I have attached a quick sketch of how this is laid out, and a C# project which is supposed to create a box with two animated vertices. Unfortunately the project doesn’t work. All the objects (the controllers and keys) are created, but nothing shows up in the track view in Max.

I think I may be creating the keys in the wrong location, or omitting some step that updates the Master Point Controller with the number of keyframes the object has. I won’t be looking at it further though until someone here can point out where this is going wrong – I have had as much of Autodesk’s ““documentation””* as I can take for the month… or year!

Good luck with your attempt!

(* because just one sarcastic quotation wasn’t enough!)

thanks, I got as far as to figuring out what you mentioned.

[edit]
I found this:

http://dl3d.free.fr/phpBB2/viewtopic.php?t=921&sid=9a1921f2a027daee3bb86663610157b3

It’s doing the opposite of what I want, but it’s easy to reverse.

Have a look at the pointcache modifier in the samples, you should be able to use that or modify it for your purposes. You can call it from your plugin via a CacheOps function publishing interface.

Klvnk, I tried that first, and I hit some snags.

First – I thought I could ‘record’ by using the maxscript function, but the issue then was that if i hit ‘record’ then it instantly records (For example) 100 frames, then proceeds with the next step in my code after recording, so from maxscript I could not use it.

What i need is something that let’s me record on a frame-by-frame basis.
I then tried to access it from c++ in a better way, but I was not able to figure it out properly.

what I do is that I’m triggering a function in c++ from maxscript which starts my simulation,
this called function does not exit back to maxscript before it’s done with each frame.
That’s why I need it in c++, because maxscript only ‘sees’ the first frame, and the last frame, everything in between happens in my c++ function.

I then ended up looking for a way to keyframe the verts directly as mentioned above.

(I have yet to make either work though, have not had time for it the past days).

Thanks Klvnk. My thoughts are that the pointcache will actually be better from a performance point of view and ease of use, but I would like to try both first. Also there is a complication in that I can’t use the FP interfaces from C# because Autodesk forgot to add the managed equivalent of FPParam!

I did poke it again the other night. I have found that I can create keyframes using the technique in the project in my post above. If I run the code, then in the collapsed track view, right click on the timeline and select Key Properties -> Master Point Controller, I can see my keys in the Key Info dialog. The difference between these and the ‘working’ ones created in Max as far as I can see is that my Point3 Controllers have the name “(null)” and Max’s have the names “Vertex 1”, etc.

I’m not sure if this is actually just a name or if there is some step to indicate that these controllers should be operating on the vertices of the mesh. Given that there is no method to rename controllers, I am thinking its the latter though I’ve no idea what the step is.

the pointcache uses a pretty simple file format *.mc data file (fbx format I believe and uses big endian byte order and stores vertex positions as doubles) and the .xml descriptor file. It wouldn’t take much work to write the data and call the mxs to create the modifier and load the file from c#.

The .mc is Autodesk’s own format isn’t it? I was going to use .pc2 originally since, apart from being simpler, it hasn’t undergone any changes in a long time. I’d like to use .mc but am not sure if the format may risk changing with each version of Max.

pc2 is a single file operation and the correct endian.

Page 1 / 3