Game Development Community

dev|Pro Game Development Curriculum

ODEItem v0.10

by Pascal · 01/04/2004 (1:38 pm) · 130 comments

Edit: 1/9/04 -- updated to 2nd Release w/ multiplayer and a couple more config features (see docs)
You can download the file from HERE (it was too large with the included .lib files for GG)

see the README.html file for complete installation usage instructions.

A number of short engine changes are required to get it working (three have changed since release 1, see docs)

Included are compiled versions of the .lib files for ODE as well as the slightly modified source.

Take a look at the following Movie Zipfile for a demo (I think its compressed with DivX..)

For those of you familiar with ODE I decided to use the torque engine for collision mechanism instead of the one built into ODE. While this is probably a performance hit (or maybe not, I don't really know enough to say) it does make life much easier as any DTS file with collision meshes should work correctly with the rest of the world including the terrain.

The code will need some modifications to make it useful so check out the ODE Homepage for some more info on the engine. I need to do a revamp of the code an clean up my initial confusion a little so I will probably release a new version in a couple of weeks.

Included are a crate and an trash can to get you started.

Have fun throwing crates around (I did)..
My next step is to try to get some rag dolls working but that may be a little while.

-Pascal
Page«First 1 2 3 4 5 6 7 Next»
#121
12/06/2005 (7:28 am)
thanks alot guys ...
i'v tested the ode item. it's really great.

my question is:
what shall i do in order to have the odeitem as my main player (i.e setting the making the odeitem a control object )?????.
#122
04/19/2006 (11:40 pm)
Im confused how would you expose other variable than ERP, CFM, and gravity, where are all the other properties of the object?
#123
06/09/2006 (8:00 am)
I'm in the same boat as Jeff. 35 linker errors. Unresolved externals... Looks like the lib isn't getting linked in properly for whatever reason.

I've tried everything. :(

Anyone have any ideas?

EDIT: Im using Visual Studio 2005 Express.
#124
06/27/2006 (10:17 am)
Im having an issue...

My Items are invisible until I bump them and Jeff's suggestion of adding enabled ="1"; to the datablock didnt change anything.

The shape becomes visible when dBodyEnable(mBodyID); is called in ODEItem::resolveShapeBaseCollision

I tried adding dBodyEnable(mBodyID); to the :onadd function but it didnt make a difference.

Can anyone help me ?
#125
06/29/2006 (6:39 am)
Yes !! It's true !!! I have the same problem !!!

Can anyone help us ??

Thanks

Bye
#126
06/29/2006 (8:20 am)
I fixed it... It was a huge pain in the ass.

I havent cleaned my code yet, so some of these changes might not actually be neccessary...

in bool ODEItem::onAdd()

after
dBodySetMass (mBodyID,&mMass);
	dBodySetLinearVel(mBodyID,mVelocity.x,mVelocity.y,mVelocity.z);
	dBodySetPosition (mBodyID, mDelta.pos.x,
							 mDelta.pos.y,
							 mDelta.pos.z);

add

mIsEnabled = true;

Here's the one that I think actually fixed the issue.

Replace ODEItem::packUpdate with the following:

U32 ODEItem::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
{
	U32 retMask = Parent::packUpdate(con, mask, stream);

    if(stream->writeFlag(mask & (PositionMask | RotationMask))){
		/*if(*/stream->writeFlag(dBodyIsEnabled(mBodyID));/*){*/
		   stream->writeAffineTransform(getTransform());
//		   const dReal *angVel = dBodyGetAngularVel(mBodyID);
//		   stream->writeCompressedPoint(Point3F(angVel[0],angVel[1],angVel[2]));
		   const dReal *vel = dBodyGetLinearVel(mBodyID);
		   stream->writeCompressedPoint(Point3F(vel[0],vel[1],vel[2]));
		/*}*/
	}

	if (stream->writeFlag(mask & PropertyUpdate))
	{
		// Write Object Properties.
		//stream->write(mMass);
		stream->writeCompressedPoint(mObjScale);
        if(stream->writeFlag(mOverride)) {
               stream->write(mFriction1);
               stream->write(mFriction2);
               stream->write(mBounceVel);
               stream->write(mBounce);
        }
	}

	// Were done ...
	return(retMask);
}

Replace ODEItem::unpackUpdate with the following:

void ODEItem::unpackUpdate(NetConnection * con, BitStream * stream)
{
	// Unpack Parent.
   	Parent::unpackUpdate(con, stream);

	//mBreak = stream->readFlag();
/*  if(mBreak && isClientObject()){
    int i =0;
	i++;
  }
*/	if(stream->readFlag()){ //DynamicObjectupdate
		mIsEnabled = stream->readFlag();
			//mIsEnabled = true;
		//if(mIsEnabled){ //is it enabled?
			
			if(mBodyID)
    			dBodyEnable(mBodyID);

			mPredictionCount = 30; //sMaxPredictionTicks;
			QuatF rotation = QuatF(getTransform());
			mDelta.warpRot[0] = rotation;
			F32 speed = mVelocity.len();

			MatrixF		ObjectMatrix;
			stream->readAffineTransform(&ObjectMatrix);
			//stream->readCompressedPoint(&mAngVel);
			stream->readCompressedPoint(&mVelocity);
			rotation = QuatF(ObjectMatrix);

	///RIPPED FROM VEHICLE.CS///////////////
		  if (isProperlyAdded()) {
			 // Determin number of ticks to warp based on the average
			 // of the client and server velocities.
			 Point3F cp = mDelta.pos + mDelta.posVec * mDelta.dt;
			 mDelta.warpOffset = ObjectMatrix.getPosition() - cp;

			 // Calc the distance covered in one tick as the average of
			 // the old speed and the new speed from the server.
			 F32 dt,as = (speed + mVelocity.len()) * 0.5 * TickSec;

			 // Cal how many ticks it will take to cover the warp offset.
			 // If it's less than what's left in the current tick, we'll just
			 // warp in the remaining time.
			 if (!as || (dt = mDelta.warpOffset.len() / as) > 3)//sMaxWarpTicks)
				dt = mDelta.dt + 3;//sMaxWarpTicks;
			 else
				dt = (dt <= mDelta.dt)? mDelta.dt : mCeil(dt - mDelta.dt) + mDelta.dt;

			 // Adjust current frame interpolation
			 if (mDelta.dt) {
				mDelta.pos = cp + (mDelta.warpOffset * (mDelta.dt / dt));
				mDelta.posVec = (cp - mDelta.pos) / mDelta.dt;
				QuatF cr;
				cr.interpolate(mDelta.rot[1],mDelta.rot[0],mDelta.dt);
				mDelta.rot[1].interpolate(cr,rotation,mDelta.dt / dt);
				mDelta.rot[0].extrapolate(mDelta.rot[1],cr,mDelta.dt);
				//mDelta.rot[0] = mDelta.rot[1];
			 }

			 // Calculated multi-tick warp
			 mDelta.warpCount = 0;
			 mDelta.warpTicks = (S32)(mFloor(dt));
			 if (mDelta.warpTicks) {
				mDelta.warpOffset = ObjectMatrix.getPosition() - mDelta.pos;
				mDelta.warpOffset /= mDelta.warpTicks;
				mDelta.warpRot[0] = mDelta.rot[1];
				mDelta.warpRot[1] = rotation;
			 }
		  }
		  else {
			  // Set the object to the server position
			 mDelta.dt  = 0;
			 mDelta.pos = ObjectMatrix.getPosition();
			 mDelta.posVec.set(0,0,0);
			 mDelta.rot[1] = mDelta.rot[0] = rotation;
			 mDelta.warpCount = mDelta.warpTicks = 0;
             Parent::setTransform(ObjectMatrix);
			}
		}else if(mBodyID)
		    dBodyDisable(mBodyID);
	/////////////////////////////////////////////////////
	//}

	// Read Property update Mask Flag.
	if(stream->readFlag())
	{
			
		//stream->read(&mMass);
		stream->readCompressedPoint(&mObjScale);
		//stream->read(&mType);

         if(mOverride = stream->readFlag()) {
               stream->read(&mFriction1);
               stream->read(&mFriction2);
               stream->read(&mBounceVel);
               stream->read(&mBounce);
        }

/*
		dMass mass;
		OdeWorld *world = gClientOdeWorld;
		if(mBodyID){
		   dBodyDestroy(mBodyID);
		}
*/		
		/*if(isServerObject()){ //Add the server objects to the server world.
		   scriptOnAdd();
		   mBodyID = gOdeWorld->addRigidBody();
		   mGeomID = dCreateBox(gOdeWorld->getWorldSpaceID(),mObjScale.x,mObjScale.y,mObjScale.z);
		}else if (isClientObject()){ //Add Client ones to the client world.
		*/
/*		if(mGeomID){
		   dGeomDestroy(mGeomID);
		   mGeomID = 0;
		}
		   
		dBodySetMass(mBodyID,&mass);

		mObjBox.min.set( -0.5*mObjScale.x, -0.5f*mObjScale.y, -0.5*mObjScale.z );
		mObjBox.max.set(  0.5*mObjScale.x, +0.5f*mObjScale.y,  0.5*mObjScale.z );
		// Reset the World Box.
		resetWorldBox();
		// Set the Render Transform.
		setRenderTransform(mObjToWorld);
*/	}
}

Hope that fixes it for you.
#127
07/03/2006 (12:06 am)
Wao !!! Thanks for this !!! Now I test it today !

Bye

^_^
#128
08/27/2006 (9:31 pm)
is there a link for the odeItem-r2.zip the link is broken
#129
11/05/2006 (2:53 pm)
Does anyone have a copy of this that they can host somewhere? I could even host it if need be...

cchambers AT gmail.com <-- hit me up, thanks! :D
#130
12/08/2006 (1:03 pm)
ODEScript Physics Resource.

Works kinda like ODEItem, and kinda not.

Gary (-;
Page«First 1 2 3 4 5 6 7 Next»