Game Development Community

Box2D Integration on Google Code

by Michael Woerister · in Torque Game Builder · 01/23/2009 (6:27 am) · 144 replies

Hi all,

as you may or may not know I created a wrapper for Box2D that let's you use it in TGB through script and behaviors. I wrote my bachelor thesis on this topic and now that it got approved I'd like to share the code with the community.

So here is my question to Garage Games: Is it OK if I put code and thesis up on Google Code (or Sourceforge)? It obviously contains some references to TGB's C++ code base and I don't want break the EULA. But having a public Subversion repository there would make it way easier to maintain the resource.

A few bits of information on the wrapper:
- It requires TGB Pro because Box2D is written in C++.
- It does not silently replace TGB's internal physics engine. It has to be used explicitly.
- It allows for binding t2dSceneObjects to Box2D bodies and shapes.
- I tried to make it as usable as possible in the time I had but it's not for sissies ;)
- It's a good idea to read the thesis to get an overview.

So, what do you say?

-Michael
Page«First 2 3 4 5 6 7 8 Next»
#141
10/27/2011 (6:28 am)
@nadafy - Sorry, I do not have an estimate to provide.
#142
11/01/2011 (9:23 am)
Hi, I am trying to install today and have a few questions that I am sure will pop up...



upon installing the Box2D folder into the directory....
I am asked to
Quote:
Now add the Box2D Visual Studio project to the TGB Solution. To do this right-click on the Solution in the Solution Explorer in Visual Studio and select �Add � Existing Project...�. Browse to the directory
engine/lib/Box2D/Build/VC8 and there select Box2D.vcproj (do not confuse with Box2D.sln).

I am not sure what this means. I use a Mac. I have no such thing as Solution Explorer. Is this Finder? If so, what is the "Solution" equivalent I am supposed to clink on?




Also,
Quote:Next open the Properties of the project TGBGame.
I am unsure of how to do this. Again, I am on a Mac, building for iTGB.
#143
11/01/2011 (10:50 am)
///just as an update. First off I want to say thank you Michael for creating this but a few things.

1. I am on a Mac. Huge problem? (intermediate 2nd yr programmer)
2. I am building for iTGB and the directories have changed. Huge problem? (is for me)
3. I was hoping to read through your example behaviors, but they are dso's. bummer.
4. I have made the changes to source as you suggest, but am stuck.

The following behavior, yielded no visual of the object.


if(!isObject(box2DBodyCreatorBhvr))
{
	%template = new behaviorTemplate(box2DBodyCreatorBhvr);
	
	%template.friendlyName = "box2DBodyCreatorBhvr";
	%template.behaviorType = "Box2D";
	%template.description = "box2DBodyCreatorBhvr";
}
	
function box2DBodyCreatorBhvr::onBehaviorAdd(%this, %sceneGraph)
{
	%this.startAdding();
}

function box2DBodyCreatorBhvr::startAdding(%this)
{
	// Create a body in the Box2D world and its adapter object 
	$BodyRef = $Box2dWorldRef.createBody( %bodyDef, %sceneObject );	
	// Create a definition for the body using dynamic fields 
	%bodyDef = new t2dStaticSprite(man){
		scenegraph = %this.owner.scenegraph;
		image = "dPadPadImageMap";
	}; 
	%bodyDef.Mass = 10; 
	%bodyDef.Inertia = 100;
	%bodyDef.CenterOfMass = "0 0"; 
	%bodyDef.LinearDamping = 0.6; 
	%bodyDef.AngularDamping = 0.7; 
	%bodyDef.AllowSleeping = true; 
	%bodyDef.IsSleeping = false; 
	%bodyDef.FixedRotation = false; 
	%bodyDef.IsBullet = false;
	
	
	echo("box2DBodyCreatorBhvr:: %bodyDef.getName()" @ %bodyDef.getName());
	echo("box2DBodyCreatorBhvr:: %bodyDef.Mass" @ %bodyDef.Mass);	
	echo("box2DBodyCreatorBhvr:: %bodyDef.Inertia" @ %bodyDef.Inertia);	
	echo("box2DBodyCreatorBhvr:: %bodyDef.CenterOfMass" @ %bodyDef.CenterOfMass);	
	echo("box2DBodyCreatorBhvr:: %bodyDef.LinearDamping" @ %bodyDef.LinearDamping);	
	echo("box2DBodyCreatorBhvr:: %bodyDef.AngularDamping" @ %bodyDef.AngularDamping);	
	echo("box2DBodyCreatorBhvr:: %bodyDef.AllowSleeping" @ %bodyDef.AllowSleeping);	
	echo("box2DBodyCreatorBhvr:: %bodyDef.FixedRotation" @ %bodyDef.FixedRotation);	
	echo("box2DBodyCreatorBhvr:: %bodyDef.IsBullet" @ %bodyDef.IsBullet);	
	echo("box2DBodyCreatorBhvr:: %bodyDef.position" @ %bodyDef.position);		
								

	// Create a body in the Box2D world and its adapter object 
	$BodyRef2 = $Box2dWorldRef.createBody( %bodyDef, %sceneObject );

	// The scene graph has a class that creates a Box2D world on // its initialization. The Box2dWorldRef object can then be // accessed through the scene graph. 
	%worldRef = %sceneGraph.getWorldRef();
	// The first parameter of Box2dWorldRef::createBody() is the // body definition object, containing all relevant data in its // dynamic fields. %this fulfills this role. // The second parameter is the t2dSceneObject that should be // bound to 	the Box2D body. By also using %this here the // t2dSceneObject used as definition can be reused as the TGB // representation of the body. 
	%this.bodyRef = %worldRef.createBody( %this);
	
	%this.bodyRef.position = "30 SPC 30";
	%this.bodyRef.size = "45 SPC 45";
	
		
}



Thanks again, any insight is helpful.
Cheers.
::))((
#144
11/03/2011 (9:35 am)
Hey,
I can't really help you there because I don't have a Mac or iTGB. You will probably have to use something like XCode instead of Visual Studio. And you will have to re-compile iTGB with the changes described in the thesis otherwise it won't work.

From the comments in this thread I know that wrapper can be used with iTGB. But I don't know how much additional integration work this involves. Maybe someone else can help you.
Page«First 2 3 4 5 6 7 8 Next»