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 »

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?)
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 »

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

There are also a few threads about it, but it's pretty self explanatory.
User avatar
neocryptek
Gnome
Posts: 335
Joined: Sat Mar 01, 2003 11:21 pm
Location: Idaho, USA
Contact:

Post by neocryptek »

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
User avatar
kfields
Gnoblar
Posts: 17
Joined: Wed Jul 14, 2004 4:26 pm

Re: Characters, items and alike + ODE

Post by kfields »

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!
AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon »

....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 :)
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 »

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
AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon »

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...
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
x 7
Contact:

Post by haffax »

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.
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 »

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:
Go Go Gadget OGRE!!
Image
AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon »

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. :)
Hope is the first step on the road to disappointment.
DigitalGhost
Halfling
Posts: 62
Joined: Mon Feb 07, 2005 9:47 pm

Post by DigitalGhost »

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.
AssiDragon
Greenskin
Posts: 145
Joined: Wed Apr 28, 2004 12:10 pm
Location: Hungary
Contact:

Post by AssiDragon »

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. :)
Hope is the first step on the road to disappointment.
Post Reply