From: Oliver O. <fr...@us...> - 2007-05-08 03:06:14
|
Update of /cvsroot/simspark/simspark/spark/oxygen/sceneserver In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv15342 Modified Files: Tag: projectx camera.cpp Log Message: - added LookAt() method (making the camera looking at a point) - cosmetic changes Index: camera.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/sceneserver/camera.cpp,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** camera.cpp 5 Dec 2005 21:21:17 -0000 1.1 --- camera.cpp 8 May 2007 03:06:03 -0000 1.1.4.1 *************** *** 49,53 **** transforms. It is really fast and very generic because of that. */ ! void Camera::DescribeFrustum(Frustum& frustum) const { // concatenate projection and view transform --- 49,54 ---- transforms. It is really fast and very generic because of that. */ ! void ! Camera::DescribeFrustum(Frustum& frustum) const { // concatenate projection and view transform *************** *** 91,95 **** } ! void Camera::Bind() { mViewTransform = GetWorldTransform(); --- 92,97 ---- } ! void ! Camera::Bind() { mViewTransform = GetWorldTransform(); *************** *** 106,110 **** } ! void Camera::OnLink() { bool gotSetup = --- 108,113 ---- } ! void ! Camera::OnLink() { bool gotSetup = *************** *** 121,125 **** } ! void Camera::UpdateHierarchyInternal() { // make sure values are within bounds --- 124,129 ---- } ! void ! Camera::UpdateHierarchyInternal() { // make sure values are within bounds *************** *** 130,134 **** } ! void Camera::SetViewport(int x, int y, int width, int height) { mX = x; --- 134,139 ---- } ! void ! Camera::SetViewport(int x, int y, int width, int height) { mX = x; *************** *** 138,213 **** } ! int Camera::GetViewportX() { return mX; } ! int Camera::GetViewportY() { return mY; } ! int Camera::GetViewportWidth() { return mWidth; } ! int Camera::GetViewportHeight() { return mHeight; } ! void Camera::SetFOV(const float fov) { mFOV = fov; } ! void Camera::SetZNear(const float zNear) { mZNear = zNear; } ! void Camera::SetZFar(const float zFar) { mZFar = zFar; } ! void Camera::AdjustFOV(const float fov) { mFOV+=fov; } ! void Camera::AdjustZNear(const float zNear) { mZNear+=zNear; } ! void Camera::AdjustZFar(const float zFar) { mZFar+=zFar; } ! float Camera::GetFOV() const { return mFOV; } ! float Camera::GetZNear() const { return mZNear; } ! float Camera::GetZFar()const { return mZFar; } ! const salt::Matrix& Camera::GetViewTransform() const { return mViewTransform; } ! const salt::Matrix& Camera::GetProjectionTransform() const { return mProjectionTransform; } --- 143,245 ---- } ! int ! Camera::GetViewportX() const { return mX; } ! int ! Camera::GetViewportY() const { return mY; } ! int ! Camera::GetViewportWidth() const { return mWidth; } ! int ! Camera::GetViewportHeight() const { return mHeight; } ! void ! Camera::SetFOV(float fov) { mFOV = fov; } ! void ! Camera::SetZNear(float zNear) { mZNear = zNear; } ! void ! Camera::SetZFar(float zFar) { mZFar = zFar; } ! void ! Camera::AdjustFOV(float fov) { mFOV+=fov; } ! void ! Camera::AdjustZNear(float zNear) { mZNear+=zNear; } ! void ! Camera::AdjustZFar(float zFar) { mZFar+=zFar; } ! float ! Camera::GetFOV() const { return mFOV; } ! float ! Camera::GetZNear() const { return mZNear; } ! float ! Camera::GetZFar() const { return mZFar; } ! const salt::Matrix& ! Camera::GetViewTransform() const { return mViewTransform; } ! const salt::Matrix& ! Camera::GetProjectionTransform() const { return mProjectionTransform; } + + void + Camera::LookAt(const salt::Vector3f& toPoint) + { + Matrix m; + salt::Vector3f fromPoint; + fromPoint = GetWorldTransform().Pos(); + // std::cerr << "Camera: look from " << fromPoint << " at " << toPoint << "\n"; + salt::Vector3f up(0,0,1); + m.LookAt(fromPoint, toPoint, up); + SetWorldTransform(m); + } |