Have fun with JigLibX.
by b2fxna · in Torque X 3D · 12/10/2009 (11:49 pm) · 23 replies
Step by step:
1) In VS new project Starter Game 3D.
2) Check out JigLibX from svn: http://jiglibx.codeplex.com/SourceControl/ListDownloadableCommits.aspx
3) Add JiglibX project to current solution. ( it comes with a dll project, a game project, a heightmap processor, just add the dll project only, the game project is a good reference for integration)
4) Right click upgrade JigLibX if needed ( to 3.1 )
5) In the game add reference, select project, point to JiglibX.
6) Add these 2 files to Game project: J3DRigidComponent.cs, JRigidCollisionManager.cs
7) In game data: levelData.txscene change this:
- RigidManager:
Before: <RigidManager type="GarageGames.Torque.T3D.RigidCollision.RigidCollisionManager" name="RigidManager" />
After: <RigidManager type="JigLibX.Rigid.JRigidCollisionManager" name="RigidManager" />
- Terrain:
Before:
<Components>
<SceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent"/>
<RigidComponent type="GarageGames.Torque.T3D.T3DRigidComponent">
.... collision shape....
</RigidComponent>
</Components>
After:
<Components>
<SceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent">
<SceneGroup>Terrain</SceneGroup>
</SceneComponent>
<TerrainCollision type="JigLibX.Rigid.J3DRigidTerrainComponent">
<SceneGroupName>Terrain</SceneGroupName>
<RigidManager nameRef="RigidManager"/>
</TerrainCollision>
</Components>
8) in Game.cs in BeginRun add 2 func at the last line:
protected override void BeginRun() {
...
TestSimpleBall();
TestSimpleVehicle();
}
9) Here the 2 function:
void TestSimpleBall()
{
JRigidCollisionManager rigidManager =
TorqueObjectDatabase.Instance.FindObject<JRigidCollisionManager>("RigidManager");
TorqueObject ball = new TorqueObject();
ball.Name ="Ball";
T3DSceneComponent ballScene = new T3DSceneComponent();
ballScene.SceneGroup = "Ball";
ballScene.Position = new Vector3(1024, 1024, 400);
ball.Components.AddComponent(ballScene);
T3DSphere ballShape = new T3DSphere();
ballShape.Radius = 1.0f;
ballShape.SceneGroupName = "Ball";
SimpleMaterial material = new SimpleMaterial();
material.TextureFilename = @"dataskiesfront";
ballShape.Material = material;
ball.Components.AddComponent(ballShape);
J3DRigidSphereComponent ballPhysics = new J3DRigidSphereComponent();
ballPhysics.RigidManager = rigidManager;
ballPhysics.Radius = ballShape.Radius;
ballPhysics.SceneGroupName = "Ball";
ball.Components.AddComponent(ballPhysics);
TorqueObjectDatabase.Instance.Register(ball);
}
void TestSimpleVehicle()
{
JRigidCollisionManager rigidManager =
TorqueObjectDatabase.Instance.FindObject<JRigidCollisionManager>("RigidManager");
SimpleMaterial material = new SimpleMaterial();
material.TextureFilename = @"dataskiesfront";
String name = "body";
TorqueObject body = new TorqueObject();
body.Name = name;
T3DSceneComponent bodyScene = new T3DSceneComponent();
bodyScene.SceneGroup = name;
bodyScene.Position = new Vector3(1024, 1024, 300);
body.Components.AddComponent(bodyScene);
T3DBox bodyShape = new T3DBox();
bodyShape.SceneGroupName = name;
bodyShape.Size = new Vector3(1.0f, 1.0f, 1.0f);
bodyShape.Material = material;
body.Components.AddComponent(bodyShape);
J3DRigidVehicleComponent physics = new J3DRigidVehicleComponent();
physics.SceneGroupName = name;
physics.RigidManager = rigidManager;
body.Components.AddComponent(physics);
TorqueObjectDatabase.Instance.Register(body);
//-----------------------------------------------
name = "brWheel";
TorqueObject brWheel = new TorqueObject();
brWheel.Name = name;
T3DSceneComponent brWheelSceneComponent = new T3DSceneComponent();
brWheelSceneComponent.SceneGroup = name;
brWheel.Components.AddComponent(brWheelSceneComponent);
T3DSphere brWheelBody = new T3DSphere();
brWheelBody.Material = material;
brWheelBody.SceneGroupName = name;
brWheelBody.Radius = 0.4f;
brWheel.Components.AddComponent(brWheelBody);
TorqueObjectDatabase.Instance.Register(brWheel);
//-----------------------------------------------
name = "frWheel";
TorqueObject frWheel = new TorqueObject();
frWheel.Name = name;
T3DSceneComponent frWheelSceneComponent = new T3DSceneComponent();
frWheelSceneComponent.SceneGroup = name;
frWheel.Components.AddComponent(frWheelSceneComponent);
T3DSphere frWheelBody = new T3DSphere();
frWheelBody.Material = material;
frWheelBody.SceneGroupName = name;
frWheelBody.Radius = 0.4f;
frWheel.Components.AddComponent(frWheelBody);
TorqueObjectDatabase.Instance.Register(frWheel);
//-----------------------------------------------
name = "blWheel";
TorqueObject blWheel = new TorqueObject();
blWheel.Name = name;
T3DSceneComponent blWheelSceneComponent = new T3DSceneComponent();
blWheelSceneComponent.SceneGroup = name;
blWheel.Components.AddComponent(blWheelSceneComponent);
T3DSphere blWheelBody = new T3DSphere();
blWheelBody.Material = material;
blWheelBody.SceneGroupName = name;
blWheelBody.Radius = 0.4f;
blWheel.Components.AddComponent(blWheelBody);
TorqueObjectDatabase.Instance.Register(blWheel);
//-----------------------------------------------
name = "flWheel";
TorqueObject flWheel = new TorqueObject();
flWheel.Name = name;
T3DSceneComponent flWheelSceneComponent = new T3DSceneComponent();
flWheelSceneComponent.SceneGroup = name;
flWheel.Components.AddComponent(flWheelSceneComponent);
T3DSphere flWheelBody = new T3DSphere();
flWheelBody.Material = material;
flWheelBody.SceneGroupName = name;
flWheelBody.Radius = 0.4f;
flWheel.Components.AddComponent(flWheelBody);
TorqueObjectDatabase.Instance.Register(flWheel);
physics.BRWheel = brWheelSceneComponent;
physics.FRWheel = frWheelSceneComponent;
physics.BLWheel = blWheelSceneComponent;
physics.FLWheel = flWheelSceneComponent;
}
10)in FreeCameraComponent add this to protected virtual void _SetupInputMap()
// V:Gas B:Brake N:Left M:Right
_inputMap.BindMove(keyboardId, (int)Keys.V, MoveMapTypes.TriggerDigital, 0);
_inputMap.BindMove(keyboardId, (int)Keys.B, MoveMapTypes.TriggerDigital, 1);
_inputMap.BindMove(keyboardId, (int)Keys.N, MoveMapTypes.StickDigitalLeft, 2);
_inputMap.BindMove(keyboardId, (int)Keys.M, MoveMapTypes.StickDigitalRight, 2);
11) in FreeCamera add Gas and Turn.
public float Gas = 0;
public float Turn = 0;
public void ProcessTick(Move move, float elapsed)
{
if (move == null)
return;
Gas = move.Triggers[0].Value - move.Triggers[1].Value;
Turn = -move.Sticks[2].X;
That is it. Run the game now and you can enjoy JiblibX.
Files:
Game.cs _http_://www.mediafire.com/?zyjzndxattn
J3DRigidComponent.cs _http_://www.mediafire.com/?tnlgvbojw2z
JRigidManager.cs _http_://www.mediafire.com/?jmzmgvy4jyd
level _http_://www.mediafire.com/?d3zmnm4nzw4
1) In VS new project Starter Game 3D.
2) Check out JigLibX from svn: http://jiglibx.codeplex.com/SourceControl/ListDownloadableCommits.aspx
3) Add JiglibX project to current solution. ( it comes with a dll project, a game project, a heightmap processor, just add the dll project only, the game project is a good reference for integration)
4) Right click upgrade JigLibX if needed ( to 3.1 )
5) In the game add reference, select project, point to JiglibX.
6) Add these 2 files to Game project: J3DRigidComponent.cs, JRigidCollisionManager.cs
7) In game data: levelData.txscene change this:
- RigidManager:
Before: <RigidManager type="GarageGames.Torque.T3D.RigidCollision.RigidCollisionManager" name="RigidManager" />
After: <RigidManager type="JigLibX.Rigid.JRigidCollisionManager" name="RigidManager" />
- Terrain:
Before:
<Components>
<SceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent"/>
<RigidComponent type="GarageGames.Torque.T3D.T3DRigidComponent">
.... collision shape....
</RigidComponent>
</Components>
After:
<Components>
<SceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent">
<SceneGroup>Terrain</SceneGroup>
</SceneComponent>
<TerrainCollision type="JigLibX.Rigid.J3DRigidTerrainComponent">
<SceneGroupName>Terrain</SceneGroupName>
<RigidManager nameRef="RigidManager"/>
</TerrainCollision>
</Components>
8) in Game.cs in BeginRun add 2 func at the last line:
protected override void BeginRun() {
...
TestSimpleBall();
TestSimpleVehicle();
}
9) Here the 2 function:
void TestSimpleBall()
{
JRigidCollisionManager rigidManager =
TorqueObjectDatabase.Instance.FindObject<JRigidCollisionManager>("RigidManager");
TorqueObject ball = new TorqueObject();
ball.Name ="Ball";
T3DSceneComponent ballScene = new T3DSceneComponent();
ballScene.SceneGroup = "Ball";
ballScene.Position = new Vector3(1024, 1024, 400);
ball.Components.AddComponent(ballScene);
T3DSphere ballShape = new T3DSphere();
ballShape.Radius = 1.0f;
ballShape.SceneGroupName = "Ball";
SimpleMaterial material = new SimpleMaterial();
material.TextureFilename = @"dataskiesfront";
ballShape.Material = material;
ball.Components.AddComponent(ballShape);
J3DRigidSphereComponent ballPhysics = new J3DRigidSphereComponent();
ballPhysics.RigidManager = rigidManager;
ballPhysics.Radius = ballShape.Radius;
ballPhysics.SceneGroupName = "Ball";
ball.Components.AddComponent(ballPhysics);
TorqueObjectDatabase.Instance.Register(ball);
}
void TestSimpleVehicle()
{
JRigidCollisionManager rigidManager =
TorqueObjectDatabase.Instance.FindObject<JRigidCollisionManager>("RigidManager");
SimpleMaterial material = new SimpleMaterial();
material.TextureFilename = @"dataskiesfront";
String name = "body";
TorqueObject body = new TorqueObject();
body.Name = name;
T3DSceneComponent bodyScene = new T3DSceneComponent();
bodyScene.SceneGroup = name;
bodyScene.Position = new Vector3(1024, 1024, 300);
body.Components.AddComponent(bodyScene);
T3DBox bodyShape = new T3DBox();
bodyShape.SceneGroupName = name;
bodyShape.Size = new Vector3(1.0f, 1.0f, 1.0f);
bodyShape.Material = material;
body.Components.AddComponent(bodyShape);
J3DRigidVehicleComponent physics = new J3DRigidVehicleComponent();
physics.SceneGroupName = name;
physics.RigidManager = rigidManager;
body.Components.AddComponent(physics);
TorqueObjectDatabase.Instance.Register(body);
//-----------------------------------------------
name = "brWheel";
TorqueObject brWheel = new TorqueObject();
brWheel.Name = name;
T3DSceneComponent brWheelSceneComponent = new T3DSceneComponent();
brWheelSceneComponent.SceneGroup = name;
brWheel.Components.AddComponent(brWheelSceneComponent);
T3DSphere brWheelBody = new T3DSphere();
brWheelBody.Material = material;
brWheelBody.SceneGroupName = name;
brWheelBody.Radius = 0.4f;
brWheel.Components.AddComponent(brWheelBody);
TorqueObjectDatabase.Instance.Register(brWheel);
//-----------------------------------------------
name = "frWheel";
TorqueObject frWheel = new TorqueObject();
frWheel.Name = name;
T3DSceneComponent frWheelSceneComponent = new T3DSceneComponent();
frWheelSceneComponent.SceneGroup = name;
frWheel.Components.AddComponent(frWheelSceneComponent);
T3DSphere frWheelBody = new T3DSphere();
frWheelBody.Material = material;
frWheelBody.SceneGroupName = name;
frWheelBody.Radius = 0.4f;
frWheel.Components.AddComponent(frWheelBody);
TorqueObjectDatabase.Instance.Register(frWheel);
//-----------------------------------------------
name = "blWheel";
TorqueObject blWheel = new TorqueObject();
blWheel.Name = name;
T3DSceneComponent blWheelSceneComponent = new T3DSceneComponent();
blWheelSceneComponent.SceneGroup = name;
blWheel.Components.AddComponent(blWheelSceneComponent);
T3DSphere blWheelBody = new T3DSphere();
blWheelBody.Material = material;
blWheelBody.SceneGroupName = name;
blWheelBody.Radius = 0.4f;
blWheel.Components.AddComponent(blWheelBody);
TorqueObjectDatabase.Instance.Register(blWheel);
//-----------------------------------------------
name = "flWheel";
TorqueObject flWheel = new TorqueObject();
flWheel.Name = name;
T3DSceneComponent flWheelSceneComponent = new T3DSceneComponent();
flWheelSceneComponent.SceneGroup = name;
flWheel.Components.AddComponent(flWheelSceneComponent);
T3DSphere flWheelBody = new T3DSphere();
flWheelBody.Material = material;
flWheelBody.SceneGroupName = name;
flWheelBody.Radius = 0.4f;
flWheel.Components.AddComponent(flWheelBody);
TorqueObjectDatabase.Instance.Register(flWheel);
physics.BRWheel = brWheelSceneComponent;
physics.FRWheel = frWheelSceneComponent;
physics.BLWheel = blWheelSceneComponent;
physics.FLWheel = flWheelSceneComponent;
}
10)in FreeCameraComponent add this to protected virtual void _SetupInputMap()
// V:Gas B:Brake N:Left M:Right
_inputMap.BindMove(keyboardId, (int)Keys.V, MoveMapTypes.TriggerDigital, 0);
_inputMap.BindMove(keyboardId, (int)Keys.B, MoveMapTypes.TriggerDigital, 1);
_inputMap.BindMove(keyboardId, (int)Keys.N, MoveMapTypes.StickDigitalLeft, 2);
_inputMap.BindMove(keyboardId, (int)Keys.M, MoveMapTypes.StickDigitalRight, 2);
11) in FreeCamera add Gas and Turn.
public float Gas = 0;
public float Turn = 0;
public void ProcessTick(Move move, float elapsed)
{
if (move == null)
return;
Gas = move.Triggers[0].Value - move.Triggers[1].Value;
Turn = -move.Sticks[2].X;
That is it. Run the game now and you can enjoy JiblibX.
Files:
Game.cs _http_://www.mediafire.com/?zyjzndxattn
J3DRigidComponent.cs _http_://www.mediafire.com/?tnlgvbojw2z
JRigidManager.cs _http_://www.mediafire.com/?jmzmgvy4jyd
level _http_://www.mediafire.com/?d3zmnm4nzw4
About the author
#2
12/11/2009 (9:09 am)
I cannot list everything to compare. But for me JiglibX has vehicle physics, and TX doesnt have for now. Even the vehicle physics it has is very simple, but it is good enough for my gameplay prototype.
#3
12/11/2009 (6:47 pm)
Thanks, that was all I was looking for. I knew there must have been something that made you go to that effort and I was wondering what that was!
#5
12/19/2009 (6:12 pm)
seems like the co-ordinate systems are different? I replace the box car with a model and it rolls away, sideways. The tires roll like flipping coins! this will be interesting to figure out.
#6
dts car model ( x,y,z - width, length, height)
jiglibX car model ( x,y,z - length, height, width)
for me I just rotate the dts car model -90 deg around Z.
12/22/2009 (10:45 am)
that is true. you have to play around with the conversion between 2 systems.dts car model ( x,y,z - width, length, height)
jiglibX car model ( x,y,z - length, height, width)
for me I just rotate the dts car model -90 deg around Z.
#7
02/28/2010 (10:17 am)
Apologies for bumping this topic, but does anyone happen to have a copy of the files mentioned at the end of the post? The links appear to be broken now.
#8
03/06/2010 (8:26 am)
Again, sorry for the bump, but I'd really appreciate it if someone could re-upload or send me these files.
#9
03/06/2010 (1:58 pm)
The issue is they are not my files, they belong to b2fxna and while I have them apparently he has removed them for some reason. I really wouldn't feel comfortable sharing whats really not mine.
#10
03/06/2010 (2:41 pm)
That's fair enough. I sort of posted in hopes that he might respond to this personally, as I can't seem to find his contact information elsewhere.
#11
03/06/2010 (9:31 pm)
sorry for late reply, but i also dont have these files any more, @Henry please upload it somewhere if you still have the files, i hope that can help zoid.
#12
smokinskull.com/game.zip
03/07/2010 (11:39 am)
Here is the entire game folder, just make a new game remove the game folder and replace it with this one and all is well.smokinskull.com/game.zip
#13
03/07/2010 (12:03 pm)
Thank you VERY much guys - I really appreciate this!
#14
Thanks...
04/30/2010 (7:22 pm)
Sorry to bug you guys about this, but I am trying to do the same integration and I am missing the files: J3DRigidComponent.cs, JRigidCollisionManager.cs. Does anyone know where I can get these files? It looks like the links in here are all dead.Thanks...
#15
04/30/2010 (8:24 pm)
Sorry I tossed the file off my server when cleaning stuff out, it's back now.
#16
04/30/2010 (8:26 pm)
@Henry... Thank you
#17
Would the community like to see Torque X 3D officially move to something like JigLibX?
07/31/2010 (7:46 pm)
Sorry to bump this old thread, but how well does JigLibX perform compared to stock Torque X 3D physics?Would the community like to see Torque X 3D officially move to something like JigLibX?
#18
08/01/2010 (3:39 am)
i vote for a yes :), it is not a completed physics package for indie, you still need to get your hand dirty to get it up, but it is a good start point to add physics components: vehicle components, rag-doll components after that user just add them through editor and set parameters...
#19
Anyone use this?
08/01/2010 (6:36 am)
I came across BepuPhysics today and it seems to be the best thing out there.... mainly that it has a multithreaded solver.Anyone use this?
#20
08/01/2010 (10:07 am)
@Tom: I don't know BepuPhysics, but reading the site it's not a free lib one can integrate, it carries a royalty based license.
Torque Owner Trent
To be honest, I know very little about physics other than what I learnt at school (F=MA and a few other simple forumlas), I realise you're probably not affiliated with JigLibX, but can you tell me what it does that Torque phyiscs doesn't (not asking for anything complex here)?