[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.45,1.46 tc3DViewer.cpp,1.21,1.22 tcDirector.cpp,1.2,1.3
Status: Alpha
Brought to you by:
ddcforge
|
From: <ddc...@us...> - 2003-12-31 00:23:26
|
Update of /cvsroot/gcblue/gcb_wx/src/sim
In directory sc8-pr-cvs1:/tmp/cvs-serv31613/src/sim
Modified Files:
Game.cpp tc3DViewer.cpp tcDirector.cpp
Log Message:
More camera views
Index: Game.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** Game.cpp 29 Dec 2003 01:10:25 -0000 1.45
--- Game.cpp 31 Dec 2003 00:23:23 -0000 1.46
***************
*** 540,544 ****
wxASSERT(tacticalMap);
wxASSERT(briefingConsoleLeft);
! director = new tcDirector(tacticalMap, &mcSound, briefingConsoleLeft, this);
director->SetStartTime(0);
director->InitTest(); // load test event sequence
--- 540,544 ----
wxASSERT(tacticalMap);
wxASSERT(briefingConsoleLeft);
! director = new tcDirector(viewer, tacticalMap, &mcSound, briefingConsoleLeft, this);
director->SetStartTime(0);
director->InitTest(); // load test event sequence
***************
*** 872,875 ****
--- 872,876 ----
size3D = MODE3D_FULL;
}
+ Update3DSize();
}
Index: tc3DViewer.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tc3DViewer.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** tc3DViewer.cpp 15 Dec 2003 04:19:59 -0000 1.21
--- tc3DViewer.cpp 31 Dec 2003 00:23:23 -0000 1.22
***************
*** 216,219 ****
--- 216,228 ----
}
+ /**
+ *
+ */
+ void tc3DViewer::SetCameraMode(bool lookAt, bool moveWith)
+ {
+ lookAtTarget = lookAt;
+ moveWithTarget = moveWith;
+ }
+
void tc3DViewer::SetGameTime(double t)
{
***************
*** 223,226 ****
--- 232,258 ----
/**
+ * Sets position of camera for non-moveWithCamera modes.
+ */
+ void tc3DViewer::SetGeoPosition(double lon_rad, double lat_rad, float alt_m)
+ {
+ cameraLongitude = lon_rad;
+ cameraLatitude = lat_rad;
+ cameraAltitude = alt_m;
+ }
+
+ void tc3DViewer::SetLook(float az, float el)
+ {
+ cameraLookAz = az;
+ cameraLookEl = el;
+ }
+
+ void tc3DViewer::SetMoveWithVector(float az, float el, float range)
+ {
+ cameraAz = az;
+ cameraEl = el;
+ cameraRange = range;
+ }
+
+ /**
* Set the origin (0,0) of 3D world coordinates and
* update lonToGridX and gridXToLon scale factors which
***************
*** 432,445 ****
tcGameObject *obj = simState->GetObject(hookID);
if (!obj) return;
! cameraTarget = GetObjectPosition(obj);
! float camx = cosf(cameraEl)*sinf(cameraAz);
! float camy = cosf(cameraEl)*cosf(cameraAz);
! float camz = sinf(cameraEl);
!
! Producer::Vec3 camOffset = Producer::Vec3(camx,camy,camz)*cameraRange;
! Producer::Matrix m = Producer::Matrix::translate(camOffset);
- cameraPosition = cameraTarget*m;
camera->setViewByLookat(cameraPosition, cameraTarget, Producer::Vec3(0,0,1));
--- 464,501 ----
tcGameObject *obj = simState->GetObject(hookID);
if (!obj) return;
+
+ Producer::Vec3 targetPosition;
+ if (lookAtTarget || moveWithTarget)
+ {
+ targetPosition = GetObjectPosition(obj);
+ }
+ if (moveWithTarget)
+ {
+ float camx = cosf(cameraEl)*sinf(cameraAz);
+ float camy = cosf(cameraEl)*cosf(cameraAz);
+ float camz = sinf(cameraEl);
+ Producer::Vec3 camOffset = Producer::Vec3(camx,camy,camz)*cameraRange;
+ Producer::Matrix m = Producer::Matrix::translate(camOffset);
+ cameraPosition = targetPosition*m;
+ }
+ else
+ {
+ cameraPosition = GetCameraPosition();
+ }
! if (lookAtTarget)
! {
! cameraTarget = targetPosition;
! }
! else
! {
! float camx = cosf(cameraLookEl)*sinf(cameraLookAz);
! float camy = cosf(cameraLookEl)*cosf(cameraLookAz);
! float camz = sinf(cameraLookEl);
! Producer::Vec3 lookOffset = Producer::Vec3(camx,camy,camz);
! Producer::Matrix m = Producer::Matrix::translate(lookOffset);
! cameraTarget = cameraPosition*m;
! }
camera->setViewByLookat(cameraPosition, cameraTarget, Producer::Vec3(0,0,1));
***************
*** 538,541 ****
--- 594,609 ----
/**
+ * Converts lon/lat coords to world coords.
+ * @return camera position in world coordinates.
+ */
+ Producer::Vec3 tc3DViewer::GetCameraPosition()
+ {
+ float x = LonToX(cameraLongitude);
+ float y = LatToY(cameraLatitude);
+ float z = cameraAltitude;
+ return Producer::Vec3(x,y,z);
+ }
+
+ /**
* @return object position in world coordinates.
*/
***************
*** 772,775 ****
--- 840,850 ----
viewWireframe = false;
useRelativeChildPos = true;
+ moveWithTarget = true;
+ lookAtTarget = true;
+ cameraLongitude = 0;
+ cameraLatitude = 0;
+ cameraAltitude = 100.0f;
+ cameraLookAz = 0;
+ cameraLookEl = 0;
Index: tcDirector.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcDirector.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** tcDirector.cpp 22 Dec 2003 02:32:37 -0000 1.2
--- tcDirector.cpp 31 Dec 2003 00:23:23 -0000 1.3
***************
*** 107,113 ****
}
! tcDirector::tcDirector(tcMapView *mv, tcSound *soundInterface, tcConsole *console
, wxWindow *win)
! : mapView(mv)
{
tcSoundEvent::AttachSound(soundInterface);
--- 107,113 ----
}
! tcDirector::tcDirector(tc3DViewer *view3D, tcMapView *mv, tcSound *soundInterface, tcConsole *console
, wxWindow *win)
! : mapView(mv), viewer(view3D)
{
tcSoundEvent::AttachSound(soundInterface);
|