Commit 8fcbd143 authored by gllm's avatar gllm
Browse files

example_client: reintroduction du modele comme outil de calibration

parent 5fc8d9f6
ofxAssimpModelLoader
ofxPoco
ofxIO
ofxMiniPID
......
#
## Alias OBJ Material File
# Exported from SketchUp, (c) 2000-2012 Trimble Navigation Limited
newmtl _17
Ka 0.000000 0.000000 0.000000
Kd 0.321569 0.321569 0.321569
Ks 0.330000 0.330000 0.330000
d 0.360237
# Alias OBJ Model File
# Exported from SketchUp, (c) 2000-2012 Trimble Navigation Limited
# File units = millimeters
mtllib marqueurs_mesh.mtl
g Mesh1 jardin Model
usemtl _17
v -1330 290 0
vt 0 0
vn 0 0 -1
v -1000 290 0
vt 0 12.9921
v -1000 -290 0
vt -22.8346 12.9921
v -1330 -290 0
vt -22.8346 -4.26326e-14
f 1/1/1 2/2/1 3/3/1 4/4/1
vn -1.64071e-15 1 0
v -1330 290 440
vt 0 17.3228
v -1000 290 440
vt -12.9921 17.3228
vt -12.9921 0
f 1/1/2 5/5/2 6/6/2 2/7/2
vn -1 -6.22337e-16 0
vt 22.8346 0
v -1330 -290 440
vt 22.8346 17.3228
f 5/5/3 1/1/3 4/8/3 7/9/3
vt 12.9921 0
vn 1.64071e-15 -1 0
v -1000 -290 440
vt 12.9921 17.3228
vt -4.17533e-14 17.3228
vt -4.17533e-14 0
f 3/10/4 8/11/4 7/12/4 4/13/4
vt -22.8346 17.3228
vn 1 1.86701e-15 0
vt -22.8346 0
vt -2.43992e-15 0
vt -2.43992e-15 17.3228
f 8/14/5 3/15/5 2/16/5 6/17/5
vt 22.8346 12.9921
vn 0 0 1
vt 22.8346 -4.26326e-14
f 8/18/6 6/2/6 5/1/6 7/19/6
g Mesh2 court Model
v 1000 290 4.74829e-14
v 1330 290 4.74829e-14
v 1330 -290 4.74829e-14
v 1000 -290 4.74829e-14
f 9/1/1 10/2/1 11/3/1 12/4/1
v 1000 290 440
v 1330 290 440
f 9/1/2 13/5/2 14/6/2 10/7/2
v 1000 -290 440
f 13/5/3 9/1/3 12/8/3 15/9/3
v 1330 -290 440
f 11/10/4 16/11/4 15/12/4 12/13/4
f 16/14/5 11/15/5 10/16/5 14/17/5
f 16/18/6 14/2/6 13/1/6 15/19/6
#
## Alias OBJ Material File
# Exported from SketchUp, (c) 2000-2012 Trimble Navigation Limited
newmtl WOOD_LIGHT
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.330000 0.330000 0.330000
newmtl cstm_sound_tapis
Ka 0.000000 0.000000 0.000000
Kd 0.792157 0.792157 0.788235
Ks 0.330000 0.330000 0.330000
newmtl Chris_Hair
Ka 0.000000 0.000000 0.000000
Kd 0.278431 0.298039 0.290196
Ks 0.330000 0.330000 0.330000
newmtl Material_043
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.701961 0.458824
Ks 0.330000 0.330000 0.330000
newmtl Material_029
Ka 0.000000 0.000000 0.000000
Kd 0.066667 0.066667 0.066667
Ks 0.330000 0.330000 0.330000
newmtl Chris_Skin
Ka 0.000000 0.000000 0.000000
Kd 0.752941 0.643137 0.450980
Ks 0.330000 0.330000 0.330000
newmtl _Charcoal_
Ka 0.000000 0.000000 0.000000
Kd 0.137255 0.137255 0.137255
Ks 0.330000 0.330000 0.330000
newmtl _White_
Ka 0.000000 0.000000 0.000000
Kd 1.000000 1.000000 1.000000
Ks 0.330000 0.330000 0.330000
newmtl _DarkGray__0_000
Ka 0.000000 0.000000 0.000000
Kd 0.019608 0.019608 0.019608
Ks 0.330000 0.330000 0.330000
This diff is collapsed.
This diff is collapsed.
......@@ -23,6 +23,7 @@
// CLOUDLIB
#include "ofxCloudLib/ModelsManager.hpp"
#include "ofxCloudLib/ClientParameterGroups.hpp" // TODO rationaliser
#include "ofxCloudLib/Cropper.hpp"
#include "ofxCloudLib/OutliersFilter.hpp"
......@@ -150,7 +151,7 @@ class ofApp : public ofBaseApp
for (const auto &v : crop_mesh_.getVertices()) {
boundingbox_->push_back(pcl::PointXYZ(v.x * parameters_.enflure_, v.y * parameters_.enflure_, v.z * parameters_.enflure_));
}
std::cout << "loadé boundingbox avec " << boundingbox_->size() << " vertex" << std::endl;
std::cout << "loaded boundingbox avec " << boundingbox_->size() << " vertex" << std::endl;
hull_.setComputeAreaVolume(true);
hull_.setInputCloud(boundingbox_);
......@@ -201,6 +202,8 @@ class ofApp : public ofBaseApp
ofxOscParameterSync osc_sync_;
bool sync_active_ = false;
ofxCloudLib::ModelsManager models_manager_;
pcl::PointCloud<pcl::PointXYZ>::Ptr boundingbox_;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_inside_hull_;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_outside_hull_;
......
......@@ -3,6 +3,10 @@
#include "ofMain.h"
namespace ofxCloudLib
{
class Marqueur {
public:
Marqueur(size_t id, glm::vec3 position, glm::vec3 dimension) {
......@@ -29,7 +33,7 @@ public:
class Calibration {
public:
Calibration () {};
void setup(std::string json_path) {
bool setup(std::string json_path) {
ofFile file(json_path);
if(file.exists()){
......@@ -57,7 +61,7 @@ public:
std::vector<std::unique_ptr<Marqueur>> marqueurs_;
ofJson js_;
};
}
#endif /* Calibration_h */
#ifndef MODELS_MANAGER_HPP
#define MODELS_MANAGER_HPP
namespace ofxCloudLib
{
class ModelsManager
{
public:
ModelsManager(){};
void setup(std::string scene_path, std::string marqueurs_path)
{
scene_path_ =scene_path;
marqueurs_path_ =marqueurs_path;
model_material_.setAmbientColor(ofFloatColor(1.0, 1.0, 1.0, 1.0));
model_material_.setDiffuseColor(ofFloatColor(0.8, 0.8, 0.8, 1.0));
model_material_.setSpecularColor(ofFloatColor(0.8, 0.8, 0.8, 1.0));
model_material_.setShininess(10);
light_jardin_.setAreaLight(600, 400);
light_jardin_.setAmbientColor(ofFloatColor(0.5, 1, 0.5));
light_jardin_.setAttenuation(0.001, 0.001, 0.01);
light_jardin_.setDiffuseColor(ofFloatColor(.9, .4, .4));
light_jardin_.setSpecularColor(ofFloatColor(.5, .9, .5));
light_jardin_.setPosition(300, 0, 400);
light_court_.setAreaLight(600, 400);
light_court_.setAmbientColor(ofFloatColor(1.0, 1.0, 1.0));
light_court_.setAttenuation(.0001, 0.0001, 0.0001);
light_court_.setDiffuseColor(ofFloatColor(1., 1., 1.));
light_court_.setSpecularColor(ofFloatColor(1., 1., 1.));
light_court_.setPosition(-200, 0, 350);
reload_models();
}
void reload_models()
{
marqueurs_model_.setScaleNormalization(false);
marqueurs_model_.setScale(.1, .1, .1);
scene_model_.setScaleNormalization(false);
scene_model_.setScale(.1, .1, .1);
marqueurs_model_.loadModel(scene_path_);
scene_model_.loadModel(model_path_);
marqueurs_model_.setScaleNormalization(false);
marqueurs_model_.setScale(.1, .1, .1);
scene_model_.setScaleNormalization(false);
scene_model_.setScale(.1, .1, .1);
scene_model_.disableColors();
scene_model_.disableMaterials();
scene_model_.disableTextures();
if (marqueurs_model_.hasMeshes()) {
std::cout << "marqueurs_model_ #meshes: " << marqueurs_model_.getNumMeshes()
<< std::endl;
}
if (scene_model_.hasMeshes()) {
std::cout << "scene_model_ #meshes:" << scene_model_.getNumMeshes()
<< std::endl; // should not crash
}
}
void draw(bool draw_scene_, bool draw_marqueurs_);
{
ofPushStyle();
ofEnableBlendMode(OF_BLENDMODE_ALPHA);
if (draw_scene_) {
// ofEnableLighting();
// light_jardin_.enable();
// light_court_.enable();
ofPushStyle();
ofPushMatrix();
ofSetColor(255, 255, 255, 100);
ofRotateDeg(-180, 1, 0, 0); // ceci aaligne le modele avec le cloud
ofRotateYDeg(90); // ceci aaligne le modele avec le cloud
//git pu ofRotateXDeg(180); // ceci aaligne le modele avec le cloud
ofScale(250);
if (wireframe_models_) {
scene_model_.drawWireframe();
} else {
// model_material_.begin();
scene_model_.drawFaces();
// model_material_.end();
}
ofPopStyle();
ofPopMatrix();
// light_jardin_.disable();
// light_court_.disable();
// ofDisableLighting();
}
if (draw_marqueurs_) {
ofEnableLighting();
light_jardin_.enable();
light_court_.enable();
ofPushStyle();
ofPushMatrix();
ofSetColor(50, 50, 50, 150);
ofScale(100);
if (wireframe_models_) {
marqueurs_model_.drawWireframe();
} else {
model_material_.begin();
marqueurs_model_.drawFaces();
model_material_.end();
}
ofPopStyle();
ofPopMatrix();
light_jardin_.disable();
light_court_.disable();
ofSetColor(255, 255, 255, 150);
ofEnableBlendMode(OF_BLENDMODE_ADD);
marqueurs_model_.drawWireframe();
ofDisableLighting();
}
// if (draw_lights_) {
// light_jardin_.draw();
// light_court_.draw();
// }
ofPopStyle();
}
std::string scene_path_;
std::string marqueurs_path_;
ofxAssimpModelLoader scene_model_;
ofxAssimpModelLoader marqueurs_model_;
ofMaterial model_material_;
ofLight light_jardin_;
ofLight light_court_;
};
} // namespace ofxCloudLib
#endif // MODELS_MANAGER_HPP
#ifndef MODELS_MANAGER_HPP
#define MODELS_MANAGER_HPP
#include "ofMain.h"
#include "ofxAssimpModelLoader.h"
namespace ofxCloudLib {
class ModelsManager {
public:
ModelsManager(){};
void setup(std::string scene_path, std::string marqueurs_path) {
parameters_.add(draw_marqueurs_.set("draw marqueurs",true));
parameters_.add(draw_scene_.set("draw scene",true));
parameters_.add(model_color_.set("couleur",ofColor::white, ofColor::black, ofColor::white));
parameters_.setName("Models");
scene_path_ = scene_path;
marqueurs_path_ = marqueurs_path;
model_material_.setAmbientColor(ofFloatColor(1.0, 1.0, 1.0, 1.0));
model_material_.setDiffuseColor(ofFloatColor(0.8, 0.8, 0.8, 1.0));
model_material_.setSpecularColor(ofFloatColor(0.8, 0.8, 0.8, 1.0));
model_material_.setShininess(10);
light_jardin_.setAreaLight(600, 400);
light_jardin_.setAmbientColor(ofFloatColor(0.5, 1, 0.5));
light_jardin_.setAttenuation(0.001, 0.001, 0.01);
light_jardin_.setDiffuseColor(ofFloatColor(.9, .4, .4));
light_jardin_.setSpecularColor(ofFloatColor(.5, .9, .5));
light_jardin_.setPosition(300, 0, 400);
light_court_.setAreaLight(600, 400);
light_court_.setAmbientColor(ofFloatColor(1.0, 1.0, 1.0));
light_court_.setAttenuation(.0001, 0.0001, 0.0001);
light_court_.setDiffuseColor(ofFloatColor(1., 1., 1.));
light_court_.setSpecularColor(ofFloatColor(1., 1., 1.));
light_court_.setPosition(-200, 0, 350);
reload_models();
}
void reload_models() {
std::cout << "MODELS MANAGER: reloading models " << marqueurs_path_ << " & "
<< scene_path_ << std::endl;
marqueurs_model_.setScaleNormalization(false);
marqueurs_model_.setScale(.1, .1, .1);
scene_model_.setScaleNormalization(false);
scene_model_.setScale(.1, .1, .1);
marqueurs_model_.loadModel(marqueurs_path_);
scene_model_.loadModel(scene_path_);
marqueurs_model_.setScaleNormalization(false);
marqueurs_model_.setScale(.1, .1, .1);
scene_model_.setScaleNormalization(false);
scene_model_.setScale(.1, .1, .1);
scene_model_.disableColors();
scene_model_.disableMaterials();
scene_model_.disableTextures();
marqueurs_model_.disableColors();
marqueurs_model_.disableMaterials();
marqueurs_model_.disableTextures();
if (marqueurs_model_.hasMeshes()) {
std::cout << "marqueurs_model_ #meshes: "
<< marqueurs_model_.getNumMeshes() << std::endl;
}
if (scene_model_.hasMeshes()) {
std::cout << "scene_model_ #meshes:" << scene_model_.getNumMeshes()
<< std::endl; // should not crash
}
}
void draw() {
bool wireframe_models_ = false;
ofPushStyle();
ofSetColor(model_color_);
ofEnableBlendMode(OF_BLENDMODE_ALPHA);
if (draw_scene_) {
ofPushMatrix();
// ofRotateDeg(-180, 1, 0, 0); // disque
// ofRotateDeg(180, 1, 0, 0);
// ofRotateYDeg(90); // ceci aligne le modele sketchup avec le
// cloud ??
// ofRotateXDeg(180); // ceci aligne le modele sketchup avec le cloud
ofRotateDeg(180, 1, 0, 0);
ofScale(2);
if (wireframe_models_) {
scene_model_.drawWireframe();
} else {
ofPushStyle();
ofEnableLighting();
light_jardin_.enable();
light_court_.enable();
model_material_.begin();
// scene_model_.drawFaces();
model_material_.end();
light_jardin_.disable();
light_court_.disable();
ofDisableLighting();
// ofSetColor(model_color_);
ofEnableBlendMode(OF_BLENDMODE_ADD);
scene_model_.drawWireframe();
ofPopStyle();
}
ofPopMatrix();
}
if (draw_marqueurs_) {
ofPushMatrix();
// ofSetColor(80, 80, 80, 80);
ofRotateDeg(-90, 1, 0, 0);
ofScale(.01);
if (wireframe_models_) {
marqueurs_model_.drawWireframe();
} else {
ofPushStyle();
ofEnableLighting();
light_jardin_.enable();
light_court_.enable();
model_material_.begin();
marqueurs_model_.drawFaces();
model_material_.end();
light_jardin_.disable();
light_court_.disable();
ofDisableLighting();
ofPopStyle();
// ofSetColor(255, 255, 255, 128);
ofEnableBlendMode(OF_BLENDMODE_ADD);
marqueurs_model_.drawWireframe();
}
ofPopMatrix();
ofSetColor(255, 255, 255, 150);
}
// if (draw_lights_) {
// light_jardin_.draw();
// light_court_.draw();
// }
ofPopStyle();
}
std::string scene_path_;
std::string marqueurs_path_;
ofxAssimpModelLoader scene_model_;
ofxAssimpModelLoader marqueurs_model_;
ofMaterial model_material_;
ofLight light_jardin_;
ofLight light_court_;
ofParameterGroup parameters_;
ofParameter<bool> draw_scene_;
ofParameter<bool> draw_marqueurs_;
ofParameter<ofColor> model_color_;
};
} // namespace ofxCloudLib
#endif // MODELS_MANAGER_HPP
Supports Markdown
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