Skip to content

Commit

Permalink
adding updates from the BB repo to Github for V2.0.1 release CGR
Browse files Browse the repository at this point in the history
  • Loading branch information
Curtis Rubel committed Mar 29, 2016
1 parent 533060a commit b1d44d1
Show file tree
Hide file tree
Showing 84 changed files with 3,567 additions and 2,974 deletions.
68 changes: 34 additions & 34 deletions Application-A320/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
set( APP_NAME openig-demo-a320 )

set( TARGET_SRC_FILES main.cpp )
set( TARGET_OTHER_FILES DataFiles/default.txt DataFiles/openig.xml )

add_executable( ${APP_NAME} ${TARGET_SRC_FILES}
${TARGET_OTHER_FILES} )

target_link_libraries( ${APP_NAME}
${OSG_LIBRARIES}
OpenIG-Engine
)

install(
TARGETS ${APP_NAME}
RUNTIME DESTINATION bin/openig-a320 COMPONENT openig
)

set_target_properties( ${APP_NAME} PROPERTIES PROJECT_LABEL "Application A320" )

SET(INSTALL_INCDIR include)
SET(INSTALL_BINDIR bin/openig-a320)
IF(WIN32)
SET(INSTALL_LIBDIR bin)
SET(INSTALL_ARCHIVEDIR lib)
ELSE()
SET(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
SET(INSTALL_ARCHIVEDIR ${CMAKE_INSTALL_LIBDIR})
ENDIF()

install(FILES ${CMAKE_CURRENT_LIST_DIR}/DataFiles/default.txt DESTINATION ${INSTALL_BINDIR})
install(FILES ${CMAKE_CURRENT_LIST_DIR}/DataFiles/flightpath.path DESTINATION ${INSTALL_BINDIR}/demo/)
install(FILES ${CMAKE_CURRENT_LIST_DIR}/DataFiles/openig.xml DESTINATION ${INSTALL_BINDIR}/igdata/)
install(FILES ${CMAKE_CURRENT_LIST_DIR}/DataFiles/OpenIG-Splash.jpg DESTINATION ${INSTALL_BINDIR}/igdata/)
set( APP_NAME openig-demo-a320 )

set( TARGET_SRC_FILES main.cpp )
set( TARGET_OTHER_FILES DataFiles/default.txt DataFiles/openig.xml )

add_executable( ${APP_NAME} ${TARGET_SRC_FILES}
${TARGET_OTHER_FILES} )

target_link_libraries( ${APP_NAME}
${OSG_LIBRARIES}
OpenIG-Engine
)

install(
TARGETS ${APP_NAME}
RUNTIME DESTINATION bin/openig-a320 COMPONENT openig
)

set_target_properties( ${APP_NAME} PROPERTIES PROJECT_LABEL "Application A320" )

SET(INSTALL_INCDIR include)
SET(INSTALL_BINDIR bin/openig-a320)
IF(WIN32)
SET(INSTALL_LIBDIR bin)
SET(INSTALL_ARCHIVEDIR lib)
ELSE()
SET(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
SET(INSTALL_ARCHIVEDIR ${CMAKE_INSTALL_LIBDIR})
ENDIF()

install(FILES ${CMAKE_CURRENT_LIST_DIR}/DataFiles/default.txt DESTINATION ${INSTALL_BINDIR})
install(FILES ${CMAKE_CURRENT_LIST_DIR}/DataFiles/flightpath.path DESTINATION ${INSTALL_BINDIR}/demo/)
install(FILES ${CMAKE_CURRENT_LIST_DIR}/DataFiles/openig.xml DESTINATION ${INSTALL_BINDIR}/igdata/)
install(FILES ${CMAKE_CURRENT_LIST_DIR}/DataFiles/OpenIG-Splash.jpg DESTINATION ${INSTALL_BINDIR}/igdata/)
Binary file modified Application-A320/DataFiles/OpenIG-Splash.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 28 additions & 20 deletions Application-A320/DataFiles/default.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
#All platforms
addentity 2 {$OPENIG_DATA_PATH;/usr/local/database;../data}/model/radar/radar.FBX.(0.1,0.1,0.1).scale -50 50 5 0 90 0
addentity 1 {$OPENIG_DATA_PATH;/usr/local/database;../data}/model/A320/a320.ive 0 0 45.9 105 0 0
addentity 0 {$OPENIG_DATA_PATH/terrain;/data/OIG/OIG_DEMO_SC_7_NT_;../data/terrain}/master.flt.osg 0 0 0 -50.5 0 0

fpo -4 0 -37
ms SBSC_Activ 0

playanim 2 fbx:"Take 001":LOOP

manip 1 trackball

tod 4 45
fog 500000
wind 5 90
addclouds 0 4 500 3000 0.7




#All platforms
addentity 2 {$OPENIG_DATA_PATH;/usr/local/database;../data}/model/radar/radar.FBX.(0.1,0.1,0.1).scale -50 50 5 0 90 0
addentity 1 {$OPENIG_DATA_PATH;/usr/local/database;../data}/model/A320/a320.ive 0 0 10 0 0 0
addentity 0 {$OPENIG_DATA_PATH/terrain;/data/OIG/OIG_DEMO_SC_7_NT_;../data/terrain}/master.flt.osg 0 0 0 -51.1 0 0

fpo -4 0 -37
ms SBSC_Activ 0

# addentity 0 {$OPENIG_DATA_PATH/geocentric;/data/OIG/OIG_DEMO_SC_7_NT_;../data/geocentric}/master.flt.osg 0 0 0 0 0 0
# If you have Geocentric visual database
# use this command to set the zero 0,0,0
# in geographics coords. The entity will
# be placed right there
# geozero -22.943 -43.7251

playanim 2 fbx:"Take 001":LOOP

manip 1 trackball
bindcamera 1 10 30 -2 -200 0 0

tod 4 45
fog 500000
wind 5 90
addclouds 0 4 500 3000 0.7




2 changes: 1 addition & 1 deletion Application-A320/DataFiles/openig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Shadowed-GPU-Vegetation>no</Shadowed-GPU-Vegetation>
<ForwardPlusLightsLODCulling>yes</ForwardPlusLightsLODCulling>
<ForwardPlusLightsDefaultLODRange>500</ForwardPlusLightsDefaultLODRange>
<LogZDepthBuffer>yes</LogZDepthBuffer>
<LogZDepthBuffer>no</LogZDepthBuffer>
<GroupLightsBasedOnXMLDefinition>yes</GroupLightsBasedOnXMLDefinition>
<ImageGenerator-Plugins-Config>
<Plugin>
Expand Down
161 changes: 134 additions & 27 deletions Application-A320/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <osgViewer/api/Win32/GraphicsHandleWin32>
#endif


// Let make some info HUD for the keyboard bindings
// based on the osghud example
osg::Node* createInfoHUD(OpenIG::Engine* ig)
Expand Down Expand Up @@ -213,15 +214,24 @@ class CameraTrackballManipulator : public osgGA::TrackballManipulator
{
public:
CameraTrackballManipulator(bool& resetDemo, OpenIG::Base::ImageGenerator* ig)
: osgGA::TrackballManipulator()
, playbackOn(false)
, reset(resetDemo)
, startOfPauseTime(0.0)
, openIG(ig)
, fixedUpMode(false)
{
: osgGA::TrackballManipulator()
, playbackOn(false)
, reset(resetDemo)
, startOfPauseTime(0.0)
, openIG(ig)
, fixedUpMode(false)
{
}
// NOTE: It is still setting it. That's why we use EventHandler
// and we wrap this Camera Manipulator

}
// We are not going to set the ViewMatrix from the CameraManipulator
// we are setting it in the OpenIG::Engine::frame as it is bind
// to an entity
//virtual void updateCamera(osg::Camera& camera)
//{
// Do nothing here
//}

virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us)
{
Expand Down Expand Up @@ -335,6 +345,109 @@ class FlightPathOffsetCommand : public OpenIG::Base::Commands::Command
osg::Vec3& _offset;
};

// For geocentric VDB we set the local 0,0,0 in lat,lon
// via this command. Later this is used for constructing
// a Matrix that will transform us in the ECEF mode
// And this is our Matrix
static osg::Matrixd s_GeoZeroMatrix;
class SetGeocentricZeroCommand : public OpenIG::Base::Commands::Command
{
public:
// Convinient method for the onscreen
// help. This one is a must
virtual const std::string getUsage() const
{
return "latitude longitude";
}

virtual const std::string getArgumentsFormat() const
{
return "D:D";
}

// Convinient method for the onscreen
// help. This one is a must too
virtual const std::string getDescription() const
{
return "sets the local zero in geographics coordinates\n"
" latitude - in degrees\n"
" longitude - in degrees";
}

// This method is called when you invoke a command in the
// terminal, call a command through the Commands class
// tokens is std::vector<std::string> holding the arguments
// provided
virtual int exec(const OpenIG::Base::StringUtils::Tokens& tokens)
{
if (tokens.size() == 2)
{
double lat = atof(tokens.at(0).c_str());
double lon = atof(tokens.at(1).c_str());

osg::EllipsoidModel em;
em.computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(lat), osg::DegreesToRadians(lon), 0.0, s_GeoZeroMatrix);
}
return -1;
}
};

// We use the camera manipulator in a tricky way. Actually
// we take the Trackball matrix and set it as an offset
// bellow against the model, then OpenIG computes the
// right view matrix. As per osg design, the side effect
// of this is that we end up with two different ViewMatrices:
// one local to the model from the trackball, and one for
// the scene. Because of this we wrap the camera manipulator
// into EventHandler to process the events and avoid setting
// the camera view matrix based on the local trackball view matrix
struct DummyActionAdapter : public osgGA::GUIActionAdapter
{
virtual void requestRedraw() {}

virtual void requestContinuousUpdate(bool needed = true) {}

virtual void requestWarpPointer(float x, float y) {}
};
struct CameraManipulatorEventHandler : public osgGA::EventHandler
{
CameraManipulatorEventHandler(osg::ref_ptr<osgGA::CameraManipulator>& cm)
: cameraManipulator(cm)
{

}

virtual bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv)
{
osg::ref_ptr<osgGA::GUIEventAdapter> ea = dynamic_cast<osgGA::GUIEventAdapter*>(event);
if (ea.valid() && cameraManipulator.valid())
{
DummyActionAdapter us;
cameraManipulator->handle(*ea, us);

switch (ea->getEventType())
{
case(osgGA::GUIEventAdapter::FRAME) :
{
static bool firstFrame = true;
if (firstFrame)
{
firstFrame = false;
cameraManipulator->home(0.0);
}
}
break;
default:
break;
}
}
return false;
}

osg::observer_ptr<osgGA::CameraManipulator> cameraManipulator;
};


// By default, OpenIG have only one Camera Manipulator
// which is the keypad manipulator - binds the numeric
// keypad to move the camera, or entities if it is bound
Expand Down Expand Up @@ -444,10 +557,7 @@ class SetCameraManipulatorCommand : public OpenIG::Base::Commands::Command
// to the camera. We have to do this through
// the OpenIG Camera binding and update
if (manip.valid())
{
// We set the Camera Manipulator
_ig->getViewer()->getView(0)->setCameraManipulator(manip,true);

{
// Bind the camera to the a320
// Entity. We can provide offset here
// good if you would like to have pilot-view
Expand All @@ -467,6 +577,9 @@ class SetCameraManipulatorCommand : public OpenIG::Base::Commands::Command
// it is bound to an Entity
s_CameraManipulator = manip;

// We set the Camera Manipulator
_ig->getViewer()->getView(0)->addEventHandler(new CameraManipulatorEventHandler(s_CameraManipulator));

osg::notify(osg::NOTICE) << "IG: " << name << " bound to entity " << id << std::endl;
}
}
Expand Down Expand Up @@ -776,7 +889,7 @@ struct UpdateWheelUpdateCallback : public osg::NodeCallback
hat.computeIntersections(terrain);
if (hat.getNumPoints())
{
if (hat.getHeightAboveTerrain(hat.getNumPoints() - 1) > 0.6 /* this is some offset */)
if (hat.getHeightAboveTerrain(hat.getNumPoints() - 1) > 0.6 )
inTheAir = true;
else
inTheAir = false;
Expand Down Expand Up @@ -1081,7 +1194,7 @@ int main(int argc, char** argv)
view->getCamera()->setProjectionMatrixAsPerspective(50, aspectratio, 1.0, 50000);
view->getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
view->getCamera()->setCullingMode(osg::CullSettings::VIEW_FRUSTUM_CULLING);
viewer->setThreadingModel(osgViewer::ViewerBase::CullThreadPerCameraDrawThreadPerContext);
viewer->setThreadingModel(osgViewer::ViewerBase::CullDrawThreadPerContext);

}

Expand Down Expand Up @@ -1124,6 +1237,7 @@ int main(int argc, char** argv)
// Add custom commands we have for this demo
OpenIG::Base::Commands::instance()->addCommand("manip", new SetCameraManipulatorCommand(ig));
OpenIG::Base::Commands::instance()->addCommand("fpo", new FlightPathOffsetCommand(s_Offset));
OpenIG::Base::Commands::instance()->addCommand("geozero", new SetGeocentricZeroCommand);

// The scene can be defined in a startup script
// using commands. Please have a look at the
Expand Down Expand Up @@ -1344,7 +1458,7 @@ int main(int argc, char** argv)
mx = osg::Matrixd::translate(s_Offset) * mx;

// and update the model
ig->updateEntity(MODEL_ENTITY_ID,mx);
ig->updateEntity(MODEL_ENTITY_ID, mx*s_GeoZeroMatrix);
}
}

Expand Down Expand Up @@ -1401,7 +1515,7 @@ int main(int argc, char** argv)
// We update the OpenIG camera
// based on the Trackball manipulators
// camera only if we set it using our
// custom command from above
// custom command from above
if (s_CameraManipulator.valid() && ig->isCameraBoundToEntity())
{
ig->bindCameraUpdate(s_CameraManipulator->getMatrix());
Expand Down Expand Up @@ -1431,7 +1545,7 @@ int main(int argc, char** argv)
mx = osg::Matrixd::translate(s_Offset) * mx;

// and update the model
ig->updateEntity(MODEL_ENTITY_ID, mx);
ig->updateEntity(MODEL_ENTITY_ID, mx*s_GeoZeroMatrix);
}

// We hard code here something. Let make
Expand Down Expand Up @@ -1555,7 +1669,7 @@ int main(int argc, char** argv)
mx = osg::Matrixd::translate(s_Offset) * mx;

// And we update the model
ig->updateEntity(MODEL_ENTITY_ID,mx);
ig->updateEntity(MODEL_ENTITY_ID, mx*s_GeoZeroMatrix);
}

// only if playback
Expand Down Expand Up @@ -1670,7 +1784,7 @@ int main(int argc, char** argv)
mx = osg::Matrixd::translate(s_Offset) * mx;

// And we update our model.
ig->updateEntity(MODEL_ENTITY_ID,mx);
ig->updateEntity(MODEL_ENTITY_ID, mx*s_GeoZeroMatrix);

// update this
s_PlaybackStartTime = 0;
Expand Down Expand Up @@ -1736,13 +1850,6 @@ int main(int argc, char** argv)

// Here the mandatory cleanup
ig->cleanup();

// There is problem with how windows manages
// the referenced pointers accross dlls and there
// is crash on exit - this is Windows only, Linux
// and Mac are fine. So till fixed we kill it this
// way. Nick.
exit(-1);
ig = NULL;

}

Loading

0 comments on commit b1d44d1

Please sign in to comment.