Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 03 April 2012 - 11:16 AM
Posted 03 April 2012 - 01:10 PM
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
Posted 04 April 2012 - 02:09 AM
ICameraManager* cameras = taskData->m_pRenderingService->getCameraManager(); ICentredCamera* camera = cameras->getCentredCamera(); // horizontal rotation animation camera->setHorizontalRotation(camera->getHorizontalRotation() + 0.01); // camera zoom animation if(camera->getRadius() >= 30.0f) { camera->setRadius(10.0f); } else { camera->setRadius(camera->getRadius() + 0.01f); }
#include "CentredCameraWrapper.h" namespace GEngine_Graphics { CentredCameraWrapper::CentredCameraWrapper(Camera* cameraToWrap) { GEngineNonZeroAssert(cameraToWrap, L"No camera passed to CentredCameraWrapper constructor", L"No Camera"); m_pWrappedCamera = cameraToWrap; m_horizontalRotation = 0.0f; m_verticalRotation = D3DX_PI / 2.0f; m_radius = 1.0f; } CentredCameraWrapper::~CentredCameraWrapper() { } void CentredCameraWrapper::setMatrices() { m_pWrappedCamera->setMatrices(); } D3DXVECTOR3* CentredCameraWrapper::getCameraPosition() { return m_pWrappedCamera->getCameraPosition(); } D3DXMATRIXA16* CentredCameraWrapper::getViewMatrix() { return m_pWrappedCamera->getViewMatrix(); } D3DXMATRIXA16* CentredCameraWrapper::getProjectionMatrix() { return m_pWrappedCamera->getProjectionMatrix(); } void CentredCameraWrapper::setAsActive() { VectorUtilities::setVector(m_pWrappedCamera->getCameraTarget(), 0.0f, 0.0f, 0.0f); VectorUtilities::setVector(m_pWrappedCamera->getCameraUp(), 0.0f, 1.0f, 0.0f); updateCameraVectors(); } /* sets the horizontal rotation of the camera Parameter list rotation: to horizontal rotation of the camera */ void CentredCameraWrapper::setHorizontalRotation(float rotation) { m_horizontalRotation = fmod(rotation, 2.0f * (float)D3DX_PI); updateCameraVectors(); } /* sets the vertical rotation of the camera Parameter list rotation: to vertical rotation of the camera */ void CentredCameraWrapper::setVerticalRotation(float rotation) { m_verticalRotation = rotation; if (m_verticalRotation > D3DX_PI) { m_verticalRotation = D3DX_PI; } else if (m_verticalRotation < 0.0f) { m_verticalRotation = 0.0f; } updateCameraVectors(); } void CentredCameraWrapper::setRadius(float radius) { m_radius = radius; // do not let the radius equal 0!!! If the camera position is the same as it's lookat position the view matrix will break!! if (m_radius <= 1.0f) { m_radius = 1.0f; } updateCameraVectors(); } float CentredCameraWrapper::getHorizontalRotation() { return m_horizontalRotation; } float CentredCameraWrapper::getVerticalRotation() { return m_verticalRotation; } float CentredCameraWrapper::getRadius() { return m_radius; } /* recalculates and updates the camera vectors */ void CentredCameraWrapper::updateCameraVectors() { D3DXVECTOR3 forward(sinf(m_horizontalRotation), cosf(m_verticalRotation), cosf(m_horizontalRotation)); D3DXVec3Normalize(&forward, &forward); VectorUtilities::setVector( m_pWrappedCamera->getCameraPosition(), m_radius * forward.x, m_radius * forward.y, m_radius * forward.z); } }
// LCCREDIT start of 3DGraph1 #include "Camera.h" /*----------------------------------------------------------------------------\ * Initialisation and Clean up | *----------------------------------------------------------------------------*/ #define DEFAULT_CAMERA_FOV D3DX_PI / 4.0f #define DEFAULT_CAMERA_NEAR_PLANE 1.0f #define DEFAULT_CAMERA_FAR_PLANE 1000.0f #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 namespace GEngine_Graphics { /* Constructs and initialises a camera object */ Camera::Camera() { m_cameraPosition = D3DXVECTOR3( 0.0f, 0.0f, -1.0f ); m_cameraTarget = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); m_cameraUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); m_nearPlane = DEFAULT_CAMERA_NEAR_PLANE; m_farPlane = DEFAULT_CAMERA_FAR_PLANE; m_fieldOfView = DEFAULT_CAMERA_FOV; m_aspectRatio = (float)SCREEN_WIDTH / (float)SCREEN_HEIGHT; setMatrices(); } /* Destructs a camera object */ Camera::~Camera() { } /*----------------------------------------------------------------------------\ * Transformation pipeline code | *----------------------------------------------------------------------------*/ /* Sets the view and projection transformation matrices. */ void Camera::setMatrices() { setViewMatrix(); setProjectionMatrix(); } /* Sets the view transformation matrix. */ void Camera::setViewMatrix() { D3DXMatrixLookAtLH( &m_viewMatrix, &m_cameraPosition, &m_cameraTarget, &m_cameraUp ); } /* Sets the projection transformation matrix. */ void Camera::setProjectionMatrix() { D3DXMatrixPerspectiveFovLH( &m_projectionMatrix, m_fieldOfView, m_aspectRatio, m_nearPlane, m_farPlane ); } D3DXMATRIXA16* Camera::getViewMatrix() { return &m_viewMatrix; } D3DXMATRIXA16* Camera::getProjectionMatrix() { return &m_projectionMatrix; } D3DXVECTOR3* Camera::getCameraPosition() { return &m_cameraPosition; } D3DXVECTOR3* Camera::getCameraTarget() { return &m_cameraTarget; } D3DXVECTOR3* Camera::getCameraUp() { return &m_cameraUp; } float Camera::getNearClipPlane() { return m_nearPlane; } float Camera::getFarClipPlane() { return m_farPlane; } float Camera::getFieldOfView() { return m_fieldOfView; } void Camera::setNearClipPlane(float value) { m_nearPlane = value; } void Camera::setFarClipPlane(float value) { m_farPlane = value; } void Camera::setFieldOfView(float value) { m_fieldOfView = value; } } // end of 3DGraph1
Posted 04 April 2012 - 04:36 AM
Posted 04 April 2012 - 06:04 AM
Posted 04 April 2012 - 07:50 AM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.