Commit b5576f6c authored by Nicolas Van der Noot's avatar Nicolas Van der Noot
Browse files

separate class mbs reader

parent d3e6bf3f
......@@ -95,6 +95,7 @@ if (FLAG_OPEN_GL)
include_directories("./open_gl/loader")
include_directories("./open_gl/loader/manual/vrml")
include_directories("./open_gl/loader/obj")
include_directories("./open_gl/mbs_read")
include_directories("./open_gl/shaders")
include_directories("./open_gl/shapes")
include_directories("./open_gl/shapes/specific")
......
This diff is collapsed.
/*!
* \author Nicolas Van der Noot
* \file MbsRead.hh
* \brief MbsRead class
*/
#ifdef OPEN_GL
#ifndef _MBS_READ_HH_
#define _MBS_READ_HH_
#include <vector>
#include <libxml/tree.h>
#include <string>
namespace OpenGLMbs{
// forward declaration
class Mbs3DComponent;
class Base3D;
class AnchorPoint3D;
class Joint3D;
class Body3D;
class MbsShape3D;
class MbsViewPoint;
class MbsPointLight;
class MbsSpotLight;
class MbsDirLight;
class MbsWorld3D;
/*! \brief read a .mbs file and extract the visu information
*/
class MbsRead
{
public:
MbsRead(MbsWorld3D *world_3d);
~MbsRead();
Base3D* AddSingleMbs(const char* mbs_filename);
private:
MbsWorld3D *world_3d; ///< world 3D
// function prototypes
xmlNodePtr FirstNode(xmlNodePtr node, const char* node_name);
xmlNodePtr FirstNodeLevel2(xmlNodePtr node, const char* name_1, const char* name_2);
xmlNodePtr FirstNodeLevel3(xmlNodePtr node, const char* name_1, const char* name_2, const char* name_3);
void ListNodes(xmlNodePtr parent_node, const char* node_name, std::vector<xmlNodePtr> &node_list);
float FloatNode(xmlNodePtr node, xmlDocPtr doc);
float FloatAttr(xmlAttr* attr, xmlDocPtr doc);
float FloatChild(xmlNodePtr parent_node, xmlDocPtr doc, const char *child_name);
void XYZChild(xmlNodePtr parent_node, xmlDocPtr doc, float &x, float &y, float &z);
void AttChild(xmlNodePtr parent_node, xmlDocPtr doc, float &x, float &y, float &z);
void RGBAttr(xmlNodePtr node, xmlDocPtr doc, float &R_col, float &G_col, float &B_col);
AnchorPoint3D* PointExtract(xmlNodePtr point_node, xmlDocPtr doc, Body3D *cur_body);
Joint3D* JointExtract(xmlNodePtr joint_node, xmlDocPtr doc, Mbs3DComponent *parent, std::vector<Joint3D*> &joint_list);
MbsShape3D* ShapeExtract(xmlNodePtr shape_node, xmlDocPtr doc, Body3D *cur_body, std::string prj_path);
MbsViewPoint* ViewPointExtract(xmlNodePtr view_node, xmlDocPtr doc, Base3D *base);
MbsPointLight* PointLightExtract(xmlNodePtr light_node, xmlDocPtr doc, Base3D *base);
MbsSpotLight* SpotLightExtract(xmlNodePtr light_node, xmlDocPtr doc, Base3D *base);
MbsDirLight* DirLightExtract(xmlNodePtr light_node, xmlDocPtr doc, Base3D *base);
Mbs3DComponent* ParentLocate(xmlNodePtr node, xmlDocPtr doc, Base3D *base);
};
}
#endif
#endif
......@@ -12,9 +12,9 @@
#include "MbsViewPoint.hh"
#include "MbsShape3D.hh"
#include "Base3D.hh"
#include "MbsRead.hh"
#include <vector>
#include <libxml/tree.h>
// forward declaration
class GLFWwindow;
......@@ -83,6 +83,12 @@ class MbsWorld3D
/// get the current view
MbsViewPoint* GetCurView() { return view_list[cur_view]; }
// add a joint list corresponding to a single .mbs file
void AddJointList(std::vector<Joint3D*> const& joint_list)
{
joint_tab.push_back(joint_list);
}
void Update();
void UpdateTime();
int CheckClose();
......@@ -157,6 +163,8 @@ class MbsWorld3D
glm::vec3 const& z_up, float FoV_rad);
private:
MbsRead mbs_read; ///< .mbs reader
GLFWwindow *win; ///< main visualizatin window
std::vector<MbsViewPoint*> view_list; ///< list of viewpoints
......@@ -178,32 +186,6 @@ class MbsWorld3D
int x_width; ///< screen width along the X axis (in pixels)
int y_width; ///< screen width along the Y axis (in pixels)
// function prototype
Base3D* AddSingleMbs(const char* mbs_filename);
xmlNodePtr FirstNode(xmlNodePtr node, const char* node_name);
xmlNodePtr FirstNodeLevel2(xmlNodePtr node, const char* name_1, const char* name_2);
xmlNodePtr FirstNodeLevel3(xmlNodePtr node, const char* name_1, const char* name_2, const char* name_3);
void ListNodes(xmlNodePtr parent_node, const char* node_name, std::vector<xmlNodePtr> &node_list);
float FloatNode(xmlNodePtr node, xmlDocPtr doc);
float FloatAttr(xmlAttr* attr, xmlDocPtr doc);
float FloatChild(xmlNodePtr parent_node, xmlDocPtr doc, const char *child_name);
void XYZChild(xmlNodePtr parent_node, xmlDocPtr doc, float &x, float &y, float &z);
void AttChild(xmlNodePtr parent_node, xmlDocPtr doc, float &x, float &y, float &z);
void RGBAttr(xmlNodePtr node, xmlDocPtr doc, float &R_col, float &G_col, float &B_col);
AnchorPoint3D* PointExtract(xmlNodePtr point_node, xmlDocPtr doc, Body3D *cur_body);
Joint3D* JointExtract(xmlNodePtr joint_node, xmlDocPtr doc, Mbs3DComponent *parent, std::vector<Joint3D*> &joint_list);
MbsShape3D* ShapeExtract(xmlNodePtr shape_node, xmlDocPtr doc, Body3D *cur_body, std::string prj_path);
MbsViewPoint* ViewPointExtract(xmlNodePtr view_node, xmlDocPtr doc, Base3D *base);
MbsPointLight* PointLightExtract(xmlNodePtr light_node, xmlDocPtr doc, Base3D *base);
MbsSpotLight* SpotLightExtract(xmlNodePtr light_node, xmlDocPtr doc, Base3D *base);
MbsDirLight* DirLightExtract(xmlNodePtr light_node, xmlDocPtr doc, Base3D *base);
Mbs3DComponent* ParentLocate(xmlNodePtr node, xmlDocPtr doc, Base3D *base);
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment