Characters, items and alike + ODE

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Characters, items and alike + ODE

Post by AssiDragon » Sat Feb 12, 2005 2:26 am

Let's say I have a character, and I equip an item onto him. I need the item to have it's own ODE body and geom, because collisions with other characters of the item is a must-have (say it's a sword).

How do you "glue" the sword into the wielder's hand? Make a joint or update the position of the sword's SceneNode frame by frame so it keeps nicely to the hand of the character that holds it? (The 2nd one sounds as a light hack to me, but in larger scale it shouldn't be as expensive to ODE as many joints no?)
0 x
Hope is the first step on the road to disappointment.

Lodes
Google Summer of Code Student
Google Summer of Code Student
Posts: 228
Joined: Mon Mar 17, 2003 12:02 am
Location: San Jose, CA, USA

Post by Lodes » Sat Feb 12, 2005 2:54 am

http://www.ogre3d.org/docs/api/html/cla ... 1Entitya20

There are also a few threads about it, but it's pretty self explanatory.
0 x

User avatar
neocryptek
Gnome
Posts: 335
Joined: Sat Mar 01, 2003 11:21 pm
Location: Idaho, USA
Contact:

Post by neocryptek » Sat Feb 12, 2005 2:56 am

How about attaching the sword entity to the wrist bone in the skeleton of the character model?

Check out Ogre::Entity::attachObjectToBone()

Not sure what that would do physics wise, I assume you can disable collision between character<->sword so they wouldnt be fighting.

Havent used it, but might work nicely.

Edit: bah, beaten by Lodes
0 x

User avatar
kfields
Gnoblar
Posts: 17
Joined: Wed Jul 14, 2004 4:26 pm

Re: Characters, items and alike + ODE

Post by kfields » Sat Feb 12, 2005 11:29 pm

AssiDragon wrote:Let's say I have a character, and I equip an item onto him. I need the item to have it's own ODE body and geom, because collisions with other characters of the item is a must-have (say it's a sword).
The easiest way is to attach the sword geom to the hand's body.
You will first need to detach it from the sword body though, and delete the sword body afterwards.

The architecture I am working on will try to hide details such as these.

Hope this helps!
0 x

AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon » Sun Feb 13, 2005 10:19 pm

....I know about OGRE attaching and detaching, thanks - but so far noone brought me a bit closer...

The problem is attached objects via ODE in OgreODE don't act attached. I mean, even if you have SceneNode* B attached to SceneNode* A, B won't keep to A's position, but will move on it's own as two totally seperate bodies. I understand that ODE supports no such "attaching", as in physical simulation needs joints or some other method I don't know of. The question was aimed at "how to make this work with ODE too". Thanks :)
0 x
Hope is the first step on the road to disappointment.

tisba
Kobold
Posts: 37
Joined: Sun Jan 26, 2003 1:17 am
Location: France (Paris)

Post by tisba » Sun Feb 13, 2005 11:09 pm

Can't you make the sword and the wieder appears as a single body to ODE, instead of trying to attach one body to the other ? May be this could be done with composite geom (don't if ODE support this though).

--tisba
0 x

AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon » Sun Feb 13, 2005 11:23 pm

But then how do you know if the sword hit the target (health damage has to be done) or if the player body touched it (no damage)? Things might even get complicated if you introduce shields.

Might be lame but only this example popped into my mind...
0 x
Hope is the first step on the road to disappointment.

User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
Contact:

Post by haffax » Sun Feb 13, 2005 11:59 pm

You probably want to use a ball joint between the player's hand and the weapon. Through the force these two add to each other you can set the stiffness of this setup and you are able to see what other bodies/geoms the sword hits. I never used it this way and I'm sure it needs much polishing to work as expected, but it will work eventually.
0 x
team-pantheon programmer
creators of Rastullahs Lockenpracht

User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber » Mon Feb 14, 2005 3:21 am

indeed... would probably be really difficult. even if you get the bodies attached, you then have to try and "animate" the bodies through forces, to mimick your object's animation.

I don't think any action games (expecially 3rd person) actually check if the sword has hit the enemy on a micro-level. I think they just check the frame of current animation, and from that know a "hot zone" which is where the sword is in that frame. if an enemy is within that zone, it gets hit.

personally I think trying to let the physics do something on this level is a bit over-kill.

however I don't know what kind of game your making... a 1-on-1 sword fighting game might be really cool with truly acurate physics like you describe... :wink:
0 x
Go Go Gadget OGRE!!
Image

AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon » Mon Feb 14, 2005 8:47 am

tanis wrote:You probably want to use a ball joint between the player's hand and the weapon. Through the force these two add to each other you can set the stiffness of this setup and you are able to see what other bodies/geoms the sword hits. I never used it this way and I'm sure it needs much polishing to work as expected, but it will work eventually.
Yay thanks! Will try it =)
walaber wrote:indeed... would probably be really difficult. even if you get the bodies attached, you then have to try and "animate" the bodies through forces, to mimick your object's animation.
Hmm... when the bone changes position using the skeletal system, the joint body in the physic engine also has to follow it... well, I'd think it should. Need to check it lol.
If everything else failsI can just manually update the position and rotation of the weapon anyway. :)
walaber wrote:I don't think any action games (expecially 3rd person) actually check if the sword has hit the enemy on a micro-level. I think they just check the frame of current animation, and from that know a "hot zone" which is where the sword is in that frame. if an enemy is within that zone, it gets hit.
Hmm.
That would need either setting a hotzone to every attack animations' every frame, or constant raycasting from the possible hit zones Either way, it has to be done taking account the used weapons' lenght, and you would still have to check not only "if the enemy is within the zone" though, as you still want to know if a shield, a sword in defensive position or other object-for-the-purpose defended the attacked entity...
walaber wrote:personally I think trying to let the physics do something on this level is a bit over-kill.
Um why? This adds 1 or 2 objects per character maximum, and the same number of joints. And I already have to use physics for weapons - ranged ones to be more precise - so I dont think making this approach would put much extra pressure onto ODE. I could wrong though. :)
0 x
Hope is the first step on the road to disappointment.

DigitalGhost
Halfling
Posts: 62
Joined: Mon Feb 07, 2005 9:47 pm
Contact:

Post by DigitalGhost » Mon Feb 14, 2005 8:23 pm

I think ODE might be overklil for this because you don't really care about the linear/angular velocities. Basically, you can just check if the bounding rectangle of the weapon intersects with the player, and if it does, calculate a hit.

The problem with using ODE is that now you have to keep tweaking your animation so thtat the character swings his arm fast enough to knock the other player down, and stuff like that. It can get really ugly.

However, if you are willing to put the effort into it, it could turn out really cool.

I'm also working on a fighting game and I plan on using Ogre with ODE and stuff like that. If you want to work together, lemme know. I want to make an engine similar to soul calibar, where you always face the enemy and can circle strafe and stuff like that.
0 x

AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon » Mon Feb 14, 2005 9:39 pm

DigitalGhost wrote:I think ODE might be overklil for this because you don't really care about the linear/angular velocities. Basically, you can just check if the bounding rectangle of the weapon intersects with the player, and if it does, calculate a hit.
Actually, I don't want to care about velocities. :) However, ODE does automatically check for bounding intersections and OgreODE has a nice callback function when intersection takes place - I don't want to reinvent the wheel...
DigitalGhost wrote:However, if you are willing to put the effort into it, it could turn out really cool.
Thanks! Hope you'll be right. Same to you. :)
DigitalGhost wrote:I'm also working on a fighting game and I plan on using Ogre with ODE and stuff like that. If you want to work together, lemme know. I want to make an engine similar to soul calibar, where you always face the enemy and can circle strafe and stuff like that.
Well, thanks, but I have to decline this offer. I'm working on my game for quite a while now, and have a working game engine - well, more or less working, alright. :)
0 x
Hope is the first step on the road to disappointment.

Post Reply