DG Car question

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

DG Car question

Postby VeT » Mon Jun 22, 2009 12:22 pm

I have a full working code of NewtonVechicle, wich works with 1.53 version in GameStudio... now, i'm trying to make DGCar work in the same way... so, i tride
Code: Select all
 
   NewtonBody* car_body = newton_addentity(me, 1300, NEWTON_CONVEXHULL, onforceandtorque);
   NewtonBodySetLinearDamping(car_body,0.005);
   
   NewtonBodyGetMatrix(car_body,&tire_offset);
   NewtonJoint* car_joint = DGRaycastVehicleCreate(4, &tire_offset, car_body);
   
   
      
   FLwheelPtr = ent_create("WheelL.mdl",nullvector,NULL);
   vec_for_bone(tirepos,me,"FLBone");
   vec_sub(tirepos,my.x);
   D3DXMatrixTranslation(&tire_offset1, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);
   DGRaycastVehicleAddTire(car_joint,FLwheelPtr,&tire_offset1,20,0.35,0.3,1.1,0.25,60,5,1);
   
   FLwheelPtr = ent_create("WheelR.mdl",nullvector,NULL);
   vec_for_bone(tirepos,me,"FRBone");
   vec_sub(tirepos,my.x);
   D3DXMatrixTranslation(&tire_offset2, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);
   DGRaycastVehicleAddTire(car_joint,FRwheelPtr,&tire_offset2,20,0.35,0.3,1.1,0.25,60,5,1);
   
   FLwheelPtr = ent_create("WheelL.mdl",nullvector,NULL);
   vec_for_bone(tirepos,me,"BLBone");
   vec_sub(tirepos,my.x);
   D3DXMatrixTranslation(&tire_offset3, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);
   DGRaycastVehicleAddTire(car_joint,BLwheelPtr,&tire_offset3,20,0.35,0.3,1.1,0.25,60,5,1);
   
   FLwheelPtr = ent_create("WheelR.mdl",nullvector,NULL);
   vec_for_bone(tirepos,me,"BRBone");
   vec_sub(tirepos,my.x);
   D3DXMatrixTranslation(&tire_offset4, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);
   DGRaycastVehicleAddTire(car_joint,BRwheelPtr,&tire_offset4,20,0.35,0.3,1.1,0.25,60,5,1);


but now car falls down and starts to move in the left direction.

here it falls
Image

here it begin to move (blue is a place, where it falls)
ImageImage

in addition, in v1.53 i could see wheels in the debug (wich just runs through all bodies), in DGCar i canlt see them at all (as at the first picture).. i didnt add a visualisation of wheels, but i think i would be able to see it in the debug mode
ImageImage

looking like i'm missing something
1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy
LiteC+Newton2 download: http://hosted.filefront.com/NeArGa
LiteC+Newton2 discussion: http://tinyurl.com/6l7y9v
VeT
 
Posts: 84
Joined: Thu Jul 31, 2008 11:31 am

Re: DG Car question

Postby Julio Jerez » Mon Jun 22, 2009 1:02 pm

I have seen peopel having thsi roenetaion problems before,
what direction the car point too?

I think we need to start a series of toturial in the wiki.
Now that Delfi updated it, I will go updation teh torurial becaus etehya are too old, and do not mach exactlu how sdk 2.0 should work.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: DG Car question

Postby VeT » Mon Jun 22, 2009 2:05 pm

This happens with any direction of the car... after creating, and before Newton initializing, i rotate car's pan at 90,180,270 angles but result is the same: it rolls to the left

about tutorials: you're right, its hard to learn Newton almost without documentation :)
i can help with basics, that i understand (that i already use in wrapper), but car and character control is still dark for me
1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy
LiteC+Newton2 download: http://hosted.filefront.com/NeArGa
LiteC+Newton2 discussion: http://tinyurl.com/6l7y9v
VeT
 
Posts: 84
Joined: Thu Jul 31, 2008 11:31 am

Re: DG Car question

Postby Julio Jerez » Mon Jun 22, 2009 2:15 pm

The car jopint asume that teh car local direction of travel is the unit vectore (1, 0, 0).
do you vehicle geometry point on that direction?

I believe that there is a way to change when cration the Joint, but I am no sure if it works, I will fidn out and post, and if it does not works I will fix it.
Are you using the joint Library C interface or the Class?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: DG Car question

Postby VeT » Mon Jun 22, 2009 2:37 pm

hm.... really, i'll try to play with model geometry
i'm using interface of Joint library as Lite-c still doesn't support classes.
1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy
LiteC+Newton2 download: http://hosted.filefront.com/NeArGa
LiteC+Newton2 discussion: http://tinyurl.com/6l7y9v
VeT
 
Posts: 84
Joined: Thu Jul 31, 2008 11:31 am

Re: DG Car question

Postby VeT » Mon Jun 22, 2009 2:41 pm

thats better.. but i still cant see wheels in the debug view (as i said, debug just runs through all bodies with the help of NewtonWorldGetFirstBody/NewtonWorldGetNextBody and highlights their collisions)
Do the wheels have their own collisions, or they are the part of joint or something like that?
1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy
LiteC+Newton2 download: http://hosted.filefront.com/NeArGa
LiteC+Newton2 discussion: http://tinyurl.com/6l7y9v
VeT
 
Posts: 84
Joined: Thu Jul 31, 2008 11:31 am

Re: DG Car question

Postby VeT » Mon Jun 22, 2009 3:08 pm

http://www.youtube.com/watch?v=7KFs2bejlzo
Here is what i get (maybe video will be unavailable, wait a little)
1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy
LiteC+Newton2 download: http://hosted.filefront.com/NeArGa
LiteC+Newton2 discussion: http://tinyurl.com/6l7y9v
VeT
 
Posts: 84
Joined: Thu Jul 31, 2008 11:31 am

Re: DG Car question

Postby Julio Jerez » Mon Jun 22, 2009 3:17 pm

Ok I see this function
NewtonCustomJoint *DGRaycastVehicleCreate (int maxTireCount, const dFloat* cordenateSytem, NewtonBody* carBody);
If you are setting the cordenateSytem is
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

It should be that if you call with cordenateSytem set to
0 0 1 0
0 1 0 0
-1 0 0 0
0 0 0 1

Then the joint will set a the car sideway, Unfortuntaly I tried and it did not worked, There is a bug in the joint the prevent this from working as it should.
I will debug it tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: DG Car question

Postby JernejL » Mon Jun 22, 2009 3:26 pm

VeT wrote:http://www.youtube.com/watch?v=7KFs2bejlzo
Here is what i get (maybe video will be unavailable, wait a little)


Just a suggestion, there's now a youtube tag on the forum you can use - a new a button on posting toolbar next to "font colour".

Example:
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: DG Car question

Postby VeT » Mon Jun 22, 2009 3:41 pm

2 Delphi: thanks :)

2 Julio: as you see, i solved problem with sideway(with rotating models origin, you were right), but car still moves unreal.. i think, its a wheel trouble
1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy
LiteC+Newton2 download: http://hosted.filefront.com/NeArGa
LiteC+Newton2 discussion: http://tinyurl.com/6l7y9v
VeT
 
Posts: 84
Joined: Thu Jul 31, 2008 11:31 am

Re: DG Car question

Postby Julio Jerez » Mon Jun 22, 2009 3:50 pm

VeT wrote:2 Julio: as you see, i solved problem with sideway

can you wait until tonight, I do not want you to rotate the mesh, there is a bug in the joint that need to be resolved.

Some people do no have model editor to rotate the mesh, so there engine have to handle that graciustly.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: DG Car question

Postby VeT » Mon Jun 22, 2009 4:01 pm

okay, no problems...

btw, one wish: can you add new, or change old, or just overload function GDRaycastVechileAddTire(), so it could get in parameters another bodies as wheels?
i see this in next way: i create car mesh, i create wheels, i create car newton body, i create newton bodies for wheels and then construct a vechile from this with the help of one function
1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy
LiteC+Newton2 download: http://hosted.filefront.com/NeArGa
LiteC+Newton2 discussion: http://tinyurl.com/6l7y9v
VeT
 
Posts: 84
Joined: Thu Jul 31, 2008 11:31 am

Re: DG Car question

Postby Julio Jerez » Mon Jun 22, 2009 4:08 pm

VeT wrote:okay, no problems...

btw, one wish: can you add new, or change old, or just overload function GDRaycastVechileAddTire(), so it could get in parameters another bodies as wheels?
i see this in next way: i create car mesh, i create wheels, i create car newton body, i create newton bodies for wheels and then construct a vechile from this with the help of one function


what do you mean by "so it could get in parameters another bodies as wheels"

what if you need more than 4 wheel, you can make all kind of vehicles, even motorcicles.
Having the ability to add wheel at will provide low level controll, you can alway make you wraper to do teh work for you.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: DG Car question

Postby VeT » Mon Jun 22, 2009 4:22 pm

//what if you need more than 4 wheel, you can make all kind of vehicles, even motorcicles.

yes, but i'm talking about adding bodies(or collisions).. now i must use
GDRaycastVechileAddTire(car, wheel_ptr, wheel_pos, HERE_IS_A_LOT_OF_PARAMETERS_SUCH_AS_RADIUS_AND_WIDTH)

i'm talking about
GDRaycastVechileAddTire(car, wheel_ptr, wheel_pos, COLLISION_OR_BODY_TO_BE_A_WHEEL, friction_and_so_on)

i'm asking about this because now(like situation on video) i cant debug wheels and i cant know, whats wrong with them



PS: that is first problem, the second problem is visualization... now i must explore this hell from example
Code: Select all
void oxGLRayCastVehicle::BuildRenderListGL ()
{
  if (!rv_NewtonActived) {
    rv_Mesh->ob_Matrix = ob_Matrix;
    rv_Mesh->BuildRenderListGL ();
  } else {

    ob_Matrix = rv_Mesh->ob_Matrix;
    rv_Mesh->BuildRenderListGL ();
    dMatrix mt;

    for (int i = 0; i < rv_TiresCount; i ++) {

     DGRayCarTireMatrix(rv_Joint,i,&mt[0][0]);
     rv_Tires[i].rt_Mesh->ob_Matrix = mt;

      rv_Tires[i].ob_Matrix = rv_Tires[i].rt_Mesh->ob_Matrix;
      rv_Tires[i].rt_Mesh->BuildRenderListGL ();

     if (GetWindowGL()->ct_WorldDebugLines) {
        dMatrix mt, mt1, mt2;
        dFloat CurrentTirePos;

       mt = rv_Tires[i].rt_Mesh->ob_Matrix; 
       CurrentTirePos = DGRaycastVehicleGetTirePosit(rv_Joint,i);
       DGRayCarSuspensionMatrix(rv_Joint,i,CurrentTirePos,&mt1[0][0]);
       DGRayCarGetChassisMatrixLocal(rv_Joint,&mt2[0][0]);

        dMatrix tireBaseMatrix = mt1 * mt2;
        tireBaseMatrix = tireBaseMatrix * rv_Mesh->ob_Matrix;

       GetWindowGL()->AddDebugCollisionToList((NewtonCollision*)DGRayCarTireShape(rv_Joint,i),mt,dVector(1.0f,1.0f,0.0f,1.0f));

        dVector span(tireBaseMatrix.TransformVector(dVector(0.0f,-(CurrentTirePos+(rv_Tires[i].rt_Radius/2)),0.0f,0.0f)));

        GetWindowGL()->DebugDrawLine(tireBaseMatrix.m_posit,span);
     }
    }
  }
}


and if i would be able to add wheel as body, i'd be able to render them in wheel's callback function.
1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy
LiteC+Newton2 download: http://hosted.filefront.com/NeArGa
LiteC+Newton2 discussion: http://tinyurl.com/6l7y9v
VeT
 
Posts: 84
Joined: Thu Jul 31, 2008 11:31 am

Re: DG Car question

Postby Julio Jerez » Mon Jun 22, 2009 6:39 pm

VeT wrote://what if you need more than 4 wheel, you can make all kind of vehicles, even motorcicles.

yes, but i'm talking about adding bodies(or collisions).. now i must use
GDRaycastVechileAddTire(car, wheel_ptr, wheel_pos, HERE_IS_A_LOT_OF_PARAMETERS_SUCH_AS_RADIUS_AND_WIDTH)


This is the correct format, you maybe be a little confused for fews reasons:

    1- The codenade system you are using is rotated for the joint, when I fix that tonight your can joint should work fine.
    2- You are thing of the RayCast Cart as the car on 1.53, but they are very different. The Raycast car do no really have rigid bodies as tire, the tire are simulated but shooting a ray for the body. There is a variance with this this some that allow to use a convex cast for fining better contact specially when moving a low speed and taking steps.
    3- We are working on the Mutibody car, this one is the same one used in 1.53 but will be exposed as a custom joint, with this one you will be able to see you collision shape without adding that special render code.
    4- Hopefully with the next Beta 2.03 you will not have to worry about the writing debugging functions anymore since we will release the Visual Debugger that will allow you to see all of the different feature on the engine without having to write special code.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron