Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ofxaddons
ofxCloudLib
Commits
5fc8d9f6
Commit
5fc8d9f6
authored
Sep 17, 2017
by
alexandre burton
Browse files
ModelsManager: creation d'une classe pour gerer les modeles
parent
fedae5a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ofxCloudLib/ModelsManager.cpp
0 → 100644
View file @
5fc8d9f6
#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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment