]> git.mxchange.org Git - flightgear.git/commitdiff
Moved src/Model/loader.[ch]xx and src/Model/model.[ch]xx to
authorcurt <curt>
Fri, 9 May 2003 20:40:59 +0000 (20:40 +0000)
committercurt <curt>
Fri, 9 May 2003 20:40:59 +0000 (20:40 +0000)
simgear/scene/model/

17 files changed:
src/ATC/AIEntity.hxx
src/ATC/AIPlane.hxx
src/Cockpit/hud_card.cxx
src/FDM/UFO.cxx
src/GUI/dialog.cxx
src/Main/main.cxx
src/Model/Makefile.am
src/Model/loader.cxx [deleted file]
src/Model/loader.hxx [deleted file]
src/Model/model.cxx [deleted file]
src/Model/model.hxx [deleted file]
src/Model/model_panel.cxx
src/Model/modelmgr.cxx
src/MultiPlayer/mpplayer.cxx
src/Network/multiplay.hxx
src/Objects/newmat.cxx
src/Scenery/tilemgr.cxx

index 3156c4724782ed120feb006b98e18df7dedb243b..2ff7570491d58bb68f1bd9a6b9e5bc74b57f6111 100644 (file)
 #include <plib/ssg.h>
 
 #include <simgear/math/point3d.hxx>
+#include <simgear/scene/model/model.hxx>
 #include <simgear/scene/model/placement.hxx>
 
-#include <Model/model.hxx>
-
 
 /*****************************************************************
 *
index 34e8544b011c45cae0c4cb598794773f2f1daafa..5815570eb25a6c1a502a058b2bbeab3d53fa08b7 100644 (file)
 #ifndef _FG_AI_PLANE_HXX
 #define _FG_AI_PLANE_HXX
 
-#include <Model/model.hxx>
 #include <plib/sg.h>
 #include <plib/ssg.h>
 #include <simgear/math/point3d.hxx>
+#include <simgear/scene/model/model.hxx>
 
 #include "AIEntity.hxx"
 #include "ATC.hxx"
index 303b7ff80748b3058e9774018c7f65f7596eb310..ca153418eb90672ee70bd939990f73c566d4cb57 100644 (file)
@@ -435,7 +435,7 @@ draw( void ) //  (HUD_scale * pscale )
             i = (int)vmin; // N
 
             if(zoom ==1) { 
-                zoomed_scale(vmin,vmax); //suma
+                zoomed_scale((int)vmin,(int)vmax); //suma
             } else {
                 for( ; i <last ; i++ ) {
                     condition = true;
@@ -742,7 +742,7 @@ draw( void ) //  (HUD_scale * pscale )
             //  i    = FloatToInt(vmin);
 
             if(zoom ==1) {  
-                zoomed_scale(vmin,vmax); //suma
+                zoomed_scale((int)vmin,(int)vmax); //suma
             } else  { 
                 //default to zoom=0
                 last = (int)vmax + 1;
@@ -909,7 +909,7 @@ zoomed_scale(int first, int last)
     RECT   scrn_rect = get_location();
     UINT options     = get_options();
     char TextScale[80];
-    int disp_val = 0;
+    // int disp_val = 0;
     int data[80];
  
     float x,y,w,h,bottom;
index ca9b773a7dee5b407bebadeb93b0527e5943cbb0..48e77c48768b49136ed40399d13d748f7776e9f3 100644 (file)
@@ -62,8 +62,6 @@ void FGUFO::update( double dt ) {
     if (is_suspended())
       return;
 
-    int multiloop = _calc_multiloop(dt);
-
     double time_step = dt;
 
     // read the throttle
index c5191099061b0433582be8fc8f956a64cd9bd12d..5370e2a22c3f2dd406bc0b320336b237fd3d288a 100644 (file)
@@ -291,7 +291,7 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
             value_nodes.push_back(selection_node->getChild(q));
 
         char ** entries = make_char_array(value_nodes.size());
-        for (int i = 0, j = value_nodes.size() - 1;
+        for (unsigned int i = 0, j = value_nodes.size() - 1;
              i < value_nodes.size();
              i++, j--)
             entries[i] = strdup((char *)value_nodes[i]->getName());
index 8be4d24f59a5f1eb4e25201892498ba641a4d924..a42fc242e034b26788d2f8cc771db60d64ab5588 100644 (file)
@@ -78,7 +78,9 @@ SG_USING_STD(endl);
 #include <simgear/math/sg_random.h>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/model/animation.hxx>
+#include <simgear/scene/model/loader.hxx>
 #include <simgear/scene/model/location.hxx>
+#include <simgear/scene/model/model.hxx>
 #ifdef FG_USE_CLOUDS_3D
 #  include <simgear/sky/clouds3d/SkySceneLoader.hpp>
 #  include <simgear/sky/clouds3d/SkyUtil.hpp>
@@ -104,8 +106,6 @@ SG_USING_STD(endl);
 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
 #include <GUI/gui.h>
 #include <Model/acmodel.hxx>
-#include <Model/loader.hxx>
-#include <Model/model.hxx>
 #include <Model/modelmgr.hxx>
 #include <Model/panelnode.hxx>
 #ifdef FG_NETWORK_OLK
index b08a8e6895b927e23711568a21f3aa408547925a..d763d443ea0da4bf3c8ac7b0b17cb6b45cb07258 100644 (file)
@@ -2,8 +2,6 @@ noinst_LIBRARIES = libModel.a
 
 libModel_a_SOURCES = \
         acmodel.cxx acmodel.hxx \
-       loader.cxx loader.hxx \
-       model.cxx model.hxx \
        model_panel.cxx model_panel.hxx \
         modelmgr.cxx modelmgr.hxx \
         panelnode.cxx panelnode.hxx
diff --git a/src/Model/loader.cxx b/src/Model/loader.cxx
deleted file mode 100644 (file)
index 2dad98b..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-// loader.cxx - implement SSG model and texture loaders.
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <simgear/compiler.h>
-#include <simgear/props/props.hxx>
-
-#include "loader.hxx"
-#include "model.hxx"
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSSGLoader.
-////////////////////////////////////////////////////////////////////////
-
-FGSSGLoader::FGSSGLoader ()
-{
-    // no op
-}
-
-FGSSGLoader::~FGSSGLoader ()
-{
-    std::map<string, ssgBase *>::iterator it = _table.begin();
-    while (it != _table.end()) {
-        it->second->deRef();
-        _table.erase(it);
-    }
-}
-
-void
-FGSSGLoader::flush ()
-{
-    std::map<string, ssgBase *>::iterator it = _table.begin();
-    while (it != _table.end()) {
-        ssgBase * item = it->second;
-                                // If there is only one reference, it's
-                                // ours; no one else is using the item.
-        if (item->getRef() == 1) {
-            item->deRef();
-            _table.erase(it);
-        }
-        it++;
-    }
-}
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGModelLoader.
-////////////////////////////////////////////////////////////////////////
-
-FGModelLoader::FGModelLoader ()
-{
-}
-
-FGModelLoader::~FGModelLoader ()
-{
-}
-
-ssgEntity *
-FGModelLoader::load_model( const string &fg_root,
-                           const string &path,
-                           SGPropertyNode *prop_root,
-                           double sim_time_sec )
-{
-                                // FIXME: normalize path to
-                                // avoid duplicates.
-    std::map<string, ssgBase *>::iterator it = _table.find(path);
-    if (it == _table.end()) {
-        _table[path] = fgLoad3DModel( fg_root, path, prop_root, sim_time_sec );
-        it = _table.find(path);
-        it->second->ref();      // add one reference to keep it around
-    }
-    return (ssgEntity *)it->second;
-}
-
-
-// end of loader.cxx
diff --git a/src/Model/loader.hxx b/src/Model/loader.hxx
deleted file mode 100644 (file)
index af50ff7..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef __MODEL_LOADER_HXX
-#define __MODEL_LOADER_HXX 1
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include <simgear/compiler.h>  // for SG_USING_STD
-
-#include <map>
-SG_USING_STD(map);
-
-#include <string>
-SG_USING_STD(string);
-
-#include <plib/ssg.h>
-
-
-/**
- * Base class for loading and managing SSG things.
- */
-class FGSSGLoader
-{
-public:
-    FGSSGLoader ();
-    virtual ~FGSSGLoader ();
-    virtual void flush ();
-protected:
-    std::map<string,ssgBase *> _table;
-};
-
-
-/**
- * Class for loading and managing models with XML wrappers.
- */
-class FGModelLoader : public FGSSGLoader
-{
-public:
-    FGModelLoader ();
-    virtual ~FGModelLoader ();
-
-    virtual ssgEntity * load_model( const string &fg_root,
-                                    const string &path,
-                                    SGPropertyNode *prop_root,
-                                    double sim_time_sec );
-};
-
-
-#endif
diff --git a/src/Model/model.cxx b/src/Model/model.cxx
deleted file mode 100644 (file)
index cbc8ac8..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-// model.cxx - manage a 3D aircraft model.
-// Written by David Megginson, started 2002.
-//
-// This file is in the Public Domain, and comes with no warranty.
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <simgear/compiler.h>
-
-#include <string.h>             // for strcmp()
-
-#include <vector>
-
-#include <plib/sg.h>
-#include <plib/ssg.h>
-#include <plib/ul.h>
-
-#include <simgear/misc/exception.hxx>
-#include <simgear/misc/sg_path.hxx>
-#include <simgear/props/props.hxx>
-#include <simgear/props/props_io.hxx>
-#include <simgear/scene/model/animation.hxx>
-
-#include "model.hxx"
-
-SG_USING_STD(vector);
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Static utility functions.
-////////////////////////////////////////////////////////////////////////
-
-/**
- * Callback to update an animation.
- */
-static int
-animation_callback (ssgEntity * entity, int mask)
-{
-    ((Animation *)entity->getUserData())->update();
-    return true;
-}
-
-
-/**
- * Locate a named SSG node in a branch.
- */
-static ssgEntity *
-find_named_node (ssgEntity * node, const char * name)
-{
-  char * node_name = node->getName();
-  if (node_name != 0 && !strcmp(name, node_name))
-    return node;
-  else if (node->isAKindOf(ssgTypeBranch())) {
-    int nKids = node->getNumKids();
-    for (int i = 0; i < nKids; i++) {
-      ssgEntity * result =
-        find_named_node(((ssgBranch*)node)->getKid(i), name);
-      if (result != 0)
-        return result;
-    }
-  } 
-  return 0;
-}
-
-/**
- * Splice a branch in between all child nodes and their parents.
- */
-static void
-splice_branch (ssgBranch * branch, ssgEntity * child)
-{
-  int nParents = child->getNumParents();
-  branch->addKid(child);
-  for (int i = 0; i < nParents; i++) {
-    ssgBranch * parent = child->getParent(i);
-    parent->replaceKid(child, branch);
-  }
-}
-
-/**
- * Make an offset matrix from rotations and position offset.
- */
-void
-fgMakeOffsetsMatrix( sgMat4 * result, double h_rot, double p_rot, double r_rot,
-                     double x_off, double y_off, double z_off )
-{
-  sgMat4 rot_matrix;
-  sgMat4 pos_matrix;
-  sgMakeRotMat4(rot_matrix, h_rot, p_rot, r_rot);
-  sgMakeTransMat4(pos_matrix, x_off, y_off, z_off);
-  sgMultMat4(*result, pos_matrix, rot_matrix);
-}
-
-
-void
-fgMakeAnimation( ssgBranch * model,
-                 const char * name,
-                 vector<SGPropertyNode_ptr> &name_nodes,
-                 SGPropertyNode *prop_root,
-                 SGPropertyNode_ptr node,
-                 double sim_time_sec )
-{
-  Animation * animation = 0;
-  const char * type = node->getStringValue("type", "none");
-  if (!strcmp("none", type)) {
-    animation = new NullAnimation(node);
-  } else if (!strcmp("range", type)) {
-    animation = new RangeAnimation(node);
-  } else if (!strcmp("billboard", type)) {
-    animation = new BillboardAnimation(node);
-  } else if (!strcmp("select", type)) {
-    animation = new SelectAnimation(prop_root, node);
-  } else if (!strcmp("spin", type)) {
-    animation = new SpinAnimation(prop_root, node, sim_time_sec );
-  } else if (!strcmp("timed", type)) {
-    animation = new TimedAnimation(node);
-  } else if (!strcmp("rotate", type)) {
-    animation = new RotateAnimation(prop_root, node);
-  } else if (!strcmp("translate", type)) {
-    animation = new TranslateAnimation(prop_root, node);
-  } else {
-    animation = new NullAnimation(node);
-    SG_LOG(SG_INPUT, SG_WARN, "Unknown animation type " << type);
-  }
-
-  if (name != 0)
-      animation->setName((char *)name);
-
-  ssgEntity * object;
-  if (name_nodes.size() > 0) {
-    object = find_named_node(model, name_nodes[0]->getStringValue());
-    if (object == 0) {
-      SG_LOG(SG_INPUT, SG_WARN, "Object " << name_nodes[0]->getStringValue()
-             << " not found");
-      delete animation;
-      animation = 0;
-    }
-  } else {
-    object = model;
-  }
-  
-  ssgBranch * branch = animation->getBranch();
-  splice_branch(branch, object);
-
-  for (unsigned int i = 1; i < name_nodes.size(); i++) {
-      const char * name = name_nodes[i]->getStringValue();
-      object = find_named_node(model, name);
-      if (object == 0) {
-          SG_LOG(SG_INPUT, SG_WARN, "Object " << name << " not found");
-          delete animation;
-          animation = 0;
-      }
-      ssgBranch * oldParent = object->getParent(0);
-      branch->addKid(object);
-      oldParent->removeKid(object);
-  }
-
-  animation->init();
-  branch->setUserData(animation);
-  branch->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback);
-}
-
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Global functions.
-////////////////////////////////////////////////////////////////////////
-
-ssgBranch *
-fgLoad3DModel( const string &fg_root, const string &path,
-               SGPropertyNode *prop_root,
-               double sim_time_sec )
-{
-  ssgBranch * model = 0;
-  SGPropertyNode props;
-
-                                // Load the 3D aircraft object itself
-  SGPath xmlpath;
-  SGPath modelpath = path;
-  if ( ulIsAbsolutePathName( path.c_str() ) ) {
-    xmlpath = modelpath;
-  }
-  else {
-    xmlpath = fg_root;
-    xmlpath.append(modelpath.str());
-  }
-
-                                // Check for an XML wrapper
-  if (xmlpath.str().substr(xmlpath.str().size() - 4, 4) == ".xml") {
-    readProperties(xmlpath.str(), &props);
-    if (props.hasValue("/path")) {
-      modelpath = modelpath.dir();
-      modelpath.append(props.getStringValue("/path"));
-    } else {
-      if (model == 0)
-        model = new ssgBranch;
-    }
-  }
-
-                                // Assume that textures are in
-                                // the same location as the XML file.
-  if (model == 0) {
-    ssgTexturePath((char *)xmlpath.dir().c_str());
-    model = (ssgBranch *)ssgLoad((char *)modelpath.c_str());
-    if (model == 0)
-      throw sg_exception("Failed to load 3D model");
-  }
-
-                                // Set up the alignment node
-  ssgTransform * alignmainmodel = new ssgTransform;
-  alignmainmodel->addKid(model);
-  sgMat4 res_matrix;
-  fgMakeOffsetsMatrix(&res_matrix,
-                      props.getFloatValue("/offsets/heading-deg", 0.0),
-                      props.getFloatValue("/offsets/roll-deg", 0.0),
-                      props.getFloatValue("/offsets/pitch-deg", 0.0),
-                      props.getFloatValue("/offsets/x-m", 0.0),
-                      props.getFloatValue("/offsets/y-m", 0.0),
-                      props.getFloatValue("/offsets/z-m", 0.0));
-  alignmainmodel->setTransform(res_matrix);
-
-  unsigned int i;
-
-                                // Load animations
-  vector<SGPropertyNode_ptr> animation_nodes = props.getChildren("animation");
-  for (i = 0; i < animation_nodes.size(); i++) {
-    const char * name = animation_nodes[i]->getStringValue("name", 0);
-    vector<SGPropertyNode_ptr> name_nodes =
-      animation_nodes[i]->getChildren("object-name");
-    fgMakeAnimation( model, name, name_nodes, prop_root, animation_nodes[i],
-                     sim_time_sec);
-  }
-
-                                // Load sub-models
-  vector<SGPropertyNode_ptr> model_nodes = props.getChildren("model");
-  for (i = 0; i < model_nodes.size(); i++) {
-    SGPropertyNode_ptr node = model_nodes[i];
-    ssgTransform * align = new ssgTransform;
-    sgMat4 res_matrix;
-    fgMakeOffsetsMatrix(&res_matrix,
-                        node->getFloatValue("offsets/heading-deg", 0.0),
-                        node->getFloatValue("offsets/roll-deg", 0.0),
-                        node->getFloatValue("offsets/pitch-deg", 0.0),
-                        node->getFloatValue("offsets/x-m", 0.0),
-                        node->getFloatValue("offsets/y-m", 0.0),
-                        node->getFloatValue("offsets/z-m", 0.0));
-    align->setTransform(res_matrix);
-
-    ssgBranch * kid = fgLoad3DModel( fg_root, node->getStringValue("path"),
-                                     prop_root, sim_time_sec );
-    align->addKid(kid);
-    model->addKid(align);
-  }
-
-  return alignmainmodel;
-}
-
-
-// end of model.cxx
diff --git a/src/Model/model.hxx b/src/Model/model.hxx
deleted file mode 100644 (file)
index 4102460..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// model.hxx - manage a 3D aircraft model.
-// Written by David Megginson, started 2002.
-//
-// This file is in the Public Domain, and comes with no warranty.
-
-#ifndef __MODEL_HXX
-#define __MODEL_HXX 1
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include <vector>
-
-SG_USING_STD(vector);
-
-#include <plib/sg.h>
-#include <plib/ssg.h>
-
-#include <simgear/props/props.hxx>
-
-
-// Has anyone done anything *really* stupid, like making min and max macros?
-#ifdef min
-#undef min
-#endif
-#ifdef max
-#undef max
-#endif
-
-
-/**
- * Load a 3D model with or without XML wrapper.  Note, this version
- * Does not know about or load the panel/cockpit information.  Use the
- * "model_panel.hxx" version if you want to load an aircraft
- * (i.e. ownship) with a panel.
- *
- * If the path ends in ".xml", then it will be used as a property-
- * list wrapper to add animations to the model.
- *
- * Subsystems should not normally invoke this function directly;
- * instead, they should use the FGModelLoader declared in loader.hxx.
- */
-ssgBranch * fgLoad3DModel( const string& fg_root, const string &path,
-                           SGPropertyNode *prop_root, double sim_time_sec );
-
-
-/**
- * Make an offset matrix from rotations and position offset.
- */
-void
-fgMakeOffsetsMatrix( sgMat4 * result, double h_rot, double p_rot, double r_rot,
-                     double x_off, double y_off, double z_off );
-
-/**
- * Make the animation
- */
-void
-fgMakeAnimation( ssgBranch * model,
-                 const char * name,
-                 vector<SGPropertyNode_ptr> &name_nodes,
-                 SGPropertyNode *prop_root,
-                 SGPropertyNode_ptr node,
-                 double sim_time_sec );
-
-
-#endif // __MODEL_HXX
index 3e09b6fffbc3231f17cffa0d29fdcf3e783b43c7..b06d83c8a6154b30b8bd67d7cd0d35268d92e85f 100644 (file)
 #include <simgear/props/props.hxx>
 #include <simgear/props/props_io.hxx>
 #include <simgear/scene/model/animation.hxx>
+#include <simgear/scene/model/model.hxx>
 
 #include "panelnode.hxx"
 
-#include "model.hxx"
 #include "model_panel.hxx"
 
 SG_USING_STD(vector);
index f178b26e9c29f2bdf371c7ab7c4ea1314b250df8..a1d92a9629ff77a9a6cfe14f7e1090c44aec8608 100644 (file)
 #include <plib/ssg.h>
 
 #include <simgear/scene/model/placement.hxx>
+#include <simgear/scene/model/model.hxx>
 
 #include <Main/fg_props.hxx>
 #include <Scenery/scenery.hxx>
 
-#include "model.hxx"
 
 #include "modelmgr.hxx"
 
index a89e373a794bbdf3a712ae86e77f42ba0784e99a..a57103f2940c1fade755588fab0752596a6d3add 100644 (file)
@@ -52,8 +52,9 @@
 #include <plib/netSocket.h>
 #include <plib/sg.h>
 
+#include <simgear/scene/model/loader.hxx>
+
 #include <Main/globals.hxx>
-#include <Model/loader.hxx>
 #include <Scenery/scenery.hxx>
 
 
index 10bea8ae16ebd504fdf2bb8d57c9c21a58f773a0..c7459e21a242a1add1a2c57dc5916f5c731179c7 100644 (file)
 
 #define FG_MULTIPLAY_HID "$Id$"
 
+#include <simgear/compiler.h>
+
 #include STL_STRING
-SG_USING_STD(string);
 
-#include "protocol.hxx"
-#include <simgear/compiler.h>
+#include <simgear/scene/model/model.hxx>
+
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <Model/acmodel.hxx>
-#include <Model/model.hxx>
 #include <MultiPlayer/multiplaytxmgr.hxx>
 #include <MultiPlayer/multiplayrxmgr.hxx>
 
+#include "protocol.hxx"
+
+SG_USING_STD(string);
+
+
 /****************************************************************
 * @version $Id$
 *
index c68eec91dcd9d954560cda2eabe09e1882608801..fe9ae938b9d20c8729ca4684ed1c5484e4747aee 100644 (file)
@@ -40,10 +40,10 @@ SG_USING_STD(map);
 #include <simgear/math/sg_random.h>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/sgstream.hxx>
+#include <simgear/scene/model/loader.hxx>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
-#include <Model/loader.hxx>
 
 #include "newmat.hxx"
 
index 6c0d106efe3ba65b80d7b9a7fcb17c29b1ad3eef..bc94fc620a22f25c1f081fa21f12aa8188d3a498 100644 (file)
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/vector.hxx>
 #include <simgear/misc/exception.hxx>
+#include <simgear/scene/model/loader.hxx>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/viewer.hxx>
-#include <Model/loader.hxx>
 #include <Objects/obj.hxx>
 
 #include "newcache.hxx"