NPC Activation

Everything about development and the OpenMW source code.
Locked
User avatar
lgromanowski
Site Admin
Posts: 1147
Joined: 05 Aug 2011, 22:21
Location: Wroclaw, Poland
Github profile: https://github.com/lgromanowski
Contact:

NPC Activation

Post by lgromanowski » 15 Aug 2011, 09:47

gus wrote: I think i found the cause:
<!-- ia0 -->test.png<!-- ia0 -->
As you can see, the visual representation and the physic representation are not in the same place, which is troublesome.
But the strangest thing it's not only the Z axis. The physic representation is centered on the position of the actor(or at least it should), so that mean that the visual representation isn't. Is it the normal behavior?
Star-Demon wrote: You can actually see the result of this behavior in my videos.

Is the physics node a child of the mesh node?

I would guess it's just offset incorrectly.

Worse yet, it's possible that we're dealing with a problem with the data in nif.

I'd say quick fix is to set the position of the physic representation to 0,0,0 as a child of the entitynode that the mesh is attached to.

or the dumb fix, which is to make the offset center on the player by force. This requires playing with it until it looks good.
Zini wrote: Since physics uses the same code for NPCs and objects; and objects are handled correctly, obviously the NPC rendering code is at fault.
Star-Demon wrote: Good point - but I wonder why would our NPCs be rendered to the rightish?

I guess we'll just have to go back and fix it.
Zini wrote: Regular objects are just a simple mesh (or a hierarchy of meshes). NPCs are constructed via code from various body parts. This code probably has a bug (mixing a center coordinate point with a corner coordinate point or something; I am just guessing here).
gus wrote: But you can also see another problem: the capsuleShape is too low/too small. But I can't really correct that if the visual representation is wrong (as i have to adjust the capsule shape position/size to the visual representation position/size by hand).
Zini wrote: Jhooks wrote the NPC rendering code. Maybe he has an idea what can be done about it.

If everything else fails, we could go for a temporary workaround that at least gives an approximately correct result. IIRC jhooks said, that the NPC rendering code needs a rewrite anyway.
jhooks1 wrote: Yes, the npc rendering code right now works with scenenodes. The proper way to render them would be to instead use the base_anim skeleton.

In order to render them correctly in this method, you must use Entity->attachObjectToBone(). Each body part mesh attaches to the respective bone of the skeleton. You can check out my NPCAnim and animation branches for an example of how this could be implemented.

The problem we have with this new implementation is at the moment we have no way to mirror/reflect the meshes. This means the npc would have two left feet, two left arms, etc. There is an ogre package meshmagick that has what we need to reflect the meshes, but we would have to integrate the library into openmw.

I would recommend not writing physics for the scenenode npcs since we need to start over with skeleton npcs anyway.
Zini wrote: Okay. A quick workaround then. Doesn't have to be perfect, but activating a NPC should be possible without fiddling around. If I understand the situation right, the correct method is to adjust the position of the meshes/the screennode to match that of the physics shape.
gus wrote: I don't have the time to do this task right now. But for testing purpose, just use the debug rendering mode, you will be able to see the true physical shape.
jhooks1 wrote: I don't know anything about bullet or activation, but I will look into this.
Zini wrote: The problem is that either the NPC or the bullet collision shape is not centred on the NPC's coordinates as specified in the world model. I think the consent was that the NPC is misaligned.
best regards,
Lukasz

Locked

Who is online

Users browsing this forum: No registered users and 1 guest