dNewton vehicle integration

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

dNewton vehicle integration

Postby Shaderman » Sun May 01, 2016 4:45 am

Hi.

I'm still working on a newton plugin for the ShiVa engine and it looks promising so far. I have almost all collision types and custom joints working and would like to add vehicles now. I've spent several days trying to build on the sdk demo vehicles, but failed.

My attempts were to decouple the vehicle code from all the DemoEntity* code, because I don't need the DemoEntityManager with its wxWidgets stuff for example. Also the DemoEntity class seems to contain too many things I don't need and thus an integration is too hard for me and my C++ skills.

I'm using dNewton for my plugin but besides dNewtonVehicleManager, there doesn't seem to be anything that might be of use for me. Unfortunately this class appears to be outdated and there doesn't seem to be any other dNewton code reflecting the current (and awesome!) vehicle code base.

Julio, are you planning to update or build dNewton based vehicle classes decoupled from the demos which I could try to use? If not, I think my only chance would be to write lots of code and try to make vehicles work with custom joints.

Thanks

Shaderman
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: dNewton vehicle integration

Postby Shaderman » Sun May 01, 2016 6:41 am

Well, I think I've been confused by all the Demo code around CustomVehicleControllerManager and CustomVehicleController. These classes seem to be what I need to build upon myself. I wonder why I didn't study these classes carefully before :roll:
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: dNewton vehicle integration

Postby Julio Jerez » Sun May 01, 2016 8:01 am

I was going to say that you do no nee the DemoEntity you only need to sub class from
CustomVehicleControllerManager.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewton vehicle integration

Postby Shaderman » Sun May 15, 2016 5:54 am

I'm stuck with the vehicle integration and ask for a helping hand once again.

What I'm trying to do is building the vehicle from the basic car demo. I don't need any rendering code or things like keyboard input. What I do need though is the physics side of things and the ability to set translation and rotation of a newton vehicle for scene objects I have in my engine.

I'm currently trying to reduce the basic car demo and removed the dependencies to the demo framework (classes like DemoEntityManager, DemoEntity).
I've reduced the code in BasicCar.cpp and just left code which drives the vehicle with some steering angle once the demo starts. This just makes things clearer for me and should give a working base to build on.

Now I'm trying to make this reduced basic vehicle work with my current newton integration but always run into an unhandled exception in this function:

Code: Select all
dNewtonBody* dNewtonBody::GetParent() const
{   
   return m_parent;
}


I don't understand where this exception comes from and don't know how to debug it in my multithreaded newton setup. I don't think i removed too much code, but don't see the missing piece.

Here's my current code without the car parameters I've copied from the BasicCar.cpp:

http://pastebin.com/eu1rFsxu

Any help is appreciated.

Thanks

Shaderman
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: dNewton vehicle integration

Postby Shaderman » Tue May 17, 2016 3:37 pm

Well the problem I have seems to be related to the DemoEntity code which I'm trying to get around.

To be more precise, I'm having problems finding a solution to work around the last parameter of CustomVehicleControllerManager::CreateVehicle. In the demos, 'this' is passed, which is the BasicCarEntity instance which itself is derived from DemoEntity.

m_controller = manager->CreateVehicle (chassisCollision, chassisMatrix, parameters.VEHICLE_MASS, PhysicsApplyGravityForce, this);

I'd like to stick as close as possible to the sandbox demo code instead of building everything on my own. This would allow faster updates if anything changes.

Any idea how to work around this problem and completely drop the DemoEntity dependencies?

Thanks

Shaderman
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: dNewton vehicle integration

Postby Julio Jerez » Tue May 17, 2016 7:20 pm

Shaderman wrote:In the demos, 'this' is passed, which is the BasicCarEntity instance which itself is derived from DemoEntity.
m_controller = manager->CreateVehicle (chassisCollision, chassisMatrix, parameters.VEHICLE_MASS, PhysicsApplyGravityForce, this);


this is just the user data that is passed in the callbacks. in the Demo is DemoEntity, in your demo is what ever is you gameObject. The in the call back you cast it to you game objects.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewton vehicle integration

Postby Julio Jerez » Fri May 20, 2016 3:59 pm

can you show me the code that you wrote?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewton vehicle integration

Postby Shaderman » Fri May 20, 2016 4:17 pm

I've posted the code to pastebin.

I know it's a lot of code and probably hard to help. So let me explain what I did to simplify things:

- I've copied BasicCar.cpp into my plugin
- I removed functions I don't need right now to make a basic vehicle work.
- I've tested this reduced code base with the sdk demo to make sure it should also work in my plugin.
- I've commented out some lines in the remaining code which I believe aren't required in my plugin (references to the DemoEntity* stuff). These lines are still there to show what I removed.
- I've modified the function parameters for CustomVehicleController::BodyPartTire* AddTire() and added a const char* parameter. This is just a hack to quickly get a reference to the engine tire objects and their matrix (line 127-129).

It probably looks complicated, but that's 99% your code with my changes named above. There's no code yet to update my game objects from the vehicle body and tires. Once it doesn't crash anymore, I can add this visual part.

Thanks for your help Julio.
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: dNewton vehicle integration

Postby Julio Jerez » Fri May 20, 2016 4:21 pm

I will check it out tonight, I can't open file from where I am now.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewton vehicle integration

Postby Shaderman » Fri May 20, 2016 4:39 pm

Thanks Julio and don't rush please.
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: dNewton vehicle integration

Postby Shaderman » Sun Jun 05, 2016 5:39 am

I've not yet given up, but didn't get much closer :roll:

What I can offer though is a simple example derived from a stripped down basic car sdk demo merged into the project tutorial_101_GettingStarted. Stripped down means, I've removed dependencies around DemoEntity, to make the code work without the demo framework.

This example shows the problem I also see in my Shiva engine plugin. It just requires a few smaller changes to the tutorial project in case somebody wants to help.

The problem I see is still the same, I get a crash and the debugger stopps here:

Code: Select all
NewtonBody* dNewtonBody::GetNewtonBody () const
{
   return m_body; <-- crash
}


Here's a example call stack for the calling thread:

Code: Select all
>   tutorial_101_GettingStarted.exe!dNewtonBody::GetParent()  Zeile 275 + 0x3 Bytes   C++
    tutorial_101_GettingStarted.exe!dNewtonTransformManager::UpdateTransformKernel(NewtonWorld * const world=0x016400c0, void * const context=0x01670880, int threadIndex=1)  Zeile 45 + 0x8 Bytes   C++
    tutorial_101_GettingStarted.exe!dgThreadHive::dgThreadBee::RunNextJobInQueue(int threadId=1)  Zeile 98 + 0x12 Bytes   C++
    tutorial_101_GettingStarted.exe!dgThreadHive::dgThreadBee::Execute(int threadId=1)  Zeile 73   C++
    tutorial_101_GettingStarted.exe!dgThread::dgThreadSystemCallback(void * threadData=0x0167c50c)  Zeile 229   C++
    tutorial_101_GettingStarted.exe!ptw32_threadStart(void * vthreadParms=0x01680908)  Zeile 225 + 0x7 Bytes   C
    msvcr100d.dll!_callthreadstartex()  Zeile 314 + 0xf Bytes   C
    msvcr100d.dll!_threadstartex(void * ptd=0x016813c8)  Zeile 297   C
    kernel32.dll!BaseThreadInitThunk()  + 0x24 Bytes   
    [Unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für kernel32.dll]   
    ntdll.dll!RtlInitializeExceptionChain()  + 0x8f Bytes   
    ntdll.dll!RtlInitializeExceptionChain()  + 0x5a Bytes   


The problem starts when the following (required) line is added. When it's comment it out, there's no crash. Looking at the related code and classes, I'm not able to figure out a solution myself :?

Code: Select all
BasicCarEntity* const heavyVehicle = new BasicCarEntity (manager, location, basicCarParameters);


If you want to help and make the example work, extract the two files in the attached zip to applications\tutorialsSDK300\CNewtonTutorials\tutorial_101_GettingStarted.

The project file just contains changes to link with dJointLibrary_d.lib.

Build the solution (Debug) and copy the following files to applications\tutorialsSDK300\CNewtonTutorials\Debug:
- newton_d.dll/pdb
- dNewton_d.dll/pdb
- dContainers_d.dll/pdb
- dJointLibrary.dll/pdb

By the way, I'm using Visual C++ 2010 Express.

Any help is highly appreciated before I'm going nuts with this...

Shaderman
Attachments
main.zip
(7.21 KiB) Downloaded 394 times
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am

Re: dNewton vehicle integration

Postby Shaderman » Sun Jun 19, 2016 5:11 am

Finally I have some success and believe me, it was a looong way to get there.

https://youtu.be/wyUpb9eovGE

The vehicle in the video is driving with a fixed steering and gas pedal value. There are no keyboard controls yet, but at least it's rolling :D
The setup is currently built with fixed values. I hope I can make a customizable setup and controls work with Shiva soon.

Btw I love how the differentials work, awesome job Julio!
Shaderman
 
Posts: 66
Joined: Tue Mar 08, 2016 2:51 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 23 guests

cron