예제 #1
0
void OgreCursor::update()
{
  int x,y, w;
  getPosition(x, y);
  updatePosition(x-7, y-7); //FIXME: ugly hack to compensate offset (-7, -7) from OIS Mouse

  getWheelPos(w);

  deltaWheel += (wheelPos - w);
  int upDown = deltaWheel / wheelPosStep;
  //std::cerr << "upDown=" << upDown << std::endl;

  if (upDown > 0)
  {
    wheelDown += upDown;
    deltaWheel -= upDown * wheelPosStep;
  }
  else if (upDown < 0)
  {
    wheelUp -= upDown;
    deltaWheel -= upDown * wheelPosStep;
  }

  wheelPos = w;

  //update button status
  OIS::MouseState ms = _mouse->getMouseState();
  leftButton = ms.buttonDown(OIS::MB_Left);
  rightButton = ms.buttonDown(OIS::MB_Right);
  wheelButton = ms.buttonDown(OIS::MB_Middle);
}
예제 #2
0
파일: pWheel2.cpp 프로젝트: gbaumgart/vt
VxVector pWheel2::getGroundContactPos()const
{
	VxVector pos   = getWheelPos()+VxVector(0, -mWheelShape->getRadius(), 0);

	if (pos.Magnitude())
	{
		int op2 = 0 ; 
		op2++;
	}
	return pos;
}
예제 #3
0
void PhysicsVehicleWheel::transform(Node* node) const
{
    GP_ASSERT(_host);
    GP_ASSERT(_host->_node);

    node->setRotation(_orientation);

    // Use only the component parallel to the defined strut line
    Vector3 strutLine;
    getWheelDirection(&strutLine);
    _host->_node->getMatrix().transformVector(&strutLine);
    Vector3 wheelPos;
    getWheelPos(&wheelPos);
    node->setTranslation(wheelPos + strutLine*(strutLine.dot(_positionDelta) / strutLine.lengthSquared()));
}
예제 #4
0
void PhysicsVehicleWheel::update(float elapsedTime)
{
    GP_ASSERT(_host);
    GP_ASSERT(_host->_vehicle);

    const btTransform& trans = _host->_vehicle->getWheelInfo(_indexInHost).m_worldTransform;
    const btQuaternion& rot = trans.getRotation();
    const btVector3& pos = trans.getOrigin();
    _orientation.set(rot.x(), rot.y(), rot.z(), rot.w());

    Vector3 commandedPosition(pos.x(), pos.y(), pos.z());
    Vector3 wheelPos;
    getWheelPos(&wheelPos);
    commandedPosition -= wheelPos;

    // Filter out noise from Bullet
    Vector3 delta(_positionDelta, commandedPosition);
    float threshold = getStrutRestLength() * 2.0f;
    float responseTime = (delta.lengthSquared() > threshold*threshold) ? 0 : 60;
    _positionDelta.smooth(commandedPosition, elapsedTime, responseTime);
}