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.
			
			
									
						
										
						Vehicle, Wheels going all over the place
- 
				duncang
 - Posts: 7
 - Joined: Wed May 16, 2012 1:30 pm
 
Re: Vehicle, Wheels going all over the place
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
			
			
									
						
										
						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