Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Jul 05, 2012 4:08 pm 
Offline

Joined: Wed May 16, 2012 1:30 pm
Posts: 7
Hi,

I have been trying to get a vehicle working within Cocos3d on IOS.

I have a vehicle that I can move around but the wheels go all over the place.

I thought maybe it is to do with my coordinate getting muddled up but I'm not sure

In cocos 3d.

Forward = Negative Z
Up = Positive Y
Right = Positive X

For my vehicle I have

int rightIndex = 0;
int upIndex = 1;
int forwardIndex = 2;
physicsObject.m_vehicle->setCoordinateSystem(rightIndex, upIndex, forwardIndex);//X,Y,Z

and for my wheels I have

btVector3 wheelDirectionCS0(0,-1,0);
btVector3 wheelAxleCS(-1,0,0);

They are then attached as follows

btVector3 connectionPointCS0(0.88f,connectionHeight,1.6f);
carChassis.m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,suspensionRestLength,wheelRadius,carChassis.mTuning,isFrontWheel);

etc

They are all placed correctly but when I turn left or right, they rotate on their side originally, instead of left and right.
and then as i move the vehicle forward as soon as I start to turn they just go all over the place..

I update the rendering of my wheels as follows


btQuaternion btq = object.m_vehicle->getWheelInfo(i).m_worldTransform.getRotation();
btVector3 wPos = object.m_vehicle->getWheelInfo(i).m_worldTransform.getOrigin();
CC3Vector4 quaternion;
quaternion.x = btq.x();
quaternion.y = btq.y();
quaternion.z = btq.z();
quaternion.w = btq.w();
//wheel.quaternion = quaternion;


switch (i) {
case 0:
wheel = object.Wheel1;
break;
case 1:
wheel = object.Wheel2;
break;
case 2:
wheel = object.Wheel3;
break;
case 3:
wheel = object.Wheel4;
break;
default:
break;
}

wheel.location = CC3VectorMake(wPos.getX(), wPos.getY(), wPos.getZ());
wheel.quaternion = quaternion;


Any pointers in the right direction would be hand,

Many thanks

Duncan.


Top
 Profile  
 
PostPosted: Thu Jul 12, 2012 2:09 pm 
Offline

Joined: Wed May 16, 2012 1:30 pm
Posts: 7
I figured out that all my issues were to do with the steering.

After making a few alterations I managed to get it working with cocos3d.

I've documented the changes here.

http://ios-app-development.blogspot.co. ... cos3d.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group