コード例 #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
ファイル: Transform.cpp プロジェクト: aaweb/GamePlay
Vector3 Transform::getDownVector() const
{
    Vector3 v;
    getDownVector(&v);
    return v;
}