How to actually get bone and animation data with assimp? - assimp

Hello Im trying to import animation and bones data from a FBX file.
I actually tried with several different models in different formats, but no matter what I Do it always says
scene->mNumAnimations = 0;
scene->mNumBones = 0;
What could be happening?

What assimp uses to animate the models is a bone chain based on the meshes. We have a bone hierarchy which stores the affected vertices by the bone animation. The bones itself are descriped by an offset-matrix, which is just the inverse of the global transform for the current mesh in respect to the root-node of your animation hierarchy. This comes from the X-Fileformat and I want to add a better way to descripe bone-animations.
The pretransform-bone-post-processor will perform the transformation after the import directly. So your bones will be gone.

Related

Blender glft mirrors armature after exporting model

I have gltf model with rig and animation sequences (with .bin), exported from video game League of Legends. After mport into Blender, everything looks fine (almost, but that's not important for rig), but after exporting into other format (I export as .smd to use in Source Filmmaker, but also tried othe formats) and importing into Blender exported model armature mirrors along global Y. Here's how animation has to look
And here is what comes after export-import:
import mesh with armature, but without animation
and what comes with adding animation
(for this after previous screenshot I flipped mesh in edit mode along Y global).
I tried to mirror before/after export-import both armature and mesh. Nothing helped before. On last screenshot everything is flipped along global X. One day I fixed it, but her weapon (circle thing) is always behind her after export-import when it must be ahead of her.

Godot doesn't import glTF material shaders correctly

I have a model that I am using as my gameworld in Godot and I am putting some textures on it in Blender. When exporting the model to .glb it seems to not be exporting some of the materials correctly.
The ones that are an image texture that I scaled using mapping.
It just skips the first two nodes. When I disconnect them the material looks like it does in Godot.
What it should look like (what it looks like in Blender):
What it looks like in Godot:
There also are some materials that use mix shaders to mix images together. These are also skipped and it just uses one of the two instead of mixing them.
What it should look like:
What it looks like in Godot:
The F is from an image with text that is overlayed ontop of the other image.
I am not really sure if these issues lie with the glTF format and certain shaders just don't work with it or that Godot doesn't want to import them.
I hope someone can help me with this.
Thanks in advance and have a nice day,
Rover
In general, arbitrary node graphs cannot be exported from Blender — see https://blender.stackexchange.com/a/57541/43930 for the long explanation of that. To ensure that the material will export correctly, you'll need to refer to the documentation for the Blender glTF exporter and configure your material accordingly. For more complicated effects, you can also bake Blender nodes down to simpler textures.

Blender .fbx -> Spark AR Studio scaling issue for skeleton animations

I'm trying to create a character with skeleton animation in Blender to bring into Spark AR Studio. In Spark I want to use the baked animation. The .fbx brings the model and skeleton into Spark's scene just fine, until a new animation controller is selected via the object's inspector window and the animation is selected for use.
At that point, the Empty object named "Armature" is scaled to 100 instead of 1 and cannot be changed.
As a workaround, the Skeleton child object named "skeleton" can be scaled to 0.01. In Blender, I tried changing the scene's units and made sure the object's scales were all applied. Nothing is scaled to 100, everything is scaled to 1.
Since the object from the .fbx imports into Spark with correct scaling, I expect the animation to maintain that, but once the animation is selected the scale jumps from 1 to 100.
Put you animated object inside some nullObject and then scale down not animated but nullObject. Hope it is clear.

blender's triangle is CW order or CCW order by default?

I have a model exported from blender.
I checked and I found that each triangle is in the clock wise order. Is this the default order for blender?
You can see the generation of triangles with "Ctrl+T" or Mesh>Faces>Triangulate Faces
There you get a triangulated mesh which will be the same as the exported order.
Basically the is no clock or counter clock wise. It all depends on your model's shape and how you rotate or even mirror it. But with the quads to tris you already see how your model will look after exporting without importing into another application (unless the application you import to changes the mesh).

Is this a good OO design?

I'm building an API for myself to do 2D skeletal animation.
I have a Bone class
and a Skeleton class.
The Skeleton creates a root bone and then subsequent bones are added via the Skeleton's add method by providing the parent bone.
What I now want to do is add animation and frames.
What I was thinking of, is a class that can load and interpolate animations. So it would be an object that would load an animation. It would then, at each frame, take in a Skeleton and modify the Skeleton accordingly.
Is this a good design? Should an animation take in a Skeleton, or should a Skeleton take in an animation and apply it onto itself?
It's best to create an Animation that makes use of a Skeleton instead of the opposite. This because, logically speaking, the object Skeleton does not require an Animation to live, but an Animation strongly requires a Skeleton.
So you can couple those elements in the Animation itself. Do not put too much logics in the objects, and try to put it just where necessary.
Presumably every bone has a 2d position/angle and an animation is a collection of frames where each frame is a collection of bone identifiers and position/angles?
Then you might consider something like
public class Skeleton
{
public List<Bone> Bones {get;set;}
public void Animate(Animation animation)
{
foreach(Bone bone in Bones)
{
bone.Displace(animation.Displacements.FirstOrDefault(o=>o.BoneId == bone.BoneID));
}
}
}
I would create an Animation class containing a std::vector<Skeleton> data member that you can use to manipulate individual Skeleton objects on each frame or interpolate across multiple Skeleton objects in the vector from keyframes. Then when you "play" the animation, you merely have to iterate over the vector, calling out each Skeleton object, and pass that to some other function or class that will display the results on-screen (or do whatever else the Skeleton can be useful for, such as warping a mesh, etc.)
Having an animation object will make it much easier to manipulate the frames of the animation, allowing you to remove/replace frames, etc. Otherwise if you try to pile all of this functionality into a Skeleton object, then you're going to find there's a lot of baggage when trying to manipulate individual aspects of the Skeleton separately from the animation sequence (i.e. suppose you need to change the hierarchy of the Skeleton for a segment of frames, etc.? ... that would be very easy if there is a Skeleton on each frame, but not if you have a monolithic Skelton object).