Making better use of Ogre's capbilities?

Everything about development and the OpenMW source code.
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: Making better use of Ogre's capbilities?

Post by Chris »

jhooks1 wrote:Looks good. Doesn't the head have a parent NiNode/Bone you can connect it to?
I can take the last node specified in the tree before the NiTriShape, but that doesn't really seem correct. If I try that, it was still rotated incorrectly).

I imagine something a little more complex is at work. AFAIK, xskinnpc.nif is actually clothing that characters wear. The body and head are separate sections, so there's probably something else the engine uses to figure out where the head trishape goes.

I'm again left to wonder if each NiTriShape should be a separate mesh/entity instead of a sub-mesh/sub-entity. As long as each mesh entity is connected to the correct bone of a root mesh/skeleton, it should behave largely the same but with the extra flexibility of being able to move each trishape independently by connecting its nodes to something else. Connect the nodes of the child entity (and any skeleton it may have) to the root entity's skeleton, and animating the root skeleton will implicitly animate the child.

This will need a bit more "book keeping" for certain types of in-game objects since you're now dealing with a hierarchy of entities instead of just one, but it seems a better fit from how this stuff is laid out.

Alternatively, we might be able to get away with rewriting the submesh's vertices/normals and bone assignments once when it needs to connect to something else, though there could be bounding box and collision issues with that.
At time .5 I believe your code would pick quat2 as the rotation value, and trans1 as the translation.

Shouldn't the translation picked instead be a value between trans1 and trans2 (An interpolation?)
Yes, though I wasn't really concerned about that at the time. What's there was good enough to get something working, even if some of the movements may be a little jerky. I can try doing something a bit better now, though.
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

Chris wrote:
jhooks1 wrote:Looks good. Doesn't the head have a parent NiNode/Bone you can connect it to?
I can take the last node specified in the tree before the NiTriShape, but that doesn't really seem correct. If I try that, it was still rotated incorrectly).
I have this working correctly in openmw, for shapes without skins. I don't know if my implementation will help you though. Another creature with NiTriShapes like this is the Ancestor Ghost - the head and jaw.
Chris wrote:
At time .5 I believe your code would pick quat2 as the rotation value, and trans1 as the translation.

Shouldn't the translation picked instead be a value between trans1 and trans2 (An interpolation?)
Yes, though I wasn't really concerned about that at the time. What's there was good enough to get something working, even if some of the movements may be a little jerky. I can try doing something a bit better now, though.
Maybe this is the source of the problem you mentioned?
I would suggest to pick the value in between, (may need some custom interpolation. Perhaps look at handleAnimationTransforms() in openmw) - Ogre Slerp for your rotations and another calculation for your translations. Once you get the in between values, fill them in as necessary into the Animation Track.

Or Option 2, have an Ogre animation containing only Quaternions and an animation only containing Vector3's. Then blend them together. This may not work and would be less efficient.

EDIT:
About clothing/body parts for npcs attached to one bone, ogre makes this easy, we use attachObjectToBone() on the entity, provide the bone name and body part, and bam we are done.
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: Making better use of Ogre's capbilities?

Post by Chris »

jhooks1 wrote:I have this working correctly in openmw, for shapes without skins. I don't know if my implementation will help you though. Another creature with NiTriShapes like this is the Ancestor Ghost - the head and jaw.
From what I can tell, you weight unskinned vertices to the last bone index in the skeleton. It still comes out wrong when I do that.

I really think the separate mesh/entity idea is the way to go. It should actually be very simple, since you can load the nif's skeleton once, then specify that one skeleton for each skinned trishape you create a mesh/entity from. For unskinned trishapes, you still get an entity that can be attached to a skeleton bone.
Maybe this is the source of the problem you mentioned?
I doubt it. If I didn't know better, I'd say it was a weighting issue, but it doesn't make sense for it to be.
About clothing/body parts for npcs attached to one bone, ogre makes this easy, we use attachObjectToBone() on the entity, provide the bone name and body part, and bam we are done.
This would fit in very well with taking each trishape as its own entity, since an entity is a MovableObject that can be given to attachObjectToBone.
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: Making better use of Ogre's capbilities?

Post by Chris »

Well, at this point I'm at a loss. I have the mesh appropriately using multiple entities, and have them all sharing one skeleton instance (so you essentially just update the "root" entity's skeleton, and all the "children" entities animate automatically). I also have keyframe interpolation working.

But I still can't get over this mesh problem. I can either get mesh warping with proper animations, or animation warping with a good mesh (which should also show it's not a weighting issue). This is really annoying, and I hate NIFs.
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

Going to try copying some of the concepts from your code into the openmw nifloader. I need to change the bonetrafo to use Matrix44's instead.
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

Tried doing the weighting/skinning the way you do it with Matrix44's. Launched openmw, ash zombie doesn't look right. I am feeding into Matrix44 Ogre::Vector3's and Ogre::Matrix3, perhaps this difference could be causing the problem? Will probably put up the code in a new branch tonight.

I am going to try to compile your code soon, not sure how to link in niflib though.
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

Trying to compile your code. I am using cmake and every time I get an ogre not found message. Does this run on ogre 1.7 or 1.8?
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: Making better use of Ogre's capbilities?

Post by Chris »

jhooks1 wrote:Tried doing the weighting/skinning the way you do it with Matrix44's. Launched openmw, ash zombie doesn't look right. I am feeding into Matrix44 Ogre::Vector3's and Ogre::Matrix3, perhaps this difference could be causing the problem?
A Matrix44 is a 4x4 matrix, so it would be an Ogre::Matrix4. Ogre::Vector3 would match a Vector3, and Ogre::Matrix3 would be Matrix33.
jhooks1 wrote:Trying to compile your code. I am using cmake and every time I get an ogre not found message. Does this run on ogre 1.7 or 1.8?
Ogre 1.8, though it uses pkg-config to look for Ogre and OIS, which probably isn't available on Windows.

I can try copying over OpenMW's FindOGRE and FindOIS scripts, and switch to them.
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: Making better use of Ogre's capbilities?

Post by Chris »

Here's the latest source I have, now:
http://ompldr.org/vZGhwMA/ogre-proj.zip

You might need to edit CMakeLists.txt to change

Code: Select all

INCLUDE_DIRECTORIES(${OGRE_INCLUDE_DIRS} ${OIS_INCLUDE_DIRS} "${CMAKE_SOURCE_DIR}/niflib/include")
LINK_DIRECTORIES("${CMAKE_SOURCE_DIR}/niflib")
to point to where the niflib headers and lib are. And after running cmake, you might need to edit the generated plugins.cfg to set PluginFolder= properly, and resources.cfg to set the data paths properly (sorry for that; never really intended this code to be used as-is by others, let alone on Windows).
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

Having problems.
MSVC complained about
usleep()
boost/thread/tss.hpp missing
____PRETTY_FUNCTION_____
Post Reply