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

extract filepath name

parent 180bc88b
......@@ -83,6 +83,7 @@ if (FLAG_OPEN_GL)
include_directories("./open_gl")
include_directories("./open_gl/anim_read")
include_directories("./open_gl/components")
include_directories("./open_gl/interface")
include_directories("./open_gl/lights")
include_directories("./open_gl/lights/specific")
include_directories("./open_gl/loader")
......
......@@ -177,8 +177,8 @@ MbsBox* MbsWorld3D::AddBox(double d, double w, double h, glm::vec3 color, float
glm::vec3 const& trans_pos, glm::vec3 const& trans_scale, glm::vec3 const& trans_rot)
{
MbsBox *new_box = new MbsBox(d, w, h, color,
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.frag",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.frag",
this, transparency, trans_pos, trans_scale, trans_rot);
model_list.push_back(new_box);
......@@ -190,8 +190,8 @@ MbsCylinder* MbsWorld3D::AddCylinder(double r, double h, glm::vec3 color, float
glm::vec3 const& trans_pos, glm::vec3 const& trans_scale, glm::vec3 const& trans_rot)
{
MbsCylinder *new_cylinder = new MbsCylinder(r, h, color,
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.frag",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.frag",
this, transparency, trans_pos, trans_scale, trans_rot);
model_list.push_back(new_cylinder);
......@@ -203,8 +203,8 @@ MbsCone* MbsWorld3D::AddCone(double r, double h, glm::vec3 color, float transpar
glm::vec3 const& trans_pos, glm::vec3 const& trans_scale, glm::vec3 const& trans_rot)
{
MbsCone *new_cone = new MbsCone(r, h, color,
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.frag",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.frag",
this, transparency, trans_pos, trans_scale, trans_rot);
model_list.push_back(new_cone);
......@@ -216,8 +216,8 @@ MbsSphere* MbsWorld3D::AddSphere(double r, glm::vec3 color, float transparency,
glm::vec3 const& trans_pos, glm::vec3 const& trans_scale, glm::vec3 const& trans_rot)
{
MbsSphere *new_sphere = new MbsSphere(r, color,
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.frag",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.frag",
this, transparency, trans_pos, trans_scale, trans_rot);
model_list.push_back(new_sphere);
......@@ -229,8 +229,8 @@ MbsInline* MbsWorld3D::AddInline(std::string cad_file, float transparency,
glm::vec3 const& trans_pos, glm::vec3 const& trans_scale, glm::vec3 const& trans_rot)
{
MbsInline *new_inline = new MbsInline(cad_file,
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/flag_vert/basique2D.frag",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.vert",
OPEN_GL_FILES_PATH"shaders/frag_vert/basique2D.frag",
this, transparency, trans_pos, trans_scale, trans_rot);
model_list.push_back(new_inline);
......@@ -354,6 +354,22 @@ Base3D* MbsWorld3D::AddSingleMbs(const char* mbs_filename)
std::vector<xmlNodePtr> point_n_list, body_n_list, shape_n_list;
std::vector<xmlNodePtr> joint_n_list, view_n_list, light_n_list;
size_t pos;
std::string prj_path, cur_name;
// extract PRJPATH
prj_path = mbs_filename;
prj_path = prj_path.substr(0, prj_path.find_last_of("\\/"));
pos = prj_path.find_last_of("\\/");
cur_name = prj_path.substr(pos+1, prj_path.size()-pos-1);
if (!cur_name.compare("dataR"))
{
prj_path = prj_path.substr(0, prj_path.find_last_of("\\/"));
}
// base of the .mbs
base = NULL;
// ignore text nodes
......@@ -418,7 +434,7 @@ Base3D* MbsWorld3D::AddSingleMbs(const char* mbs_filename)
while (cur_node != NULL)
{
ShapeExtract(cur_node, doc, cur_body);
ShapeExtract(cur_node, doc, cur_body, prj_path);
cur_node = cur_node->next;
}
......@@ -490,7 +506,7 @@ Base3D* MbsWorld3D::AddSingleMbs(const char* mbs_filename)
while (cur_node != NULL)
{
ShapeExtract(cur_node, doc, cur_body);
ShapeExtract(cur_node, doc, cur_body, prj_path);
cur_node = cur_node->next;
}
......@@ -1014,7 +1030,7 @@ MbsPointLight* MbsWorld3D::PointLightExtract(xmlNodePtr light_node, xmlDocPtr do
return new_light;
}
MbsShape3D* MbsWorld3D::ShapeExtract(xmlNodePtr shape_node, xmlDocPtr doc, Body3D *cur_body)
MbsShape3D* MbsWorld3D::ShapeExtract(xmlNodePtr shape_node, xmlDocPtr doc, Body3D *cur_body, std::string prj_path)
{
float pos_x, pos_y, pos_z;
float sc_x, sc_y, sc_z;
......@@ -1028,7 +1044,7 @@ MbsShape3D* MbsWorld3D::ShapeExtract(xmlNodePtr shape_node, xmlDocPtr doc, Body3
size_t start_pos;
std::stringstream ss;
std::string elem_str, prj_path;
std::string elem_str, prj_path_name;
xmlNodePtr cur_node;
......@@ -1214,14 +1230,13 @@ MbsShape3D* MbsWorld3D::ShapeExtract(xmlNodePtr shape_node, xmlDocPtr doc, Body3
ss << (const char*) elem_val;
ss >> elem_str;
prj_path = "PRJPATH";
prj_path_name = "PRJPATH";
start_pos = elem_str.find(prj_path);
start_pos = elem_str.find(prj_path_name);
if(start_pos != std::string::npos)
{
//elem_str.replace(start_pos, prj_path.length(), std::string(PROJECT_SOURCE_DIR) + "/..");
elem_str.replace(start_pos, prj_path.length(), ".."); // TEMPORARY
elem_str.replace(start_pos, prj_path_name.length(), prj_path + "/");
}
new_shape_3d = AddInline((const char*) elem_str.c_str(), transp,
......
......@@ -155,7 +155,7 @@ class MbsWorld3D
AnchorPoint3D* PointExtract(xmlNodePtr point_node, xmlDocPtr doc, Body3D *cur_body);
Joint3D* JointExtract(xmlNodePtr joint_node, xmlDocPtr doc, Mbs3DComponent *parent);
MbsShape3D* ShapeExtract(xmlNodePtr shape_node, xmlDocPtr doc, Body3D *cur_body);
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);
......
......@@ -13,6 +13,9 @@
#include "events_sdl.h"
#endif
//#include "java_functions.h"
//#include "open_gl_c_int.h"
#ifdef SDL
/*! \brief initialize SDL real-time variables
......@@ -188,7 +191,7 @@ Realtime_visu* init_realtime_visu(void *realtime_options, MbsData* mbs_data)
#if (defined JAVA)
init_jni(visu, nb_models, nb_q, visu->cur_q, options->mbs_file, options->start_viewpoint);
#elif (defined OPEN_GL)
init_open_gl(visu, nb_models, nb_q, visu->cur_q, options->mbs_file, options->start_viewpoint);
#endif
return visu;
......@@ -229,7 +232,7 @@ void free_realtime_visu(Realtime_visu *visu)
#if (defined JAVA)
free_jni(visu->visu_class);
#elif (defined OPEN_GL)
free_open_gl(visu->visu_class);
#endif
free(visu);
......
......@@ -35,7 +35,7 @@ if(FLAG_SHARED_LIB)
install (TARGETS ${LIB_MBSYSC_UTILITIES} DESTINATION ${CMAKE_INSTALL_PREFIX})
else( )
add_library(${LIB_MBSYSC_UTILITIES} STATIC ${SOURCE_FILES} ${INCLUDE_DIR})
add_definitions( -DMBSYSC_UTILITIES_STATIC_DEFINE)
add_definitions( -DMBSYSC_UTILITIES_STATIC_DEFINE)
endif( )
set(LIB_MBSYSC_UTILITIES_PATH ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
......
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