From: Oliver O. <fr...@us...> - 2007-06-17 13:39:37
|
Update of /cvsroot/simspark/simspark/spark/oxygen/sceneserver In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv21072/oxygen/sceneserver Modified Files: camera.cpp camera.h camera_c.cpp fpscontroller.cpp Log Message: merge from projectx branch Index: camera_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/sceneserver/camera_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** camera_c.cpp 5 Dec 2005 21:21:17 -0000 1.1 --- camera_c.cpp 17 Jun 2007 13:38:32 -0000 1.2 *************** *** 163,166 **** --- 163,186 ---- } + FUNCTION(Camera,lookAt) + { + int inX; + int inY; + int inZ; + + if ( + (in.GetSize() != 3) || + (! in.GetValue(in[0],inX)) || + (! in.GetValue(in[1],inY)) || + (! in.GetValue(in[2],inZ)) + ) + { + return false; + } + + obj->LookAt(salt::Vector3f(inX,inY,inZ)); + return true; + } + void CLASS(Camera)::DefineClass() { *************** *** 179,181 **** --- 199,202 ---- DEFINE_FUNCTION(adjustZFar); DEFINE_FUNCTION(getZFar); + DEFINE_FUNCTION(lookAt); } Index: camera.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/sceneserver/camera.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** camera.h 5 Dec 2005 21:21:17 -0000 1.1 --- camera.h 17 Jun 2007 13:38:32 -0000 1.2 *************** *** 46,73 **** /** sets viewpoint properties */ void SetViewport(int x, int y, int width, int height); ! int GetViewportX(); ! int GetViewportY(); ! int GetViewportWidth(); ! int GetViewportHeight(); /** sets the field of view (FOV) */ ! void SetFOV(const float fov); /** sets the distance of the Z near plane */ ! void SetZNear(const float zNear); /** sets the distance of the Z far plane */ ! void SetZFar(const float zFar); /** adjusts the current FOV, i.e. adds a delta increment */ ! void AdjustFOV(const float fov); /** adjusts the distance of the Z near plane, i.e adds a delta increment */ ! void AdjustZNear(const float zNear); /** adjusts the distance of the Z far plane, i.e adds a delta increment */ ! void AdjustZFar(const float zFar); /** returns the field of View */ --- 46,74 ---- /** sets viewpoint properties */ void SetViewport(int x, int y, int width, int height); ! ! int GetViewportX() const; ! int GetViewportY() const; ! int GetViewportWidth() const; ! int GetViewportHeight() const; /** sets the field of view (FOV) */ ! void SetFOV(float fov); /** sets the distance of the Z near plane */ ! void SetZNear(float zNear); /** sets the distance of the Z far plane */ ! void SetZFar(float zFar); /** adjusts the current FOV, i.e. adds a delta increment */ ! void AdjustFOV(float fov); /** adjusts the distance of the Z near plane, i.e adds a delta increment */ ! void AdjustZNear(float zNear); /** adjusts the distance of the Z far plane, i.e adds a delta increment */ ! void AdjustZFar(float zFar); /** returns the field of View */ *************** *** 90,93 **** --- 91,99 ---- void DescribeFrustum(salt::Frustum& frustum) const; + /** turn the camera so that it looks to a given point. + * @param toPoint the point to look at + */ + void LookAt(const salt::Vector3f& toPoint); + /** sets the view transform to be the inverted WorldTransform and sets up the projection transform matrix Index: camera.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/sceneserver/camera.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** camera.cpp 5 Dec 2005 21:21:17 -0000 1.1 --- camera.cpp 17 Jun 2007 13:38:32 -0000 1.2 *************** *** 32,36 **** mFOV = 60.0f; mZNear = 1.0f; ! mZFar = 2000.0f; mX = 0; mY = 0; --- 32,36 ---- mFOV = 60.0f; mZNear = 1.0f; ! mZFar = 100000.0f; mX = 0; mY = 0; *************** *** 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); + } Index: fpscontroller.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/sceneserver/fpscontroller.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fpscontroller.cpp 31 Mar 2007 13:23:30 -0000 1.3 --- fpscontroller.cpp 17 Jun 2007 13:38:32 -0000 1.4 *************** *** 54,58 **** } ! void FPSController::PrepareUpdate(Matrix& matrix, Matrix& fwd, Vector3f& vec) { // determine force direction --- 54,59 ---- } ! void ! FPSController::PrepareUpdate(Matrix& matrix, Matrix& fwd, Vector3f& vec) { // determine force direction *************** *** 88,94 **** { if (mBody.get() == 0) ! { ! return; ! } Matrix matrix; --- 89,95 ---- { if (mBody.get() == 0) ! { ! return; ! } Matrix matrix; |