void wheelCallback( float deltax, float deltay)
    {
		if (!m_leftMouseButton)
		{

			if (deltay<0 || m_cameraDistance>1)
			{
				m_cameraDistance -= deltay*0.1;
				if (m_cameraDistance<1)
					m_cameraDistance=1;
			} else
			{
				b3Vector3 fwd = m_cameraTargetPosition-m_cameraPosition;
				fwd.normalize();
				m_cameraTargetPosition += fwd*deltay*WHEEL_MULTIPLIER;
			}
        } else
		{
			if (b3Fabs(deltax)>b3Fabs(deltay))
			{
				b3Vector3 fwd = m_cameraTargetPosition-m_cameraPosition;
				b3Vector3 side = m_cameraUp.cross(fwd);
				side.normalize();
				m_cameraTargetPosition += side * deltax*WHEEL_MULTIPLIER;

			} else
			{
				m_cameraTargetPosition -= m_cameraUp * deltay*WHEEL_MULTIPLIER;

			}
		}
	}
示例#2
0
	void wheelCallback( float deltax, float deltay)
    {
		if (!m_mouseButton)
		{
			if (b3Fabs(deltax)>b3Fabs(deltay))
			{
				m_azi -= deltax*0.1;
				
			} else
			{
				//m_cameraDistance -= deltay*0.1;
				b3Vector3 fwd = m_cameraTargetPosition-m_cameraPosition;
				fwd.normalize();
				m_cameraTargetPosition += fwd*deltay*0.1;
			}
        } else
		{
			if (b3Fabs(deltax)>b3Fabs(deltay))
			{
				b3Vector3 fwd = m_cameraTargetPosition-m_cameraPosition;
				b3Vector3 side = m_cameraUp.cross(fwd);
				side.normalize();
				m_cameraTargetPosition += side * deltax*0.1;

			} else
			{
				m_cameraTargetPosition -= m_cameraUp * deltay*0.1;

			}
		}
	}
	void mouseMoveCallback(float x, float y)
	{
		if (m_altPressed || m_controlPressed)
		{
			float xDelta = x-m_mouseXpos;
			float yDelta = y-m_mouseYpos;
			
			if (m_leftMouseButton)
			{
	//			if (b3Fabs(xDelta)>b3Fabs(yDelta))
	//			{
					m_azi -= xDelta*MOUSE_MOVE_MULTIPLIER;
	//			} else
	//			{
					m_ele += yDelta*MOUSE_MOVE_MULTIPLIER;
	//			}
			}
			if (m_middleMouseButton)
			{
				m_cameraTargetPosition += m_cameraUp * yDelta*0.01;

				
				b3Vector3 fwd = m_cameraTargetPosition-m_cameraPosition;
				b3Vector3 side = m_cameraUp.cross(fwd);
				side.normalize();
				m_cameraTargetPosition += side * xDelta*0.01;

			}
			if (m_rightMouseButton)
			{
					m_cameraDistance -= xDelta*0.01;
					m_cameraDistance -= yDelta*0.01;
					if (m_cameraDistance<1)
						m_cameraDistance=1;
					if (m_cameraDistance>1000)
						m_cameraDistance=1000;
			}
		}

		//printf("m_azi/pitch = %f\n", m_azi);
//		printf("m_ele/yaw = %f\n", m_ele);

		m_mouseXpos = x;
		m_mouseYpos = y;
		m_mouseInitialized = true;
	}
示例#4
0
	void applyImpulse(const b3Vector3& impulse, const b3Vector3& rel_pos)
	{
		m_linearVelocity += impulse * m_invMass;
		b3Vector3 torqueImpulse = rel_pos.cross(impulse);
		m_angularVelocity += m_invInertiaTensorWorld * torqueImpulse;
	}
示例#5
0
	b3Vector3 getVelocity(const b3Vector3& relPos) const
	{
		return m_linearVelocity + m_angularVelocity.cross(relPos);
	}