Raycast vehicle wheels created away from chassis DirectX 11

Post Reply
Atokad75
Posts: 2
Joined: Thu Apr 28, 2016 6:43 pm

Raycast vehicle wheels created away from chassis DirectX 11

Post by Atokad75 »

Hi all. I'm new to bullet and I've been trying to get the Raycast Vehicle demo to work with my DirectX 11 Project. It is currently creating the wheels away from the chassis and I cannot figure out why. Any help would be much appreciated. Attached is the main function code where I create the vehicle, my DirectX game object class, and a screenshot of the output. Thanks in advance.
Attachments
Entity.cpp
Game Entity class
(9.14 KiB) Downloaded 260 times
MyDemoGame.cpp
Where I create the Vehicle.
(29.59 KiB) Downloaded 224 times
DirectX Output
DirectX Output
Capture.PNG (343.8 KiB) Viewed 4196 times
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Raycast vehicle wheels created away from chassis DirectX

Post by benelot »

Does the bullet model work normally? What I have experienced with other graphics engines is that the coordinate system of the bullet model is different from your graphics model. What I mean is that if you tell bullet that something is 2 units wide, then these units are not the same as the ones of your graphics engine. Therefore, if bullet tells you that the wheels are positioned at let us say (0,0,0),(0,0,2),(2,0,0) and (2,0,2), then it might be that placing your graphics objects there might not be correct. Additionally it might be that your graphics object's origin is not at the same point as the bullet objects, meaning that you for instance get the center of mass of the bullet chassis, but your graphics chassis origin is somewhere else.

It might be easiest to fix this using debug output using a debug drawer. It draws a wireframe of your bullet objects into your graphics space, so problems get more obvious. I hope I do not send you into another tough to solve problem, because if the axis definitions and projections of DX11 are totally different, you might get seemingly random output.

Here is the version from Ogre3D, that should give you the framework for it. You can basically delete every content out of the methods and the find out how to implement at least drawLine(...), then you must add your debugdrawer to bullet like this:

Code: Select all

mDebugDrawer = new YourDebugDrawer();
mDebugDrawer->setDebugMode( btIDebugDraw::DBG_DrawWireframe );
dynamicsWorld->setDebugDrawer( mDebugDrawer ); 
To draw, you call the method below (the call will immediately call drawLine() and other methods from your DebugDrawer, so make sure the drawing code you use can be run at the point you call debugDrawWorld()):

Code: Select all

dynamicsWorld->debugDrawWorld()
Here are some DirectX examples that used to work:
http://www.gamedev.net/topic/643993-bul ... ug-drawer/

Have fun debugging!
Atokad75
Posts: 2
Joined: Thu Apr 28, 2016 6:43 pm

Re: Raycast vehicle wheels created away from chassis DirectX

Post by Atokad75 »

benelot wrote:Does the bullet model work normally? What I have experienced with other graphics engines is that the coordinate system of the bullet model is different from your graphics model. What I mean is that if you tell bullet that something is 2 units wide, then these units are not the same as the ones of your graphics engine. Therefore, if bullet tells you that the wheels are positioned at let us say (0,0,0),(0,0,2),(2,0,0) and (2,0,2), then it might be that placing your graphics objects there might not be correct. Additionally it might be that your graphics object's origin is not at the same point as the bullet objects, meaning that you for instance get the center of mass of the bullet chassis, but your graphics chassis origin is somewhere else.

It might be easiest to fix this using debug output using a debug drawer. It draws a wireframe of your bullet objects into your graphics space, so problems get more obvious. I hope I do not send you into another tough to solve problem, because if the axis definitions and projections of DX11 are totally different, you might get seemingly random output.

Here is the version from Ogre3D, that should give you the framework for it. You can basically delete every content out of the methods and the find out how to implement at least drawLine(...), then you must add your debugdrawer to bullet like this:

Code: Select all

mDebugDrawer = new YourDebugDrawer();
mDebugDrawer->setDebugMode( btIDebugDraw::DBG_DrawWireframe );
dynamicsWorld->setDebugDrawer( mDebugDrawer ); 
To draw, you call the method below (the call will immediately call drawLine() and other methods from your DebugDrawer, so make sure the drawing code you use can be run at the point you call debugDrawWorld()):

Code: Select all

dynamicsWorld->debugDrawWorld()
Here are some DirectX examples that used to work:
http://www.gamedev.net/topic/643993-bul ... ug-drawer/

Have fun debugging!
Hello! Thank you for your help so far! After much research, I was able to implement the bullet Debug Draw Lines interface with my project. It has visualized my problem but I am still unsure how to fix it. Attached is a screenshot of my vehicle with the chassis as a sphere for clarity.
Attachments
DebugIssue.PNG
DebugIssue.PNG (381.71 KiB) Viewed 4040 times
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Raycast vehicle wheels created away from chassis DirectX

Post by benelot »

You could post your bullet debug drawer implementation, it might help others to use it as well. Also we could check if you made no mistake there. I heard about some dimension particularities of DirectX (it is a left/right hand coordinate system and bullet is the opposite or similar).

Are the horizontal lines next to the sphere the place where the bullet wheels are and where your graphical wheels are supposed to be? (I mean, how does this vehicle behave when on ground? I first would expect that the units of the dimensions between DirectX and bullet are different, however I also observe that the chassis is below the wheels whereas it should be above. Might be an indication that the vertical, Y-axis of Direct X is inverted to bullet (top-down as opposed to bottom-up.)
Post Reply