Beispiel #1
0
void Camera::updateViewMatrix()
{
    //TODO: use XMatrixLookAt built in?
    // A partir de la view matrix on peut aller chercher les elements (position, up, look) si je me souviens bien
	XMVECTOR R = XMLoadFloat3(&m_right);
	XMVECTOR U = XMLoadFloat3(&m_up);
	XMVECTOR L = XMLoadFloat3(&m_look);
	XMVECTOR P = XMLoadFloat3(&m_position);

	// Keep camera's axes orthogonal to each other and of unit length.
    // Necessary because after several rotations numerical errors can accumulate
	L = XMVector3Normalize(L);
	U = XMVector3Normalize(XMVector3Cross(L, R));

	// U, L already ortho-normal, so no need to normalize cross product.
	R = XMVector3Cross(U, L); 

	// Fill in the view matrix entries.
	float x = -XMVectorGetX(XMVector3Dot(P, R));
	float y = -XMVectorGetX(XMVector3Dot(P, U));
	float z = -XMVectorGetX(XMVector3Dot(P, L));

	XMStoreFloat3(&m_right, R);
	XMStoreFloat3(&m_up, U);
	XMStoreFloat3(&m_look, L);

    //Build the matrix
	m_view(0,0) = m_right.x; 
	m_view(1,0) = m_right.y; 
	m_view(2,0) = m_right.z; 
	m_view(3,0) = x;   

	m_view(0,1) = m_up.x;
	m_view(1,1) = m_up.y;
	m_view(2,1) = m_up.z;
	m_view(3,1) = y;  

	m_view(0,2) = m_look.x; 
	m_view(1,2) = m_look.y; 
	m_view(2,2) = m_look.z; 
	m_view(3,2) = z;   

	m_view(0,3) = 0.0f;
	m_view(1,3) = 0.0f;
	m_view(2,3) = 0.0f;
	m_view(3,3) = 1.0f;
}
Beispiel #2
0
void Camera::moveCam()
{
	XMVECTOR tempRight = XMLoadFloat3(&mRight);
	XMVECTOR tempUp = XMLoadFloat3(&mUp);
	XMVECTOR tempPosition = XMLoadFloat3(&mPosition);
	XMVECTOR tempForward = XMLoadFloat3(&mLook);
	



	//set the camera to look at the character
	camTarget = playerPosition;






	XMVECTOR tempTarget = XMLoadFloat3(&camTarget);

	tempTarget = XMVectorSetY(tempTarget,10);


	
	//rotate camera around the character
	camRotationMatrix = XMMatrixRotationRollPitchYaw(-camPitch, camYaw, 0);
	tempPosition = XMVector3TransformNormal(PlayerForward, camRotationMatrix);
	tempPosition = XMVector3Normalize(tempPosition);


	tempPosition = (tempPosition * -50) + tempTarget;
		
	tempPosition = XMVectorSetY(tempPosition, 30.0f);

	tempForward = XMVector3Normalize(tempTarget - tempPosition);	// Get forward vector based on target
	tempForward = XMVectorSetY(tempForward, 0.0f);	// set forwards y component to 0 so it lays only on

	tempForward= XMVector3Normalize(tempForward);

	tempRight = XMVectorSet(XMVectorGetZ(-tempForward), 0.0f, XMVectorGetX(tempForward), 0.0f);

	tempUp = XMVector3Normalize(XMVector3Cross(XMVector3Normalize(tempPosition - tempTarget), tempRight));



	XMStoreFloat3(&mRight, tempRight);
	XMStoreFloat3(&mUp, tempUp);
	XMStoreFloat3(&mPosition, tempPosition);
	XMStoreFloat3(&mLook, tempForward);

	XMMATRIX tempView = XMLoadFloat4x4(&mView);


	tempView = XMMatrixLookAtLH(tempPosition, tempTarget, tempUp);

	XMStoreFloat4x4(&mView, tempView);

	///////////mising some code maybe
}
void		CFVec4::SetXY( CFVec2Arg fv2Source )
{
	const XMVECTOR& v2V = *reinterpret_cast<const XMVECTOR*>( &fv2Source );
	XMVECTOR& v4V = *reinterpret_cast<XMVECTOR*>(this);

	v4V = XMVectorSetX( v4V, XMVectorGetX( v2V ) );
	v4V = XMVectorSetY( v4V, XMVectorGetY( v2V ) );
}
Beispiel #4
0
float BoidManager::getDistanceBetween(XMVECTOR vectorBetween)
{
	float distanceBetween;

	distanceBetween = XMVectorGetX(XMVector4Length((vectorBetween)));

	return distanceBetween;
}
Beispiel #5
0
	//---------------------------------------------------------------------
	Frustum::LocateSide Frustum::testContainState(FXMVECTOR plane, const Util::AABBPtr & aabb)
	{
		Util::real dist = XMVectorGetX(XMPlaneDotCoord(plane, aabb->getCenterPoint()));

		XMVECTOR halfSize = aabb->getHalfSize();
		Util::real maxAbsDist = abs(XMVectorGetX(plane) * XMVectorGetX(halfSize)) + 
			abs(XMVectorGetY(plane) * XMVectorGetY(halfSize)) +
			abs(XMVectorGetZ(plane) * XMVectorGetZ(halfSize));

		if (dist < -maxAbsDist)
			return LS_NEGATIVE;

		if (dist > + maxAbsDist)
			return LS_POSITIVE;

		return LS_INTERSECT;
	}
Beispiel #6
0
void Game::UpdateScene()
{
	floorWorld = XMMatrixIdentity();

	scale = XMMatrixScaling(250.0f, 1.0f, 250.0f);
	translation = XMMatrixTranslation(0.0f, 0.0f, 0.0f);

	floorWorld = scale*translation;

	//Keep the cubes rotating
	rotSpeed += .0005f;
	if (rotSpeed > 6.26f)
		rotSpeed = 0.0f;

	//When used, these matrices will rotate objects
	rotateAboutX = XMMatrixRotationAxis(rotXAxis, -rotSpeed);
	rotateAboutY = XMMatrixRotationAxis(rotYAxis, -rotSpeed);
	rotateAboutZ = XMMatrixRotationAxis(rotZAxis, -rotSpeed);

	scale = XMMatrixScaling(2, scaleY, 2);

	//Reset cubes locations
	cube1World = XMMatrixIdentity();
	cube2World = XMMatrixIdentity();

	//When used, these matrices will set an objects position
	translation = XMMatrixTranslation(-5.0f, 2.0f, 0.0f);

	//Set cube1's world space using the transformations
	cube1World = rotateAboutX * translation * scale;

	//When used, these matrices will set an objects position
	translation = XMMatrixTranslation(5.0f, 2.0f, 0.0f);

	//Set cube2's world space matrix
	cube2World = rotateAboutY * translation * scale;

	meshWorld = XMMatrixIdentity();
	
	travelSpeed += 0.0003f;
	//Setting meshes scale, translation and rotation
	scale = XMMatrixScaling(0.2f,0.2f,0.2f);
	translation = XMMatrixTranslation(-travelSpeed, 0.0f, 0.0f);
	rotation = XMMatrixRotationRollPitchYaw(0, XMConvertToRadians(180), 0);

	meshWorld = translation * rotation * scale;

	//Reset sphereWorld
	sphereWorld = XMMatrixIdentity();

	//Define sphereWorld's world space matrix
	scale = XMMatrixScaling(5.0f, 5.0f, 5.0f);
	//Make sure the sphere is always centered around camera
	translation = XMMatrixTranslation(XMVectorGetX(camPosition), XMVectorGetY(camPosition), XMVectorGetZ(camPosition));

	//Set sphereWorld's world space using the transformations
	sphereWorld = scale * translation;
}
void Camera::UpdateViewMatrix()
{
	XMVECTOR R = XMLoadFloat3(&mRight);
	XMVECTOR U = XMLoadFloat3(&mUp);
	XMVECTOR L = XMLoadFloat3(&mLook);
	XMVECTOR P = XMLoadFloat3(&mPosition);

	// Keep camera's axes orthogonal to each other and of unit length.
	L = XMVector3Normalize(L);
	U = XMVector3Normalize(XMVector3Cross(L, R));

	// U, L already ortho-normal, so no need to normalize cross product.
	R = XMVector3Cross(U, L); 

	// Fill in the view matrix entries.
	float x = -XMVectorGetX(XMVector3Dot(P, R));
	float y = -XMVectorGetX(XMVector3Dot(P, U));
	float z = -XMVectorGetX(XMVector3Dot(P, L));

	XMStoreFloat3(&mRight, R);
	XMStoreFloat3(&mUp, U);
	XMStoreFloat3(&mLook, L);

	mView(0,0) = mRight.x; 
	mView(1,0) = mRight.y; 
	mView(2,0) = mRight.z; 
	mView(3,0) = x;   

	mView(0,1) = mUp.x;
	mView(1,1) = mUp.y;
	mView(2,1) = mUp.z;
	mView(3,1) = y;  

	mView(0,2) = mLook.x; 
	mView(1,2) = mLook.y; 
	mView(2,2) = mLook.z; 
	mView(3,2) = z;   

	mView(0,3) = 0.0f;
	mView(1,3) = 0.0f;
	mView(2,3) = 0.0f;
	mView(3,3) = 1.0f;

	mSphereCollider.Center = mPosition;
}
void	CFVec4::Normalise( FLOAT32 &fMagnitude )
{
	XMVECTOR& v4V = *reinterpret_cast<XMVECTOR*>( this );

	//TODO: Is there a cheaper way of doing this?
	fMagnitude = XMVectorGetX( XMVector3Length( v4V ) );

	v4V = XMVector3Normalize( v4V );
}
FLOAT32		CFVec4::Distance( CFVec4Arg fv4To ) const
{
	CFVec4 v4Temp;
	v4Temp = fv4To - *this;

	XMVECTOR& v4V = *reinterpret_cast<XMVECTOR*>( &v4Temp );

	return XMVectorGetX( XMVector4Length( v4V ) );
}
void		CFVec4::SetXYZ( CFVec3Arg fv3Source )
{
	const XMVECTOR& v3V = *reinterpret_cast<const XMVECTOR*>( &fv3Source );
	XMVECTOR& v4V = *reinterpret_cast<XMVECTOR*>(this);

	v4V = XMVectorSetX( v4V, XMVectorGetX( v3V ) );
	v4V = XMVectorSetY( v4V, XMVectorGetY( v3V ) );
	v4V = XMVectorSetZ( v4V, XMVectorGetZ( v3V ) );
}
Beispiel #11
0
XMFLOAT3 CineCameraClass::StrafeRight()
{
	wchar_t* outstring = L"CineCameraClass::Strafe Right\n";
	WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), outstring, wcslen(outstring), NULL, NULL);

	XMVECTOR sideWaysVector = XMVector3Normalize(XMVector3Cross(XMLoadFloat3(&upDirection), XMLoadFloat3(&direction) ));

	return XMFLOAT3(XMVectorGetX(sideWaysVector) * STRAFE_SPEED, XMVectorGetY(sideWaysVector) * STRAFE_SPEED, XMVectorGetZ(sideWaysVector) * STRAFE_SPEED);
}
Beispiel #12
0
//-----------------------------------------------------------------------------
// Name: Bound::operator*
// Desc: transforms the bound by the current matrix
//-----------------------------------------------------------------------------
Bound Bound::operator*( CXMMATRIX World ) const
{
    //$OPTIMIZE: store matrix decomposed    
    XMVECTOR Translation = World.r[3];
    FLOAT Scale = XMVectorGetX( XMVector3Length( World.r[2] ) );
    XMVECTOR Rotation = XMQuaternionNormalize( XMQuaternionRotationMatrix( World ) );

    // switch based off this bounds type and call the correct
    // bound transform function
    switch( m_Type )
    {
        case Bound::Sphere_Bound:
        {
            Sphere WorldSphere = GetSphere();
            TransformSphere( &WorldSphere,
                             &WorldSphere,
                             Scale,
                             Rotation,
                             Translation );
            return Bound( WorldSphere );
        }
        case Bound::Frustum_Bound:
        {
            Frustum WorldFrustum = GetFrustum();
            TransformFrustum( &WorldFrustum,
                              &WorldFrustum,
                              Scale,
                              Rotation,
                              Translation );
            return Bound( WorldFrustum );
        }
        case Bound::OBB_Bound:
        {
            OrientedBox WorldObb = GetObb();
            TransformOrientedBox( &WorldObb,
                                  &WorldObb,
                                  Scale,
                                  Rotation,
                                  Translation );
            return Bound( WorldObb );
        }
        case Bound::AABB_Bound:
        {
            AxisAlignedBox WorldAabb = GetAabb();
            TransformAxisAlignedBox( &WorldAabb,
                                     &WorldAabb,
                                     Scale,
                                     Rotation,
                                     Translation );
            return Bound( WorldAabb );
        }
        case Bound::No_Bound:
            return Bound();
    }

    return Bound();
}
Beispiel #13
0
float ObjectToCamera(XMFLOAT4X4* _objMatrix, XMFLOAT3 _cameraPos)
{
	XMVECTOR obj = XMVectorZero();
	obj = XMVector3Transform(obj, XMLoadFloat4x4(_objMatrix));
	float ObjtoCameraX = XMVectorGetX(obj) - _cameraPos.x;
	float ObjtoCameraY = XMVectorGetY(obj) - _cameraPos.y;
	float ObjtoCameraZ = XMVectorGetZ(obj) - _cameraPos.z;
	return ObjtoCameraX*ObjtoCameraX + ObjtoCameraY*ObjtoCameraY + ObjtoCameraZ*ObjtoCameraZ;
}
Beispiel #14
0
//ALEX OWEN - 26/01/15 - set the position with a vector
void GameObject::setRotationVec(FXMVECTOR _rotation)
{
	rotation.x = XMVectorGetX(_rotation);
	rotation.y = XMVectorGetY(_rotation);
	rotation.z = XMVectorGetZ(_rotation);
	updated = true;
	transformed = true;

}
Beispiel #15
0
inline BOOL checkOctreeInCamSphere(const Engine::Octree *octree, const Engine::PerspCamera *cam)
{
	const XMVECTOR octree_position = XMLoadFloat3(&octree->position);
	const FLOAT distance = XMVectorGetX(XMVector3Length(octree_position - cam->getFrusSpherePosition()));

	if (distance < octree->radius + cam->getFrusSphereRadius())
		return TRUE;
	return FALSE;
}
Beispiel #16
0
		void invert(float* determinant = nullptr)
		{
			XMVECTOR det;
			*this = XMMatrixInverse(&det, *this);
			if (determinant)
			{
				*determinant = XMVectorGetX(det);
			}
		}
Beispiel #17
0
//ALEX OWEN - 26/01/15 - set the position with a vector
void GameObject::setPositionVec(FXMVECTOR _position)
{
	position.x = XMVectorGetX(_position);
	position.y = XMVectorGetY(_position);
	position.z = XMVectorGetZ(_position);
	updated = true;
	transformed = true;

}
Beispiel #18
0
XMFLOAT3 CineCameraClass::MoveBackward()
{
	wchar_t* outstring = L"CineCameraClass::Move Backward\n";
	WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), outstring, wcslen(outstring), NULL, NULL);
	
	XMVECTOR sideWaysVector = XMVector3Normalize(XMVector3Cross(XMLoadFloat3(&upDirection), XMLoadFloat3(&direction) ));
	XMVECTOR forwardVector = XMVector3Normalize(XMVector3Cross(XMLoadFloat3(&trueUpDirection), sideWaysVector ));
		
	return XMFLOAT3(XMVectorGetX(forwardVector) * ADVANCE_SPEED, XMVectorGetY(forwardVector) * ADVANCE_SPEED, XMVectorGetZ(forwardVector) * ADVANCE_SPEED);
}
Beispiel #19
0
void Camera::UpdateViewMatrix()
{
    XMVECTOR R = XMLoadFloat3(&m_right);
    XMVECTOR U = XMLoadFloat3(&m_up);
    XMVECTOR L = XMLoadFloat3(&m_look);
    XMVECTOR P = XMLoadFloat3(&m_position);

    // Keep camera's axes orthogonal to each other and of unit length.
    L = XMVector3Normalize(L);
    U = XMVector3Normalize(XMVector3Cross(L, R));

    // U, L already ortho-normal, so no need to normalize cross product.
    R = XMVector3Cross(U, L);

    // Fill in the view matrix entries.
    FLOAT x = -XMVectorGetX(XMVector3Dot(P, R));
    FLOAT y = -XMVectorGetX(XMVector3Dot(P, U));
    FLOAT z = -XMVectorGetX(XMVector3Dot(P, L));

    XMStoreFloat3(&m_right, R);
    XMStoreFloat3(&m_up, U);
    XMStoreFloat3(&m_look, L);

    m_view(0, 0) = m_right.x;
    m_view(1, 0) = m_right.y;
    m_view(2, 0) = m_right.z;
    m_view(3, 0) = x;

    m_view(0, 1) = m_up.x;
    m_view(1, 1) = m_up.y;
    m_view(2, 1) = m_up.z;
    m_view(3, 1) = y;

    m_view(0, 2) = m_look.x;
    m_view(1, 2) = m_look.y;
    m_view(2, 2) = m_look.z;
    m_view(3, 2) = z;

    m_view(0, 3) = 0.0f;
    m_view(1, 3) = 0.0f;
    m_view(2, 3) = 0.0f;
    m_view(3, 3) = 1.0f;
}
Beispiel #20
0
void CGUIShaderDX::Project(float &x, float &y, float &z)
{
  XMVECTOR vLocation = { x, y, z };
  XMVECTOR vScreenCoord = XMVector3Project(vLocation, m_cbViewPort.TopLeftX, m_cbViewPort.TopLeftY, 
                                           m_cbViewPort.Width, m_cbViewPort.Height, 0, 1, 
                                           m_cbWorldViewProj.projection, m_cbWorldViewProj.view, m_cbWorldViewProj.world);
  x = XMVectorGetX(vScreenCoord);
  y = XMVectorGetY(vScreenCoord);
  z = 0;
}
Beispiel #21
0
		Matrix inverse(float* determinant = nullptr) const
		{
			XMVECTOR det;
			XMMATRIX mat = XMMatrixInverse(&det, *this);
			if (determinant)
			{
				*determinant = XMVectorGetX(det);
			}
			return static_cast<Matrix>(mat);
		}
Beispiel #22
0
	void LightPoint::update_radius() {
		XMVECTOR v = colorv();
		float r = XMVectorGetX(v);
		float g = XMVectorGetY(v);
		float b = XMVectorGetZ(v);
		float max = std::fmaxf(std::fmaxf(r, g), b);
		m_radius = (-m_linear +
					std::sqrtf(m_linear * m_linear -
							   4 * m_quadratic * (m_constant - 256.0f * intensity() * max)))
			/ (2 * m_quadratic);
	}
void CubeMesh::PreLoad(XCVec4 initialPosition, XCVec4 initialRotation, XCVec4 initialScaling, Material material, Texture2D* texture, RasterType rasterType)
{
    m_currentPosition = initialPosition;
    m_MTranslation = XMMatrixTranslation(XMVectorGetX(initialPosition), XMVectorGetY(initialPosition), XMVectorGetZ(initialPosition));
    ApplyRotation(initialRotation);
    m_material = material;
    if (m_texture)
        m_texture = texture;
    m_rasterType = rasterType;
    Logger("[CubeMesh] Preload done");
}
Beispiel #24
0
//--------------------------------------------------------------------------------------
// Name: NuiMenu::GetXYForVector()
// Desc: Map normalized space coordinates to screen space.
//--------------------------------------------------------------------------------------
XMFLOAT2 NuiMenu::GetXYForVector( FXMVECTOR vNormalizedSpace ) const
{
    assert( m_dwBackBufferWidth  > 0 );
    assert( m_dwBackBufferHeight > 0 );

    XMFLOAT2 rt;
    rt.x = XMVectorGetX( vNormalizedSpace ) * m_dwBackBufferWidth + m_dwBackBufferWidth;
    rt.y = m_dwBackBufferHeight - ( XMVectorGetY( vNormalizedSpace ) * m_dwBackBufferHeight / 2 + m_dwBackBufferHeight / 2 );

    return rt;
}
Beispiel #25
0
_Use_decl_annotations_
bool __vectorcall ShapeCast(const XMFLOAT3& posA, const XMFLOAT3& moveA, SupportMapping* supA,
                            const XMFLOAT3& posB, const XMFLOAT3& moveB, SupportMapping* supB,
                            XMFLOAT3* normal, float* distance)
{
    XMVECTOR s = XMLoadFloat3(&posA);
    XMVECTOR r = XMVectorSubtract(XMLoadFloat3(&moveA), XMLoadFloat3(&moveB));

    XMVECTOR lambda = XMVectorZero();
    XMVECTOR x = s;
    XMVECTOR v = x - XMLoadFloat3(&posB);
    XMVECTOR vDotR;
    XMVECTOR p;
    XMVECTOR w;

    XMVECTOR simplexP[5] = {};
    uint32_t bits = 0;

    *distance = 0.0f;
    *normal = XMFLOAT3(0, 0, 0);

    XMVECTOR e2 = g_XMEpsilon * g_XMEpsilon;
    uint32_t iterations = 0;
    while (XMVector2Greater(XMVector3LengthSq(v), e2) && iterations++ < 1000)
    {
        v = XMVector3Normalize(v);
        p = supA->GetSupportPoint(v) + supB->GetSupportPoint(v);
        w = x - p;
        if (XMVector2Greater(XMVector3Dot(v, w), XMVectorZero()))
        {
            vDotR = XMVector3Dot(v, r);
            if (XMVector2GreaterOrEqual(vDotR, XMVectorZero()))
            {
                return false;
            }

            lambda = lambda - XMVector3Dot(v, w) / vDotR;
            if (XMVector2Greater(lambda, XMVectorSet(1, 1, 1, 1)))
            {
                return false;
            }

            x = s + lambda * r;
            XMStoreFloat3(normal, v);
        }

        AddPoint(simplexP, p, &bits);
        v = FindSupportVectorAndReduce(simplexP, x, &bits);
    }

    *distance = XMVectorGetX(lambda);

    return true;
}
Beispiel #26
0
void Scene::render()
{
	t.begin();

	DirectX11Core::clearRenderTargetViews();

	terrain.draw();
	box.draw();
	sphere.draw();
	car.draw();

	static float f = 0.0f; f += 0.001f;

	Input::update();

	//cbl.lightPosW = XMFLOAT3(-2 * sin(f), 2 * cos(f), -1);
	
	cbl.lightPosW = XMFLOAT3(XMVectorGetX(c->getPos()), XMVectorGetY(c->getPos()), XMVectorGetZ(c->getPos()));

	DirectX11Core::mDeviceContext->UpdateSubresource(light, 0, 0, &cbl, 0, 0);
	DirectX11Core::mDeviceContext->VSSetConstantBuffers(2, 1, &light);

	float lr = 0, bf = 0, dt = t.getDelta(), factor = 4.5f;
	if (Input::isKeyDown(DIK_W)) {
		bf = dt * factor;
	}
	else if (Input::isKeyDown(DIK_S)) {
		bf = -dt * factor;
	}
	if (Input::isKeyDown(DIK_A)) {
		lr = -dt * factor;
	}
	else if (Input::isKeyDown(DIK_D)) {
		lr = dt * factor;
	}
	static float yaw = 0, pitch = 0, mouseFactor = 1.2f;
	yaw += Input::getMouseX() * dt * mouseFactor;
	pitch += Input::getMouseY() * dt * mouseFactor;
	c->update(lr, bf, yaw, pitch);

	s.draw(c->getPos());

	DirectX11Core::endScene();
	t.end(1);

	FrameStats fs = t.getStats();
	std::wstring s = L"FPS: ";
	s.append(std::to_wstring((int)fs.fps));
	s.append(L" frametime: ");
	s.append(std::to_wstring(fs.msPerFrame));
	s.append(L" (ms)");
	SetWindowText(DirectX11Core::mWindow, s.c_str());
}
Beispiel #27
0
void CameraHandler::updateCamera(float dt, InputHandler* inputH, GroundModel*model) {

	float speed = 90000;

	if (inputH->IsKeyDown(87)) {	//W
		this->moveBackForward += dt/speed;
	}

	if (inputH->IsKeyDown(83)) {	//S
		this->moveBackForward -= dt/speed;
	}

	if (inputH->IsKeyDown(65)) {	//A
		this->moveLeftRight -= dt/speed;
	}

	if (inputH->IsKeyDown(68)) {	//D
		this->moveLeftRight += dt/speed;
	}

	if (inputH->IsKeyReleased(VK_SPACE)) {	//SPACE
		if (this->lockToTerrain == true) {
			this->lockToTerrain = false;
		}
		else {
			this->lockToTerrain = true;
		}
	}

	if (inputH->IsKeyDown(49)) {	//1
		this->moveUpDown += dt / speed;
	}

	if (inputH->IsKeyDown(50)) {	//2
		this->moveUpDown -= dt/speed;
	}
	
	if (this->lockToTerrain == true) {
		this->CameraMeshIntersect(model);
	}
	
	//Change Pitch/yaw values depending on mouse movement
	this->camPitch += (XMVectorGetY(inputH->GetMouseDeltaPos()) * 0.005);
	if (this->camPitch > 1.5f) {
		this->camPitch = 1.5f;
	}
	else if (this->camPitch < -1.5f) {
		this->camPitch = -1.5f;
	}
	this->camYaw += (XMVectorGetX(inputH->GetMouseDeltaPos()) * 0.005);

	return;
}
Beispiel #28
0
void Small::Draw()
{
	if (TeamID == NONE)
	{
		renderTexture(PlayerTex, Renderer, (XMVectorGetX(Location) - 4.0f), (XMVectorGetY(Location) - 4.0f));
	}
	else if (TeamID == RED)
	{
		renderTexture(RedTex, Renderer, (XMVectorGetX(Location) - 4.0f), (XMVectorGetY(Location) - 4.0f));
	}
	else //(TeamID == BLUE)
	{
		renderTexture(BlueTex, Renderer, (XMVectorGetX(Location) - 4.0f), (XMVectorGetY(Location) - 4.0f));
	}

	//renderTexture(PointingTex, Renderer, (XMVectorGetX(PointingOneLocation) - 8.0f), (XMVectorGetY(PointingOneLocation) - 8.0f));
	if (TeamID != NONE)
	{
		renderTexture(PointingTex, Renderer, (XMVectorGetX(PointingTwoLocation) - 2.0f), (XMVectorGetY(PointingTwoLocation) - 2.0f));
	}
}
Beispiel #29
0
inline BOOL checkOctreeInCamFrus(const Engine::Octree *octree, const Engine::PerspCamera *cam)
{
	const XMVECTOR camera_position = cam->getCameraPosition();
	const XMVECTOR view_vector = cam->getViewVector();
	const FLOAT fov_2 = cam->getFOV() / 2;

	XMVECTOR position = XMLoadFloat3(&octree->position);
	XMVECTOR direction = XMVector3Normalize(position - camera_position);
	FLOAT dot = XMVectorGetX(XMVector3Dot(view_vector, direction));

	if (acosf(dot) < fov_2) return TRUE;
	for (INT i = 0; i < 8; i++)
	{
		position = XMLoadFloat3(&octree->vertex[i]);
		direction = XMVector3Normalize(position - camera_position);
		dot = XMVectorGetX(XMVector3Dot(view_vector, direction));

		if (acosf(dot) < fov_2) return TRUE;
	}
	return FALSE;
}
void D3DCamera::Move_Z(float d)
{
    //m_Position += d*m_LookAt;

    // Set the current world matrix to the identity matrix
    m_WorldMatrix = XMMatrixIdentity();

    XMMATRIX temp = XMMatrixTranslation(XMVectorGetX(m_Position), XMVectorGetY(m_Position), XMVectorGetZ(m_Position));

    // Scale the temporary matrix
    m_WorldMatrix *= temp * m_ViewMatrix * m_ProjMatrix;
}