[Gcblue-commits] gcb_wx/src/sim tc3DViewer.cpp,1.22,1.23 tcDirector.cpp,1.4,1.5 tcDirectorEvent.cpp,
Status: Alpha
Brought to you by:
ddcforge
|
From: <ddc...@us...> - 2004-01-01 23:46:36
|
Update of /cvsroot/gcblue/gcb_wx/src/sim
In directory sc8-pr-cvs1:/tmp/cvs-serv6686/src/sim
Modified Files:
tc3DViewer.cpp tcDirector.cpp tcDirectorEvent.cpp
tcScenarioSelectView.cpp tcSimState.cpp
Log Message:
more briefing and scenario generation features
Index: tc3DViewer.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tc3DViewer.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** tc3DViewer.cpp 31 Dec 2003 00:23:23 -0000 1.22
--- tc3DViewer.cpp 1 Jan 2004 23:44:47 -0000 1.23
***************
*** 103,106 ****
--- 103,110 ----
}
+ /**
+ * Need to generalize this to handle different types of camera
+ * moves.
+ */
void tc3DViewer::OnLButtonDown(wxMouseEvent& event)
{
***************
*** 110,113 ****
--- 114,118 ----
azStart = cameraAz;
elStart = cameraEl;
+ usePolarOffset = true;
}
***************
*** 225,228 ****
--- 230,239 ----
}
+ void tc3DViewer::SetCartesianOffset(float x, float y, float z)
+ {
+ cameraPositionOffset.set(x, y, z);
+ usePolarOffset = false;
+ }
+
void tc3DViewer::SetGameTime(double t)
{
***************
*** 247,255 ****
}
! void tc3DViewer::SetMoveWithVector(float az, float el, float range)
{
cameraAz = az;
cameraEl = el;
cameraRange = range;
}
--- 258,267 ----
}
! void tc3DViewer::SetPolarOffset(float az, float el, float range)
{
cameraAz = az;
cameraEl = el;
cameraRange = range;
+ usePolarOffset = true;
}
***************
*** 308,311 ****
--- 320,337 ----
+ /**
+ * Adds text drawable to textGeode. Take care with reference count
+ * issues with doing it this way.
+ */
+ void tc3DViewer::AddText(osgText::Text *text)
+ {
+ textGeode->addDrawable(text);
+ }
+
+
+ void tc3DViewer::RemoveText(osgText::Text *text)
+ {
+ textGeode->removeDrawable(text);
+ }
void tc3DViewer::CreateScene()
***************
*** 472,479 ****
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;
--- 498,513 ----
if (moveWithTarget)
{
! Producer::Vec3 camOffset;
! if (usePolarOffset)
! {
! float camx = cosf(cameraEl)*sinf(cameraAz);
! float camy = cosf(cameraEl)*cosf(cameraAz);
! float camz = sinf(cameraEl);
! camOffset = Producer::Vec3(camx,camy,camz)*cameraRange;
! }
! else
! {
! camOffset = cameraPositionOffset;
! }
Producer::Matrix m = Producer::Matrix::translate(camOffset);
cameraPosition = targetPosition*m;
***************
*** 842,845 ****
--- 876,880 ----
moveWithTarget = true;
lookAtTarget = true;
+ usePolarOffset = true;
cameraLongitude = 0;
cameraLatitude = 0;
Index: tcDirector.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcDirector.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** tcDirector.cpp 31 Dec 2003 17:34:10 -0000 1.4
--- tcDirector.cpp 1 Jan 2004 23:44:47 -0000 1.5
***************
*** 80,98 ****
AddEvent(new tcConsoleTextEvent("Engage enemy to the Northwest",5));
! AddEvent(new tcMapViewEvent(mapView, 9, -5.9, 49.5, 4.0));
! AddEvent(new tcSoundEffectEvent(9,SEFFECT_THUCK));
! AddEvent(new tcMapTextEvent(mapView,"OPFOR",9.0,25.0f,-6.0, 49.9,1));
AddEvent(new tcConsoleTextEvent("",12));
! AddEvent(new tcConsoleTextEvent("Enemy is believed to be a medium sized task force",16));
! AddEvent(new tcConsoleTextEvent("similar in makeup to your own.",16));
! AddEvent(new tcConsoleTextEvent("",20));
! AddEvent(new tcConsoleTextEvent("Extreme caution is advised",20));
! AddEvent(new tcConsoleTextEvent("",22));
! AddEvent(new tcConsoleTextEvent("Good hunting",22));
! AddEvent(new tcGameCommandEvent(ID_SETPAUSE, 25 , 0));
! AddEvent(new tcGameCommandEvent(ID_SETBRIEFING, 25, 0));
! AddEvent(new tcGameCommandEvent(ID_SET3D, 25, 1)); // deactivate 3D window
//AddEvent(new tcMapViewEvent(mapView, 24, -5.9, 49.5, 4.0));
}
--- 80,98 ----
AddEvent(new tcConsoleTextEvent("Engage enemy to the Northwest",5));
! AddEvent(new tcMapViewEvent(mapView, 7, -5.9, 49.5, 4.0));
! AddEvent(new tcSoundEffectEvent(7,SEFFECT_THUCK));
! AddEvent(new tcMapTextEvent(mapView,"OPFOR",7.0,18.0f,-6.0, 49.9,1));
+ AddEvent(new tcConsoleTextEvent("",9));
+ AddEvent(new tcConsoleTextEvent("Enemy is believed to be a medium sized task force",9));
+ AddEvent(new tcConsoleTextEvent("similar in makeup to your own.",9));
AddEvent(new tcConsoleTextEvent("",12));
! AddEvent(new tcConsoleTextEvent("Extreme caution is advised",12));
! AddEvent(new tcConsoleTextEvent("",13));
! AddEvent(new tcConsoleTextEvent("Good hunting",13));
! AddEvent(new tcGameCommandEvent(ID_SETPAUSE, 18 , 0));
! AddEvent(new tcGameCommandEvent(ID_SETBRIEFING, 18, 0));
! AddEvent(new tcGameCommandEvent(ID_SET3D, 18, 1)); // deactivate 3D window
//AddEvent(new tcMapViewEvent(mapView, 24, -5.9, 49.5, 4.0));
}
Index: tcDirectorEvent.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcDirectorEvent.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tcDirectorEvent.cpp 31 Dec 2003 17:34:10 -0000 1.3
--- tcDirectorEvent.cpp 1 Jan 2004 23:44:47 -0000 1.4
***************
*** 36,39 ****
--- 36,41 ----
#include "tc3DViewer.h"
#include "math_constants.h"
+ #include <osgText/Text>
+ #include <osg/Vec3> // tc3DTextEvent
using MapView::tcMapView;
***************
*** 353,357 ****
float range = startRange + k*(stopRange - startRange);
! viewer->SetMoveWithVector(az, el, range);
}
--- 355,359 ----
float range = startRange + k*(stopRange - startRange);
! viewer->SetPolarOffset(az, el, range);
}
***************
*** 375,377 ****
tcFlybyCameraEvent::~tcFlybyCameraEvent()
{
! }
\ No newline at end of file
--- 377,496 ----
tcFlybyCameraEvent::~tcFlybyCameraEvent()
{
! }
!
! /********** tcTrackCameraEvent *****************/
! void tcTrackCameraEvent::Update(double t)
! {
! tcCameraEvent::Update(t);
!
! if (!triggered) return;
! if (t > eventStop) return;
!
! float k = (eventStart == eventStop) ? 0 : (t - eventStart)/(eventStop - eventStart);
! float x = startX + k*(stopX - startX);
! float y = startY + k*(stopY - startY);
! float z = startZ + k*(stopZ - startZ);
!
! viewer->SetCartesianOffset(x, y, z);
! }
!
! tcTrackCameraEvent::tcTrackCameraEvent(double tStart, double tStop, long targID,
! float x1, float x2, float y1, float y2, float z1, float z2 )
! : tcCameraEvent(tStart,tStop)
! {
! targetID = targID;
! moveWithTarget = true;
! lookAtTarget = true;
!
! startX = x1;
! startY = y1;
! startZ = z1;
! stopX = x2;
! stopY = y2;
! stopZ = z2;
! }
!
! tcTrackCameraEvent::~tcTrackCameraEvent()
! {
! }
!
! /******** tc3DTextEvent *************/
!
! void tc3DTextEvent::Update(double t)
! {
! if (t >= eventStop)
! {
! if (unsigned nParents = viewerText->getNumParents())
! {
! wxASSERT(nParents == 1);
! viewer->RemoveText(viewerText.get());
! }
! return;
! }
! else if (t >= eventStart)
! {
! if (viewerText->getNumParents() == 0)
! {
! wxSize viewerSize = viewer->GetSize();
! float x = textx * (float)viewerSize.GetWidth();
! float y = texty * (float)viewerSize.GetHeight();
! viewerText->setPosition(osg::Vec3(x,y,0.0f));
! viewer->AddText(viewerText.get());
! }
! if (effectCode == 1) // alpha blend
! {
! double tspan = eventStop - eventStart;
! double dt = t - eventStart;
! double tfract = (tspan != 0) ? dt/tspan : 1.0f; // fraction of active time span
! double alpha;
!
! const float a = 0.2;
! const float ainv = 1.0/a;
!
! if (tfract < a)
! alpha = ainv*tfract;
! else if (tfract > (1.0f-a))
! alpha = ainv*(1-tfract);
! else
! alpha = 1.0;
!
! viewerText->setColor(osg::Vec4(1.0f,1.0f,1.0f,alpha));
! }
!
! }
! }
!
! /**
! * x and y are normalized to screen width and height, e.g. 0.5, 0.5 is center of
! * screen.
! */
! tc3DTextEvent::tc3DTextEvent(std::string text, double startTime, double endTime,
! float x, float y, float size, int effect)
! : tcCameraEvent(startTime, endTime)
! {
! theText = text;
! fontSize = size;
! textx = x;
! texty = y;
! effectCode = effect;
!
! viewerText = new osgText::Text;
! osgText::Font* font = osgText::readFontFile("fonts/arial.ttf");
! osg::Vec4 layoutColor(1.0f,1.0f,1.0f,1.0f);
!
! viewerText->setFont(font);
! viewerText->setColor(layoutColor);
! viewerText->setCharacterSize(fontSize, 1.2f); // font height, aspect ratio
! viewerText->setPosition(osg::Vec3(40,40,0.0f));
! viewerText->setLayout(osgText::Text::LEFT_TO_RIGHT);
! viewerText->setFontResolution(32,32);
! viewerText->setText(theText.c_str());
! }
!
! /**
! * viewerText automatically deleted via ref_ptr
! */
! tc3DTextEvent::~tc3DTextEvent()
! {
! }
!
Index: tcScenarioSelectView.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcScenarioSelectView.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** tcScenarioSelectView.cpp 29 Dec 2003 01:10:25 -0000 1.11
--- tcScenarioSelectView.cpp 1 Jan 2004 23:44:47 -0000 1.12
***************
*** 350,353 ****
--- 350,360 ----
path += caption->GetBuffer();
mpSimState->mpPythonInterface->LoadScenario(path.c_str(),caption->GetBuffer());
+ if (!mpSimState->msScenarioInfo.mbLoaded)
+ {
+ wxString s =
+ wxString::Format("Error in scenario %s. Check pyerr.txt for details.",
+ path.c_str());
+ wxMessageBox(s.c_str(),"Error",wxICON_ERROR);
+ }
}
}
Index: tcSimState.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** tcSimState.cpp 29 Dec 2003 01:10:25 -0000 1.19
--- tcSimState.cpp 1 Jan 2004 23:44:47 -0000 1.20
***************
*** 1395,1402 ****
tnPoolIndex nKey;
- maPlatformState.GetNextAssoc(pos,nKey,obj);
for (unsigned i=0;i<nSize;i++)
{
maPlatformState.GetNextAssoc(pos,nKey,obj);
if (unitName == obj->mzUnit.mz)
{
--- 1395,1402 ----
tnPoolIndex nKey;
for (unsigned i=0;i<nSize;i++)
{
maPlatformState.GetNextAssoc(pos,nKey,obj);
+ wxASSERT(obj);
if (unitName == obj->mzUnit.mz)
{
***************
*** 1461,1465 ****
tnPoolIndex nKey;
! int k = rand() % nSize;
maPlatformState.GetNextAssoc(cmappos,nKey,pplat);
for (int i=0;i<k;i++) {
--- 1461,1465 ----
tnPoolIndex nKey;
! int k = rand() % nSize; // k [0,nSize-1]
maPlatformState.GetNextAssoc(cmappos,nKey,pplat);
for (int i=0;i<k;i++) {
|