Not understanding a piece of RayCastCar code

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Not understanding a piece of RayCastCar code

Postby Auradrummer » Mon Feb 09, 2009 4:56 pm

Hello guys,

I noticed that the function SubmitConstrainst is called every time, but I'm not found the calling anywhere. How can it be?
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Not understanding a piece of RayCastCar code

Postby Julio Jerez » Tue Feb 10, 2009 12:45 am

that's a callback called by the engine. you do not call it yourself
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Not understanding a piece of RayCastCar code

Postby Auradrummer » Tue Feb 10, 2009 6:58 pm

I'm still studying the raycast code here, I want to understand it completely, so I can implement some weird things I want (like mechanical failures to the car during race). If I have another thing I can't understand I'll bother you again :wink: . Thanks!
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Not understanding a piece of RayCastCar code

Postby Auradrummer » Wed Feb 11, 2009 1:11 pm

Let's me explain one thing before proceed: all my difficulties is because I'm not using Newton as renderer, I'm using it only to manage physics. So, I cannot use the exact code that comes with the example, I have to make some interfaces that are very hard for me, that am a beginner.

But I'm advancing, the graphic tires are following the physical ones. But I'm with another problem. Originally, when I put some torque over the car, it spins crazy. I deduced that the torque was being set in side of rear wheels instead of in its heading. So, I searched some place in code where torque is applied, and I found these lines:

Code: Select all
line 400          m_chassisForce += chassisMatrix.m_front.Scale (tire.m_torque * - 40);
line 402          m_chassisForce += chassisMatrix.m_right.Scale(tire.m_turnforce * 60);


I thought that is the place where torque is applied. So, I exchanged the 'm_right' and 'm_front' vectors. The car, now moves forward. But, when I try to move it backwards it go shaking. I made something wrong?
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Not understanding a piece of RayCastCar code

Postby Dave Gravel » Thu Feb 12, 2009 1:22 am

You have surely a old beta because I have change this code part, the lines that you show at 400 and 402 is changed now...
You need to understand this vehicle is a raycast it don't have real tire.
The tire is totally a simulated effect and it is not a real body it don't have any real contact.
It behaving like a air hockey game, http://images.google.com/images?q=air%2 ... =fr&tab=wi

The torque that you can find in the code is only a simulation to simulate the visual tire rotation mesh, but the tire in self don't rotate at all.
Imagine a vehicle floating like the air hockey puck but the chassis rotation is limited by some magical force, like a joint can do...
In reallity the torque is apply on the tire position like a stabilizator to stabilize the final chassis movement.
In final a force is mix with this toque at the tire position for push the vehicle chassis to make it sliding,floating on air like a real acceleration effect.

All force and torque, velocity, omega, and the joint all is based on the chassis matrix and on the tire suspenssion matrix and on the tire pos.
If you start to change some direction in the code for try to fix your problem, you have real chances to scrap all in final...
The best is to use the default code setup, and at place to change direction in the code change your vehicle mesh collision direction.
You can do this with 3d modeler or use the offsetmatrix, to fix your chassis direction with the default code setup.
When you get it right after it's a lot more simple to rotate and place your vehicle in any direction and position...

by Julio Jerez » Mon Feb 09, 2009 11:45 pm
that's a callback called by the engine. you do not call it yourself


Some callback can come called by yourself exemple with material but it is really rare, and you need to call it in a other callback with the same type.
Or maybe i'm wrong here, I have already do this in old version maybe now it's not possible with new version.
In reallity you only need to assign it on a pointer or with a newton command.


Good luck.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Not understanding a piece of RayCastCar code

Postby Auradrummer » Thu Feb 12, 2009 7:22 am

Ok Dave, is really a totally new concept of making a car, and I faced great difficulties, that are slowly going away. I'll downloaded another copy of Newton Dynamics to make some tries. I think 75% of the code are understood now. Working hard for the next 25%.

Thanks a lot for your good post! :D
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Not understanding a piece of RayCastCar code

Postby Auradrummer » Thu Feb 12, 2009 7:56 am

Hey, I just compiled the demos. The only thing I had to fix is adding the -pthread instruction in the LIBS.

Look how strange is the Raycast cars...
http://img120.imageshack.us/my.php?image=capturadatelanewtonarchde5.png
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Not understanding a piece of RayCastCar code

Postby Julio Jerez » Thu Feb 12, 2009 8:24 am

you have an older sdk, you need to download this one.
http://www.newtondynamics.com/downloads ... n-2.00.rar
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Not understanding a piece of RayCastCar code

Postby Auradrummer » Thu Feb 12, 2009 8:27 am

PAGE NOT FOUND.
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Not understanding a piece of RayCastCar code

Postby Julio Jerez » Thu Feb 12, 2009 9:19 am

Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Not understanding a piece of RayCastCar code

Postby Auradrummer » Thu Feb 12, 2009 12:41 pm

Same problem ... could be some definition of Linux?
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Not understanding a piece of RayCastCar code

Postby Auradrummer » Thu Feb 12, 2009 1:08 pm

I solved here the problem of the car shaking when goes rear. Was the Center of Mass Offset. With a 0.6f the car was raising the front when torque is set and was too heavy to raise when car goes back. I think I could solve this by tunning the suspension. But, problem solved anyway.
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Not understanding a piece of RayCastCar code

Postby Dave Gravel » Thu Feb 12, 2009 1:15 pm

With a 0.6f

Use lower value exemple 0.06 and reduce the friction a lot something like 0.5
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Not understanding a piece of RayCastCar code

Postby Auradrummer » Thu Feb 12, 2009 1:22 pm

Ok. Now I'm using your custom RayCast car (that DG is from David Gravel, right?).

I'm proceeding with the adaptations of your code to my needs here, let's see what will happens...
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 33 guests

cron