예제 #1
0
파일: vehicle.cpp 프로젝트: Anth5/vdrift
void Vehicle::alignWithGround()
{
	btScalar ray_len = 8;
	btScalar min_height = 0;
	bool no_min_height = true;
	for (int i = 0; i < wheel.size(); ++i)
	{
		wheel[i].updateDisplacement(ray_len);
		btScalar height = wheel[i].ray.getDepth() - ray_len;
		if (height < min_height || no_min_height)
		{
			min_height = height;
			no_min_height = false;
		}
	}

	btVector3 delta = getDownVector() * min_height;
	btVector3 trimmed_position = body->getCenterOfMassPosition() + delta;
	setPosition(trimmed_position);
	for (int i = 0; i < wheel.size(); ++i)
	{
		wheel[i].updateDisplacement(ray_len);
	}

	body->setAngularVelocity(btVector3(0, 0, 0));
	body->setLinearVelocity(btVector3(0, 0, 0));
}
예제 #2
0
Vector3 Transform::getDownVector() const
{
    Vector3 v;
    getDownVector(&v);
    return v;
}