Esempio n. 1
0
void FirstPersonCamera::setYDirection(float newYAngle)
{
	yAngle = newYAngle;

	// Change up vector if necessary
	int yAngleModule = (int)yAngle%360;
	if (yAngleModule < 0) yAngleModule += 360;
	if (yAngleModule > 90 && yAngleModule < 270) setUpVector(0.0f, -1.0f, 0.0f);
	else if (yAngleModule < 90 || yAngleModule > 270) setUpVector(0.0f, 1.0f, 0.0f);
}
Esempio n. 2
0
void QCamera::rotate( const QQuaternion& q )
{
    setUpVector(q * upVector());
    QVector3D viewVector = viewCenter() - position();
    QVector3D cameraToCenter = q * viewVector;
    setViewCenter(position() + cameraToCenter);
}
QD3D11MultiViewportViewer::QD3D11MultiViewportViewer( bool flipMouseUpDown,
						   float keyWalkSpeed,
						   float mousePitchSpeed,
						   QWidget* parent ) :

	m_flipMouseUpDown( flipMouseUpDown ),

	m_keyWalkSpeed( keyWalkSpeed ),
	m_mousePitchSpeed( mousePitchSpeed ),

	QD3D11Widget( parent )

{
	m_frontCamera.setDirectX( true );
	m_frontCamera.setLookAt( Vector3f( 0, 0, 5 ), Vector3f( 0, 0, 0 ), Vector3f( 0, 1, 0 ) );
	m_frontCamera.setOrtho( -5, 5, -5, 5, 0.01f, 10.0f );

	m_topCamera.setDirectX( true );
	m_topCamera.setLookAt( Vector3f( 0, 5, 0 ), Vector3f( 0, 0, 0 ), Vector3f( 0, 0, -1 ) );
	m_frontCamera.setOrtho( -5, 5, -5, 5, 0.01f, 10.0f );

	m_leftCamera.setDirectX( true );
	m_leftCamera.setLookAt( Vector3f( -5, 0, 0 ), Vector3f( 0, 0, 0 ), Vector3f( 0, 1, 0 ) );
	m_frontCamera.setOrtho( -5, 5, -5, 5, 0.01f, 10.0f );
	
    m_perspectiveCamera.setDirectX( true );
	m_perspectiveCamera.setLookAt( 5 * Vector3f( 1, 1, 1 ).normalized(), Vector3f( 0, 0, 0 ), Vector3f( -1, 1, -1 ).normalized() );
	m_perspectiveCamera.setPerspective( MathUtils::degreesToRadians( 50.0f ), 1.f, 0.01f, 10.0f );

	setUpVector( Vector3f( 0, 1, 0 ) );
}
	void CMazeGameEngine::setupCamera()
	{
		auto cameraNode = _sceneManager->addCameraSceneNode();
		_sceneManager->addLightSceneNode(cameraNode, irr::core::vector3df(0, 0.5, 0), irr::video::SColorf(1.0f, 1.0f, 1.0f), 5.0f);
		cameraNode->setPosition(irr::core::vector3df(static_cast<float>(_worldModel.getFinishPoint().first) - 0.5f
			, 4.0f, static_cast<float>(_worldModel.getFinishPoint().second) - 2.5f));
		cameraNode->setTarget(irr::core::vector3df(static_cast<float>(_worldModel.getFinishPoint().first) - 0.5f
			, 0.0f, static_cast<float>(_worldModel.getFinishPoint().second) - 0.5f));
		cameraNode->setUpVector(irr::core::vector3df(0, 0, 1));
		_camera.setCamera(cameraNode);
	}
Esempio n. 5
0
FPSControls::FPSControls( const Vector3f& upVector,
    const FPSMouseParameters& mouseParameters,
    const FPSKeyboardParameters& keyboardParameters,
    const FPSXboxGamepadParameters& xboxGamepadParameters ) :

    m_mouseParameters( mouseParameters ),
    m_keyboardParameters( keyboardParameters ),
    m_xboxGamepadParameters( xboxGamepadParameters )

{
    setUpVector( upVector );
}
Esempio n. 6
0
LockedCamera::LockedCamera (void)
{
	_realtimeCtrl = 0;
	_zoomSpeed = 4.f;
	_moveSpeed = 4.f;
	_rotateSpeed = 1.f;
	_lat = 0.f;
	_mer = 0.f;
	_isRotating = false;
	_isZooming = false;
	_isMoving = false;

	setPosition (ATOM_Vector3f(-100.f, 100.f, -100.f));
	setDirection (ATOM_Vector3f(100.f, -100.f, 100.f));
	setUpVector (ATOM_Vector3f(0.f, 1.f, 0.f));
}
Esempio n. 7
0
void bsCamera::animate(void)
{
#if 0
	if(mNumFrames>0 && mAnimation)
	{
		double pos[3],dir[3],up[3];
		int gotpos, gotdir;
		GetCamera(mAnimation,mCurrentTime,&gotpos,pos,&gotdir,dir,up);
		if(gotpos) setPosition(Vec3f(pos[0],pos[1],pos[2]));
		if(gotdir)
		{
			setLookAt(Vec3f(pos[0]+dir[0],pos[1]+dir[1],pos[2]+dir[2]));
			setUpVector(Vec3f(up[0],up[1],up[2]));
		}
	}
#endif
}
Esempio n. 8
0
QD3D11Viewer::QD3D11Viewer( bool flipMouseUpDown,
                            float keyWalkSpeed,
                            float mousePitchSpeed,
                            QWidget* parent ) :

    m_flipMouseUpDown( flipMouseUpDown ),

    m_keyWalkSpeed( keyWalkSpeed ),
    m_mousePitchSpeed( mousePitchSpeed ),

    QD3D11Widget( parent )

{
    m_camera.setDirectX( true );
    // m_camera.setPerspective( 10.f, 1.f, 4.7f, 5.4f);
    // m_camera.setPerspective( 50.f, 1.f, 3.5f, 6.5f);
    m_camera.setPerspective( 50.f, 1.f, 0.01f, 10.0f );

    setUpVector( Vector3f( 0, 1, 0 ) );
}
Esempio n. 9
0
void QCamera::translate( const QVector3D& vLocal, CameraTranslationOption option )
{
    QVector3D viewVector = viewCenter() - position(); // From "camera" position to view center

    // Calculate the amount to move by in world coordinates
    QVector3D vWorld;
    if ( !qFuzzyIsNull( vLocal.x() ) )
    {
        // Calculate the vector for the local x axis
        QVector3D x = QVector3D::crossProduct(viewVector, upVector()).normalized();
        vWorld += vLocal.x() * x;
    }

    if ( !qFuzzyIsNull( vLocal.y() ) )
        vWorld += vLocal.y() * upVector();

    if ( !qFuzzyIsNull( vLocal.z() ) )
        vWorld += vLocal.z() * viewVector.normalized();

    // Update the camera position using the calculated world vector
    setPosition(position() + vWorld);

    // May be also update the view center coordinates
    if ( option == TranslateViewCenter )
        setViewCenter(viewCenter() + vWorld);

    // Refresh the camera -> view center vector
    viewVector = viewCenter() - position();

    // Calculate a new up vector. We do this by:
    // 1) Calculate a new local x-direction vector from the cross product of the new
    //    camera to view center vector and the old up vector.
    // 2) The local x vector is the normal to the plane in which the new up vector
    //    must lay. So we can take the cross product of this normal and the new
    //    x vector. The new normal vector forms the last part of the orthonormal basis
    QVector3D x = QVector3D::crossProduct(viewVector, upVector()).normalized();
    setUpVector(QVector3D::crossProduct(x, viewVector).normalized());
}
Esempio n. 10
0
void Camera::playSequence()
{
    Q_D(Camera);

    int curveIndex = MathHelper::toInt(floor(MathHelper::toFloat(d->play_tick) / MathHelper::toFloat(d->play_ticks / d->curves.count())));
    int playTicks  = d->play_ticks / d->curves.count();
    int playTick   = d->play_tick - (playTicks * curveIndex);

    if(curveIndex >= d->curves.count())
        stop();

    BezierCurve* curve = d->curves.at(curveIndex);

    ++d->play_tick;

    float t = 1.0f / playTicks * playTick;

    setPosition(curve->calculatePoint(t));
    setViewCenter(curve->calculateViewCenter(t));
    setUpVector(curve->calculateUpVector(t));

    if(d->play_tick == d->play_ticks)
        stop(false);
}
Esempio n. 11
0
void Camera::setUpVector( float x, float y, float z ) 
{
	setUpVector( DirectX::XMFLOAT3(x,y,z) );
}
Esempio n. 12
0
void Listener::setUpVector(float x, float y, float z)
{
    setUpVector(Vector3f(x, y, z));
}
Esempio n. 13
0
void Z3DCamera::roll(float angle)
{
  glm::vec3 up = glm::rotate(glm::angleAxis(angle, m_viewVector), m_upVector);
  setUpVector(up);
}
Esempio n. 14
0
void GLCamera::setUpVector(const float x, const float y, const float z)						{ setUpVector(glm::vec3(x, y, z)); }
Esempio n. 15
0
void Billboard::setUpVector(float x, float y, float z) {
	setUpVector(ofVec3f(x, y, z));
}