Hi! After seeing the example where the Skinned Model is used with the sunburn engine, I tried to convert the "Skinned Model Extensions" code in the same way. And succeeded. When I would not edit the world position of the model it works nice. :-)
Then I implemented movement. That method basically recalculates a new world matrix out of a given vector "position". And passes it as the "worldMatrix" in the line;
Again it works swiftly up to some distance of movement as shown in the image below
But after some time the Model stops being visible but continues to cast shadows. (As shown with the red circle)
By the shadow's transformation and movement I can see that the model bones are correctly animated. And I checked to see whether the "Visibility" property stays as "ObjectVisibility.RenderedAndCastShadows" throughout the implementation.
And as you can see it is not a problem of visible distance as the ground gets rendered.
It would be a great help if you can shed some light on the issue (Literally)
Thanks in advance.
I don't believe the method is intended to be used that way, it's actually pushing the model (via its bones) outside of its bounding area. This can become a problem, because the bounding area is used for visibility.
Usually models are animated in-place (like the Skinned Model example, where the guys walks in-place), then the entire model is moved by transforming SceneObject.World to a new location. This is also less expensive as you do not have to transform all of the bone matrices, just a single World matrix.
The xna sample is still very useful for manually transforming specific bones, but within the model's bounds (avoid translating the root node).
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
Ugh Oh! Is that so? This method worked with the regular XNA project so I tried to migrate the entire code from that project to my Sunburn project. If this is the case I'd have to do a massive architecture restructuring process! It might take some time But I will get back to you with the results.
OK now the skinned model moves through the terrain.
Thank you for you advise.
Now I have a new problem. As of the
skinned model Extension example I tried to give an object to the model's
hand. But now the code that was working with regular XNA nolonger
works with this version.
Given below are the code lines that I use
to set the object's world. Can you see what I am doing wrong in
respective to Sunburn object placement scheme?
handIndex = skinningData.BoneIndices["L_Index1"];
worldTransforms = AnimationPlayer.GetSkinTransforms();
= Matrix.CreateScale(0.2f) * worldTransforms[handIndex] *Matrix.CreateTranslation(props[i].Translation)
then in update method
I assign this
calculated "ObjectWorld" matrix to the SceneObject world matrix as
sword.World = DynamicModels[i].siknned.Props.ObjectWorld *Matrix.CreateTranslation(DynamicModels[i].siknned.Position);
is to move the sword with the skinned model.
You should start by setting both the skinned model and the prop's transforms to Matrix.Identity, to make sure the prop is rendered somewhere on the model (likely at the skinned model's feet).
Then you can slowly add your transforms back in to make sure at each step the prop is where you'd expect. At some point a transform will not render where you'd expect and you can focus on why.
A quick guess is that props.Translation is in world space. As mentioned above all transforms for both the skinned model and prop should be relative in object space, then you can simply apply the skinned model's objectToWorld transform to both and they will move together.
Yay! Now it works! what I had to do is replace the
Matrix worldTransforms =
worldTransforms = AnimationPlayer.GetWorldTransforms();
works! The prop moves with the hand!
But still, as in the Skinned model extensions example, the prop
is stuck to the skinned model by the prop's origin (i.e the position on
the prop which was at the scene origin at the time of *fbx export) When I
try to apply the solution they suggested [i.e. to apply a
Matrix.CreateTranslation(props[i].Translation) ] the correction only
works for the frame that the correction is derived from. In other frames
is makes the prop move away from the bone that is intended to stick
I understand that this too may be the result of
"props[i].Translation" being expressed in relation to the object and not
the world. Is there an easy way to convert either
object which is defined in the objects pace to a Vector3
object which is defined in the world space
Created from the Translation of Vector3 object which is
defined in the objects pace to a Matrix which is defined in the
Does the prop translation value change or does it stay the same every frame?
If it stays the same then the offset should be in the prop's "space" (relative to the prop), and the transform should look something like this:
prop.World = prop_translation * model_bone_transform * model_world_transform;
Yay! It works! Thank you very much for your help!
While I was waiting for your answer I added water too. Here is a screen-shot.
Wow, looks cool!
That looks really great, could you share to the community a source code project of Skinned Model Extensions with Sunburn
Looks really cool, did you use the source from the Sunburn Reflection&Refraction sample or did you create own shader?
Contributor on the SunBurn sgMotion Animation Library open source project.
We have posted a Skinned Model Extensions exaple on
this community blog.
for the lateness of reply. We were a kind of busy these days :-D
Yes. We used the Sunburn Reflection and Refraction
Thanks very much for the example, is a good moment because i am working on this project right now