I’m trying to switch on animation interpolation to stop the frames being so jumpy in my C++ application, as it says in panda3d.org/manual/index.php … Animations. Unfortunately it only has a python guide on the C++ page, and I have been unable to find the correpsonding set_blend() function in the C++ documentation. Does anyone know how to switch this on?
By the way, I have also tried deleting my model cache and setting interpolate-frames 1 in the config prc script but this has no effect. To check that it is working I have slowed the animation down using set_play_rate(), I’m not sure if this would have an effect?
EDIT: Oh, and also I am loading bam files from the disk rather than eggs. Does this information get baked into the bams?
Thanks in advance.
Setting “interpolate-frames 1” would work if you were loading eggs, but this setting gets baked into the bams. You can also set it at the time you generate bams.
The alternative, to set this option at runtime, is to call PartBundle::set_frame_blend_flag(), which is the low-level implementation of Actor.setBlend(). You can get the PartBundle with Character::get_bundle(0).
Thanks for the information. Unfortunately I am getting a crash, here is what I am doing:
I have a feeling that the nodepath that I am using isn’t a character objects, hence when I cast it to a character and call get_bundle(0) it crashes. Here is how a load the mode and animations.
//Load just the geometry for the model with no animations
this->junkernp = this->window->load_model(this->window->get_panda_framework()->get_models(), “junker.bam”);
//Add each animation one at a time
//Auto bind the animations to controls
auto_bind(this->junkernp.node(), this->junker_anims, PartGroup::HMF_ok_part_extra | PartGroup::HMF_ok_anim_extra | PartGroup::HMF_ok_wrong_root_name);
Any ideas how to get the character object from this?
Sure, the top node of the result of load_model() is generally a ModelRoot node. The Character node will be some child of that node, often the first child, but not necessarily. You can find it with code like this:
NodePath child = this->junkernp.find("**/+Character");
Character *ch = DCAST(Character, child.node());
assert(ch != NULL);
PartBundle *bundle = ch->get_bundle(0);
assert(bundle != NULL);
Note that a responsible coder always checks return values for error conditions before calling through. Also, the DCAST macro is provided as a type-safe cast; it will print an error message and return NULL if the object in question is not actually a Character node. (Though this type-checking is disabled if NDEBUG is defined; in this case, it compiles to the same thing as a static cast.)
Thanks David, worked like a charm. Normally I would check return values, but the code I posted isn’t the actual code that I’m using. I paraphrased it for the forum . Thanks again!