コード例 #1
0
void Camera::MenuCameraRotation()
{
	// Create rotation matrix
	m_menuRotation += (float)GLOBAL::GetInstance().GetDeltaTime() / 16.0f;
	if (m_menuRotation > 6.28f)
	{
		m_menuRotation = 0.0f;
	}
	DirectX::XMMATRIX rotation = DirectX::XMMatrixRotationY(m_menuRotation);

	// Lock shadows in center.
	DirectX::XMFLOAT3 shadowPosition = GetPosition();
	DirectX::XMStoreFloat3(&shadowPosition, DirectX::XMVector3TransformCoord(DirectX::XMLoadFloat3(&shadowPosition), rotation));
	shadowPosition.x *= 0.8f;
	DirectX::XMFLOAT3 position = DirectX::XMFLOAT3(25.0f + shadowPosition.x, 100.0f, 50.0f);

	UpdatePosition(position);
	UpdateTarget(DirectX::XMFLOAT3(shadowPosition.x, 5.0f, 0.0f));
	UpdateViewMatrix();
	UpdateProjectionMatrix(true);
	GraphicsEngine::SetLightViewAndProjection(GetViewMatrix(), GetProjectionMatrix());

	// Lock camera in center and rotate camera.	
	position = DirectX::XMFLOAT3(0.0f, 40.0f, -24.0f);

	UpdatePosition(position);
	UpdateTarget(DirectX::XMFLOAT3(0.0f, 7.5f, 0.0f));
	UpdateViewMatrix();
	UpdateProjectionMatrix(false);

	DirectX::XMStoreFloat4x4(&m_viewMatrix, DirectX::XMMatrixMultiply(rotation, DirectX::XMLoadFloat4x4(&m_viewMatrix)));

	GraphicsEngine::SetViewAndProjection(GetViewMatrix(), GetProjectionMatrix());
}
コード例 #2
0
void ThirdPersonCamera::Update()
{
	real dt = TheTimer::Instance()->GetDT();

    UpdateOrientation(dt);

	if (m_springsEnabled)
        UpdateViewMatrix(dt);
    else
        UpdateViewMatrix();
}
コード例 #3
0
void Camera::FollowCharacter(DirectX::XMFLOAT3 p_playerPos)
{
	// Lock shadows on the player.
	DirectX::XMFLOAT3 playerPosition = p_playerPos;
	DirectX::XMFLOAT3 position = DirectX::XMFLOAT3(playerPosition.x + 25.0f, playerPosition.y + 100.0f, playerPosition.z + 50.0f);
	DirectX::XMFLOAT3 target = playerPosition;

	UpdatePosition(position);
	UpdateTarget(target);
	UpdateViewMatrix();
	UpdateProjectionMatrix(true);
	GraphicsEngine::SetLightViewAndProjection(GetViewMatrix(), GetProjectionMatrix());

	// Visibility view projection..
	playerPosition = p_playerPos;
	position = DirectX::XMFLOAT3(playerPosition.x, playerPosition.y + 30.0f, playerPosition.z);
	target = playerPosition;

	UpdatePosition(position);
	UpdateTarget(target);
	UpdateViewMatrix();
	GraphicsEngine::SetViewPolygonMatrix(GetViewMatrix());
	

	// Lock camera on the player.
	playerPosition = p_playerPos;
	position = DirectX::XMFLOAT3(playerPosition.x, playerPosition.y + 30.0f, playerPosition.z - 15.0f);
	target = playerPosition;

	SetOutliningRayPosition(position);
	SetOutliningRayTarget(target);

	if (GLOBAL::GetInstance().CAMERA_MOVING)
	{
		MovingCamera(playerPosition);
	}
	else
	{
		UpdatePosition(position);
		UpdateTarget(target);
		UpdateViewMatrix();
		UpdateProjectionMatrix(false);
		GraphicsEngine::SetViewAndProjection(GetViewMatrix(), GetProjectionMatrix());
		m_oldPosition = position;
	}	

	GraphicsEngine::UpdateVisibilityPolygon(Point(playerPosition.x, playerPosition.z), (float)GLOBAL::GetInstance().GetDeltaTime());
}
コード例 #4
0
ファイル: CameraRTS.cpp プロジェクト: simplerr/Devbox
	//! Updates the camera in a RTS fashion.
	void CameraRTS::Update(Input* pInput, float dt)
	{
		if(GetLocked())
			return;

		XMFLOAT3 mousePos = pInput->MousePosition();

		// Temp [NOTE]
		//if(pInput->KeyDown(VK_MBUTTON)) {
			int scrollBarSize = 5.0f;
			if(mousePos.x < scrollBarSize || mousePos.x > 65000) // [NOTE] For some reason mousePos.x can be 65 534 when outside the window.
				Move(XMFLOAT3(0, 0, 1) * GetMovementSpeed());
			else if(mousePos.x > GlobalApp::GetClientWidth() - scrollBarSize)
				Move(XMFLOAT3(0, 0, -1) * GetMovementSpeed());

			if(mousePos.y < scrollBarSize)
				Move(XMFLOAT3(1, 0, 0) * GetMovementSpeed());
			else if(mousePos.y > GlobalApp::GetClientHeight() - scrollBarSize)
				Move(XMFLOAT3(-1, 0, 0) * GetMovementSpeed());

			Move(GetDirection() * pInput->MouseDz() * 0.10f);

			// Update the view matrix.
			UpdateViewMatrix();
		//}
	}
コード例 #5
0
ファイル: Camera.cpp プロジェクト: dotrihieu/component
void Camera::Move(float dx, float dy, float dz)
{
	cameraPos.x += dx;
	cameraPos.y += dy;
	cameraPos.z += dz;
	UpdateViewMatrix();
}
コード例 #6
0
ファイル: Camera.cpp プロジェクト: simplerr/Devbox
	//! Constructor.
	Camera::Camera()
	{
		// Set the sensitivity and speed
		SetLookSensitivity(2.0f);
		SetMovementSpeed(0.6f);
		SetLocked(false);

		// Default position and target
		mPosition	= XMFLOAT3(-30, 60, 0);
		mTarget		= XMFLOAT3(0.0f, 0.0f, 0.0f);
		mUp			= XMFLOAT3(0.0f, 1.0f, 0.0f);		// Weird up vector

		// Calculate the new direction.
		UpdatePitchYaw();

		// Build the projection matrix
		XMMATRIX proj = XMMatrixPerspectiveFovLH(XM_PI * 0.25, (float)GlobalApp::GetClientWidth()/(float)GlobalApp::GetClientHeight(), 1.0f, 1000.0f);
		XMStoreFloat4x4(&mProj, proj);

		UpdateViewMatrix();
		
		// Build the camera frustum.
		mFrustum.ConstructFromProjection(GetProjectionMatrix());
		//XNA::ComputeFrustumFromProjection(&mFrustum, &XMLoadFloat4x4(&GetProjectionMatrix()));
	}
コード例 #7
0
ファイル: GLVideo.cpp プロジェクト: St0l3nID/ethanon
bool GLVideo::SetVertexShader(ShaderPtr pShader)
{
	if (!pShader)
	{
		if (m_currentVS != m_defaultVS)
			m_currentVS->UnbindShader();
		m_currentVS = m_defaultVS;
	}
	else
	{
		if (pShader->GetShaderFocus() != Shader::SF_VERTEX)
		{
			ShowMessage("The shader set is not a vertex program", GSMT_ERROR);
			return false;
		}
		else
		{
			m_currentVS->UnbindShader();
			m_currentVS = pShader;
		}
	}

	const math::Vector2 screenSize = GetScreenSizeF();
	UpdateViewMatrix(screenSize, m_ortho, m_zNear, m_zFar, (m_currentTarget.lock()) ? true : false);
	UpdateShaderViewData(m_currentVS, screenSize, m_ortho);
	return true;
}
コード例 #8
0
ファイル: Camera.cpp プロジェクト: mhyhre/Tuxis-Engine
	void Camera::Update()
	{
		mRotationMatrix = XMMatrixRotationRollPitchYaw(Roll, Pitch, Yaw);
		mTarget = XMVector3TransformCoord(DefaultForward, mRotationMatrix );
		mTarget = XMVector3Normalize(mTarget);
	
		XMMATRIX RotateYTempMatrix;
		RotateYTempMatrix = XMMatrixRotationRollPitchYaw(Roll, Pitch, Yaw);
	
		mRight = XMVector3TransformCoord(DefaultRight, RotateYTempMatrix);
		mUp = XMVector3TransformCoord(DefaultUp, RotateYTempMatrix);
		mForward = XMVector3TransformCoord(DefaultForward, RotateYTempMatrix);
	
		mPosition += mMoveLeftRight*mRight;
		mPosition += mMoveTopDown*mUp;
		mPosition += mMoveBackForward*mForward;
	
		mMoveLeftRight = 0.0f;
		mMoveTopDown = 0.0f;
		mMoveBackForward = 0.0f;
	
		mTarget = mPosition + mTarget;	
	
		UpdateViewMatrix();
	}
コード例 #9
0
void Camera::ResetCameraToLight()
{
	// Reset camera.
	DirectX::XMFLOAT3 target = DirectX::XMFLOAT3(0, 0, 0);
	DirectX::XMFLOAT3 position = DirectX::XMFLOAT3(25.0f, 100.0f, 50.0f);

	UpdatePosition(position);
	UpdateTarget(target);

	m_upVector = DirectX::XMFLOAT3(-25.0f, 100.0f, -50.0f);
	DirectX::XMStoreFloat3(&m_upVector, DirectX::XMVector3Normalize(DirectX::XMLoadFloat3(&m_upVector)));

	m_look = DirectX::XMFLOAT3(-25.0f, -100.0f, -50.0f);
	DirectX::XMStoreFloat3(&m_look, DirectX::XMVector3Normalize(DirectX::XMLoadFloat3(&m_look)));

	m_right = DirectX::XMFLOAT3(25.0f, 0.0f, -50.0f);
	DirectX::XMStoreFloat3(&m_right, DirectX::XMVector3Normalize(DirectX::XMLoadFloat3(&m_right)));

	// Projection data.
	float aspectRatio = (float)GLOBAL::GetInstance().MAX_SCREEN_WIDTH / (float)GLOBAL::GetInstance().MAX_SCREEN_HEIGHT;
	UpdateAspectRatio(aspectRatio);
	UpdateFieldOfView(3.141592f * 0.25f);
	UpdateClippingPlanes(0.1f, 1000.0f);
	UpdateViewMatrix();
	UpdateProjectionMatrix(true);

	GraphicsEngine::SetLightViewAndProjection(GetViewMatrix(), GetProjectionMatrix());
}
コード例 #10
0
ファイル: renwin3d.cpp プロジェクト: SeriousAlexej/Ivo
void CRenWin3D::ZoomFit()
{
    if(!m_model)
        return;
    float lowestX  = 999999999999.0f,
          highestX =-999999999999.0f,
          lowestY  = 999999999999.0f,
          highestY =-999999999999.0f,
          fZ       =-999999999999.0f;

    const glm::vec3* m_aabbox = m_model->GetAABBox();

    glm::mat4 viewMxNOPOS = m_viewMatrix;
    viewMxNOPOS[3] = glm::vec4(0, 0, 0, 1);

    for(int i=0; i<8; ++i)
    {
        glm::vec3 v = glm::vec3(viewMxNOPOS * glm::vec4(m_aabbox[i].x, m_aabbox[i].y, m_aabbox[i].z, 1.0f));
        lowestX = glm::min(lowestX, v.x);
        highestX = glm::max(highestX, v.x);
        lowestY = glm::min(lowestY, v.y);
        highestY = glm::max(highestY, v.y);
        fZ = glm::max(fZ, v.z);
    }
    float oneOverTanHFOVY = 1.0f / glm::tan(glm::radians(m_fovy * 0.5f));
    m_cameraPosition = glm::vec3((lowestX + highestX) * 0.5f, (lowestY + highestY) * 0.5f, 2.0f*(fZ + (highestX - lowestY) * 0.5f * oneOverTanHFOVY));
    m_cameraPosition = glm::vec3(glm::inverse(viewMxNOPOS) * glm::vec4(m_cameraPosition.x, m_cameraPosition.y, m_cameraPosition.z, 1.0f));

    UpdateViewMatrix();
}
コード例 #11
0
ファイル: renwin3d.cpp プロジェクト: SeriousAlexej/Ivo
void CRenWin3D::UpdateViewAngles()
{
    static const float _pi = glm::pi<float>();

    if(m_cameraRotation[1] > _pi*0.5f)
        m_cameraRotation[1] = _pi*0.5f;
    else
    if(m_cameraRotation[1] < -_pi*0.5f)
        m_cameraRotation[1] = -_pi*0.5f;

    while(m_cameraRotation[0] > _pi*2.0f)
        m_cameraRotation[0] -= _pi*2.0f;
    while(m_cameraRotation[0] < 0.0f)
        m_cameraRotation[0] += _pi*2.0f;

    m_front = glm::vec3(
        glm::cos(m_cameraRotation[1]) * glm::sin(m_cameraRotation[0]),
        glm::sin(m_cameraRotation[1]),
        glm::cos(m_cameraRotation[1]) * glm::cos(m_cameraRotation[0]));

    m_right = glm::vec3(
        glm::sin(m_cameraRotation[0] - _pi*0.5f),
        0.0f,
        glm::cos(m_cameraRotation[0] - _pi*0.5f));

    m_up = glm::cross(m_right, m_front);
    UpdateViewMatrix();
}
コード例 #12
0
ファイル: GLVideo.cpp プロジェクト: St0l3nID/ethanon
void GLVideo::UpdateInternalShadersViewData(const math::Vector2& screenSize, const bool invertY)
{
	UpdateViewMatrix(screenSize, m_ortho, m_zNear, m_zFar, invertY);

	UpdateShaderViewData(m_defaultVS, screenSize, m_ortho);
	UpdateShaderViewData(m_rectVS, screenSize, m_ortho);
	UpdateShaderViewData(m_fastVS, screenSize, m_ortho);
}
コード例 #13
0
ファイル: Camera.cpp プロジェクト: snicolescu/bolts
Bolts::mat4 Bolts::Camera::GetViewMatrix() const
{
	if( m_viewDirty ) {
		UpdateViewMatrix ();
	}

	return m_viewMatrix;
}
コード例 #14
0
ファイル: Camera.cpp プロジェクト: ash9991win/VVVVV-Game
	void Camera::Reset()
	{
		mPosition = Vector3Helper::Zero;
		mDirection = Vector3Helper::Forward;
		mUp = Vector3Helper::Up;
		mRight = Vector3Helper::Right;

		UpdateViewMatrix();
	}
コード例 #15
0
ファイル: Camera.cpp プロジェクト: ariabonczek/DSAProject
void Camera::Initialize()
{
	right = Vector3::Right;
	up = Vector3::Up;
	forward = Vector3::Forward;
	SetPosition(Vector3(0.0f, 0.0f, 0.0f));
	SetLens(0.25f * PI, (float)WINDOW_WIDTH / WINDOW_HEIGHT, 0.1f, 100.0f);
	UpdateViewMatrix();
}
コード例 #16
0
ファイル: Camera.cpp プロジェクト: ariabonczek/DSAProject
Matrix Camera::GetView()
{
	if (dirty)
	{
		UpdateViewMatrix();
		dirty = false;
	}
	return view;
}
コード例 #17
0
ファイル: Camera.cpp プロジェクト: torresjeff/LearnOpenGL
void Camera::Reset()
{
	mPosition = glm::vec3(0.0f, 0.0f, 2.0f); // We start at the origin of the world
	mDirection = glm::vec3(0.0f, 0.0f, -1.0f); // We start looking down the -Z axis
	mRight = glm::vec3(1.0f, 0.0f, 0.0f); 
	mUp = glm::vec3(0.0f, 1.0f, 0.0f);

	UpdateViewMatrix();
}
コード例 #18
0
ファイル: CullingManager.cpp プロジェクト: adi97ida/Client
void CCullingManager::Process()
{
	//DWORD time = ELTimer_GetMSec();
	//Frustum f;
	UpdateViewMatrix();
	UpdateProjMatrix();
	BuildViewFrustum();
	m_Factory->FrustumTest(GetFrustum(), this);
	//Tracef("cull process : %3d  ",ELTimer_GetMSec()-time);
}
Camera::Camera(float yFOV, float nearClip, float farClip)
{
	m_FOV = yFOV;
	m_NearClip = nearClip;
	m_FarClip = farClip;

	m_Position = glm::vec3(0.0);

	UpdateViewMatrix();
}
コード例 #20
0
ファイル: Camera.cpp プロジェクト: sanglin307/Disorder
    void Camera::Tick(float delta)
	{ 

		//Update Camera 
		Update(delta);

		UpdateViewMatrix();

		UpdateProjectMatrix();

	}
コード例 #21
0
ファイル: ModelView.cpp プロジェクト: beijingkaka/shellspace
void OvrSceneView::Frame( const VrViewParms viewParms_, const VrFrame vrFrame,
		ovrMatrix4f & timeWarpParmsExternalVelocity )
{
	ViewParms = viewParms_;
	UpdateViewMatrix( vrFrame );
	UpdateSceneModels( vrFrame );

	// Set the external velocity matrix so TimeWarp can smoothly rotate the
	// view even if we are dropping frames.
	timeWarpParmsExternalVelocity = CalculateExternalVelocity( ViewMatrix, YawVelocity );
}
コード例 #22
0
ファイル: Camera.cpp プロジェクト: tcye/DXEngine
void Camera::Update()
{
	static D3DXVECTOR2 lastMousePosition = theInput->GetMousePosition();
	// Rotate the camera
	if (theInput->GetKey(VK_LBUTTON))
	{
		D3DXVECTOR2 curMousePosition = theInput->GetMousePosition();
		float xDiff = curMousePosition.x - lastMousePosition.x;
		float yDiff = curMousePosition.y - lastMousePosition.y;
		lastMousePosition = curMousePosition;

		D3DXMATRIX matRotation;
		if (yDiff != 0)
		{
			D3DXMatrixRotationAxis(&matRotation, &m_right, D3DXToRadian(yDiff / 3.0f));
			D3DXVec3TransformCoord(&m_look, &m_look, &matRotation);
			D3DXVec3TransformCoord(&m_up, &m_up, &matRotation);
		}

		if (xDiff != 0)
		{
			D3DXMatrixRotationAxis(&matRotation, &D3DXVECTOR3(0, 1, 0), D3DXToRadian(xDiff / 3.0f));
			D3DXVec3TransformCoord(&m_look, &m_look, &matRotation);
			D3DXVec3TransformCoord(&m_up, &m_up, &matRotation);
			D3DXVec3TransformCoord(&m_right, &m_right, &matRotation);
		}
	}
	else
	{
		lastMousePosition = theInput->GetMousePosition();
	}
	
	// Move the Camera
	float moveX = 0.0f, moveY = 0.0f, moveZ = 0.0f;
	if (theInput->GetKey(VK_UP) || theInput->GetKey('W'))
		moveZ += 1.0f;
	if (theInput->GetKey(VK_DOWN) || theInput->GetKey('S'))
		moveZ -= 1.0f;
	if (theInput->GetKey(VK_LEFT) || theInput->GetKey('A'))
		moveX -= 1.0f;
	if (theInput->GetKey(VK_RIGHT) || theInput->GetKey('D'))
		moveX += 1.0f;
	if (theInput->GetKey(VK_HOME) || theInput->GetKey('Q'))
		moveY += 1.0f;
	if (theInput->GetKey(VK_END) || theInput->GetKey('E'))
		moveY -= 1.0f;
	D3DXVECTOR3 move = moveX * m_right + moveY * m_up + moveZ * m_look;
	D3DXVec3Normalize(&move, &move);
	m_position += move * m_moveSpeed * theTime->GetDeltaTime();



	UpdateViewMatrix();
}
コード例 #23
0
void Camera::MovingCamera(DirectX::XMFLOAT3 p_pos)
{
	float moveX, moveY, centerX, centerY, posX, posY;
	centerX = GLOBAL::GetInstance().CURRENT_SCREEN_WIDTH * 0.5f;
	centerY = GLOBAL::GetInstance().CURRENT_SCREEN_HEIGHT * 0.5f;
	posX = InputManager::GetInstance()->GetMousePositionX() - centerX;
	posY = InputManager::GetInstance()->GetMousePositionY() - centerY;
	float procX = posX / 440;
	float procY = posY / 352; // 512 *0,68 //0.68 = 440/640;
	if (procX > 1.0)
		procX = 1.0;
	if (procX < -1.0)
		procX = -1.0;
	if (procY > 1.0)
		procY = 1.0;
	if (procY < -1.0)
		procY = -1.0;

	moveX = 8 * procX;
	moveY = 8 * procY;

	DirectX::XMFLOAT3 position, target, finalPos;
	DirectX::XMFLOAT3 playerPosition = p_pos;
	position = DirectX::XMFLOAT3(playerPosition.x + moveX, playerPosition.y + 30.0f, playerPosition.z - moveY - 15.0f);
	target = DirectX::XMFLOAT3(playerPosition.x + moveX, 0, playerPosition.z - moveY);

	DirectX::XMStoreFloat3(&finalPos, SmoothStep(DirectX::XMLoadFloat3(&m_oldPosition), DirectX::XMLoadFloat3(&position), 0.25f));
	
	// Set max limits
	if (finalPos.x < -38)
		finalPos.x = -38;
	if (finalPos.x > 38)
		finalPos.x = 38;
	if (finalPos.z > 35)
		finalPos.z = 35;
	if (finalPos.z < -58)
		finalPos.z = -58;

	target = DirectX::XMFLOAT3(finalPos.x, 0, finalPos.z + 15.0f);

	UpdatePosition(finalPos);
	UpdateTarget(target);
	UpdateViewMatrix();
	UpdateProjectionMatrix(false);
	GraphicsEngine::SetViewAndProjection(GetViewMatrix(), GetProjectionMatrix());

	m_oldPosition = finalPos;

	SetOutliningRayPosition(finalPos);
	SetOutliningRayTarget(playerPosition);
};
コード例 #24
0
void FPCamera::Reset(const glm::vec3 &eye, const glm::vec3 &center, glm::vec3 &up)
{
	mPosition = eye;
	//still needs normalization
		mDirection = eye - center;
	//i = j x k
		mRight = glm::cross( up,mDirection );
	//j = k x i
		mUp = glm::cross(mDirection, mRight );
	//normalize all
		mUp = glm::normalize(mUp);
		mRight = glm::normalize(mRight);
		mDirection = glm::normalize(mDirection);
	UpdateViewMatrix();
}
コード例 #25
0
ファイル: Camera.cpp プロジェクト: tcye/DXEngine
Camera::Camera()
{
	m_position = { 0.0f, 10.0f, -50.0f };
	m_right = { 1.0f, 0.0f, 0.0f };
	m_up = { 0.0f, 1.0f, 0.0f };
	m_look = { 0.0f, 0.0f, 1.0f };

	m_moveSpeed = 10.0f;

	D3DXMatrixPerspectiveFovLH(&m_matProj, D3DXToRadian(45.0f),
		(float)theGame->GetWidth() / (float)theGame->GetHeight(),
		1.0f, 1000.0f);

	UpdateViewMatrix();
}
コード例 #26
0
ファイル: ModelView.cpp プロジェクト: beijingkaka/shellspace
void OvrSceneView::Frame( const VrViewParms viewParms_, const VrFrame vrFrame,
		ovrMatrix4f & timeWarpParmsExternalVelocity, const long long supressModelsWithClientId )
{
	ViewParms = viewParms_;
	UpdateViewMatrix( vrFrame );
	UpdateSceneModels( vrFrame, supressModelsWithClientId );

	// External systems can add surfaces to this list before drawing.
	EmitList.Clear();

	// Set the external velocity matrix so TimeWarp can smoothly rotate the
	// view even if we are dropping frames.
	const ovrMatrix4f localViewMatrix = ViewMatrix;
	timeWarpParmsExternalVelocity = CalculateExternalVelocity( &localViewMatrix, YawVelocity );
}
コード例 #27
0
ファイル: Camera.cpp プロジェクト: dotrihieu/component
void Camera::rotateOx(float radian)
{
	Matrix rotate;
	rotate.SetRotateOx(radian);
	Vector4f directionTemp;
	directionTemp.x = direction.x;
	directionTemp.y = direction.y;
	directionTemp.z = direction.z;
	directionTemp.w = 1.0;

	directionTemp = rotate * directionTemp;
	direction.x = directionTemp.x;
	direction.y = directionTemp.y;
	direction.z = directionTemp.z;
	UpdateViewMatrix();
}
コード例 #28
0
void PlayerCamera::UpdateCamera(float inTimeDelta)
{

	D3DXMatrixRotationY(&tmpMat, (_pInput->_mouseState).lX / 300.0f);
	D3DXVec3TransformCoord(&_right, &_right, &tmpMat);
	D3DXVec3TransformCoord(&_look3, &_look3, &tmpMat);

	D3DXMatrixRotationAxis(&tmpMat, &_right, (_pInput->_mouseState).lY / 300.0f);
	D3DXVec3TransformCoord(&_up, &_up, &tmpMat);
	D3DXVec3TransformCoord(&_look3, &_look3, &tmpMat);


	if( _pInput->IsWPressed() )
	{
		MoveForwards(inTimeDelta);
	}

	if( _pInput->IsSPressed() )
	{
		MoveBackwards(inTimeDelta);
	}

	if( _pInput->IsAPressed() )
	{
		StrafeLeft(inTimeDelta);
	}

	if( _pInput->IsDPressed() )
	{
		StrafeRight(inTimeDelta);
	}

	_position4.x = _position3.x;
	_position4.y = _position3.y;
	_position4.z = _position3.z;
	_position4.w = 1.0f;

	_look4.x = _look3.x;
	_look4.y = _look3.y;
	_look4.z = _look3.z;
	_look4.w = 1.0f;

	UpdateViewMatrix();

	D3DXMatrixMultiply(&_viewProjectionMatrix , &_viewMatrix, &_projectionMatrix);
}
コード例 #29
0
ファイル: Camera.cpp プロジェクト: Xyzyx101/GoblinBrawl
void XM_CALLCONV Camera::Update( float deltaTime ) {

	if( GetAsyncKeyState( VK_HOME ) ) {
		SetCamType();
	}
	
	if( GetCamType()==1 ) {

		if( GetAsyncKeyState( VK_LEFT ) ) {
			RotateY( 5.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_RIGHT ) ) {
			RotateY( -5.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_UP ) ) {
			Walk( -15.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_DOWN ) ) {
			Walk( 15.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_PRIOR ) ) {
			Pitch( 1.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_NEXT ) ) {
			Pitch( -1.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_OEM_COMMA ) ) {
			Strafe( -15.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_OEM_PERIOD ) ) {
			Strafe( 15.0f * deltaTime );
		}
	} else {

		// default camera
		
		//XMStoreFloat3( &target1, goblin1Pos);
		//XMVECTOR posV = XMLoadFloat3( &pos );
		//XMVECTOR targetV = goblin1Pos;
		//XMVECTOR upV = GetUpXM();
		//LookAt( posV, targetV, upV );
	}

	UpdateViewMatrix();
}
コード例 #30
0
ファイル: Camera.cpp プロジェクト: dotrihieu/component
void Camera::SetCameraLookAt(float eyeX, float eyeY, float eyeZ, float desX, float desY, float desZ, float upX, float upY, float upZ)
{
	cameraPos.x = eyeX;
	cameraPos.y = eyeY;
	cameraPos.z = eyeZ;
	//------------------
	direction.x = desX - eyeX;
	direction.y = desY - eyeY;
	direction.z = desZ - eyeZ;
	direction = Normalize(direction);

	up.x = upX;
	up.y = upY;
	up.z = upZ;
	up = Normalize(up);
	
	UpdateViewMatrix();
}