8 #ifndef _MBS_WORLD_3D_HH_
9 #define _MBS_WORLD_3D_HH_
24 enum {NO_LIGHT_SHADER, LIGHTS_NO_SPEC_SHADER, LIGHTS_SHADER, SHADOW_MAPPING_SHADER};
42 #define MAX_NB_LIGHTS 10
49 MbsWorld3D(
int x_width=1024,
int y_width=768,
int shader_flag=LIGHTS_NO_SPEC_SHADER,
int multi_samp=4,
50 glm::vec3
const& background_color = glm::vec3(0.8, 0.8, 0.8),
51 MbsWorldRenderer* renderer=0,
52 MbsWindowManager* winMngr=0);
56 int GetXWidth()
const {
return winManager->GetXWidth(); }
59 int GetYWidth()
const {
return winManager->GetYWidth(); }
62 double GetT()
const {
return t; }
65 int GetNbMbs()
const {
return (
int) mbs_list.size(); }
68 int GetNbModels()
const {
return (
int)model_list.size(); }
71 int GetNbLights()
const {
return (
int) light_list.size(); }
74 int GetNbViews()
const {
return (
int) view_list.size(); }
77 int GetNbJoints(
int i)
const {
return (
int) joint_tab[i].size(); }
80 int GetShaderFlag()
const {
return (
int) shader_flag; }
83 MbsShape3D* GetModel(
int i) {
return model_list[i]; }
86 std::vector<MbsShape3D*> GetModels() {
return model_list; }
89 MbsLight* GetLight(
int i) {
return light_list[i]; }
92 MbsViewPoint* GetView(
int i) {
return view_list[i]; }
95 MbsViewPoint* GetCurView() {
return view_list[cur_view]; }
98 void AddJointList(std::vector<Joint3D*>
const& joint_list)
100 joint_tab.push_back(joint_list);
104 void AddBase(Base3D *new_mbs)
106 new_mbs->UpdateAbsMatTree();
107 mbs_list.push_back(new_mbs);
113 void NextViewPoint();
114 void SetViewPoint(
int view_id);
116 void AddMbs(
const char* mbs_filename);
118 void UpdateJoints(
int model_id,
int nb_q,
double *q_vec);
120 void SetBackgroundColor(glm::vec3
const& background_color);
122 MbsBox* AddBox(
double d,
double w,
double h, glm::vec3 color,
123 float transparency = 1.0,
124 glm::vec3
const& trans_pos = glm::vec3(0.0f),
125 glm::vec3
const& trans_scale = glm::vec3(1.0, 1.0, 1.0),
126 glm::vec3
const& trans_rot = glm::vec3(0.0f),
127 float shiny_mat = 250.f,
128 glm::vec3
const& specular_mat = glm::vec3(1.0f, 1.0f, 1.0f),
129 const char* name =
"none");
131 MbsCylinder* AddCylinder(
double r,
double h, glm::vec3 color,
132 float transparency = 1.0,
133 glm::vec3
const& trans_pos = glm::vec3(0.0f),
134 glm::vec3
const& trans_scale = glm::vec3(1.0, 1.0, 1.0),
135 glm::vec3
const& trans_rot = glm::vec3(0.0f),
136 float shiny_mat = 250.f,
137 glm::vec3
const& specular_mat = glm::vec3(1.0f, 1.0f, 1.0f),
138 const char* name =
"none");
140 MbsCone* AddCone(
double r,
double h, glm::vec3 color,
141 float transparency = 1.0,
142 glm::vec3
const& trans_pos = glm::vec3(0.0f),
143 glm::vec3
const& trans_scale = glm::vec3(1.0, 1.0, 1.0),
144 glm::vec3
const& trans_rot = glm::vec3(0.0f),
145 float shiny_mat = 250.f,
146 glm::vec3
const& specular_mat = glm::vec3(1.0f, 1.0f, 1.0f),
147 const char* name =
"none");
149 MbsSphere* AddSphere(
double r, glm::vec3 color,
150 float transparency = 1.0,
151 glm::vec3
const& trans_pos = glm::vec3(0.0f),
152 glm::vec3
const& trans_scale = glm::vec3(1.0, 1.0, 1.0),
153 glm::vec3
const& trans_rot = glm::vec3(0.0f),
154 float shiny_mat = 250.f,
155 glm::vec3
const& specular_mat = glm::vec3(1.0f, 1.0f, 1.0f),
156 const char* name =
"none");
158 MbsInline* AddInline(std::string cad_file, glm::vec3 color,
159 float transparency = 1.0,
160 glm::vec3
const& trans_pos = glm::vec3(0.0f),
161 glm::vec3
const& trans_scale = glm::vec3(1.0, 1.0, 1.0),
162 glm::vec3
const& trans_rot = glm::vec3(0.0f),
163 float shiny_mat = 250.f,
164 glm::vec3
const& specular_mat = glm::vec3(1.0f, 1.0f, 1.0f),
165 const char* name =
"none");
167 MbsPointLight* AddPointLight(glm::vec3
const& rel_pos = glm::vec3(0.0f),
168 glm::vec3
const& attenuation = glm::vec3(1.0f, 0.0f, 0.0f),
169 glm::mat4
const& parent_mat = glm::mat4(1.0f),
170 glm::vec3
const& color = glm::vec3(1.0f),
171 float ambient = 0.05f,
173 int depth_x_width = 1024,
int depth_y_width = 1024,
float shadow_bias = 0.0f,
174 float depth_near = 0.1f,
float depth_far = 100.0f,
175 glm::vec3
const& shadow_z_up = glm::vec3(0.0, 0.0, 1.0),
176 float depth_FoV_rad = 1.0f,
177 glm::vec3
const& shadow_rel_dir = glm::vec3(0.0f, -1.0f, 0.0f));
179 MbsSpotLight* AddSpotLight(glm::vec3
const& rel_pos = glm::vec3(0.0f),
180 glm::vec3
const& attenuation = glm::vec3(1.0f, 0.0f, 0.0f),
181 glm::vec3
const& rel_dir = glm::vec3(0.0f, 0.0f, -1.0f),
182 glm::mat4
const& parent_mat = glm::mat4(1.0f),
183 glm::vec3
const& color = glm::vec3(1.0f),
184 float ambient = 0.05f,
185 float spread_angle = 3.1415927f,
186 float concentration = 0.0f,
188 int depth_x_width = 1024,
int depth_y_width = 1024,
float shadow_bias = 0.0f,
189 float depth_near = 0.1f,
float depth_far = 100.0f,
190 glm::vec3
const& shadow_z_up = glm::vec3(0.0, 0.0, 1.0),
191 float depth_FoV_rad = 1.0f);
193 MbsDirLight* AddDirLight(glm::vec3
const& rel_dir = glm::vec3(0.0f, 0.0f, -1.0f),
194 glm::mat4
const& parent_mat = glm::mat4(1.0f),
195 glm::vec3
const& color = glm::vec3(1.0f),
196 float ambient = 0.05f,
198 int depth_x_width = 1024,
int depth_y_width = 1024,
float shadow_bias = 0.0f,
199 float depth_near = -10.0f,
float depth_far = 20.0f,
200 glm::vec3
const& shadow_z_up = glm::vec3(0.0, 0.0, 1.0),
201 float depth_scale = 0.0015f,
202 glm::vec3
const& rel_shadow_point = glm::vec3(0.0f));
204 MbsViewPoint* AddViewPoint(glm::vec3
const&rel_pos, glm::vec3
const&rel_look_at, glm::vec3
const&z_up,
206 float FoV_scale=0.785f,
float camera_near=0.1f,
float camera_far=100.0f,
207 glm::mat4
const& parent_mat = glm::mat4(1.0f));
210 MbsWorldRenderer* GetWorldRenderer(){
211 return worldRenderer;
214 void AddViewPointRenderer(MbsViewPointRenderer* rdr){worldRenderer->AddViewPointRenderer(rdr);}
218 MbsWorldRenderer* worldRenderer;
220 MbsWindowManager* winManager;
225 std::vector<MbsViewPoint*> view_list;
227 std::vector<MbsShape3D*> model_list;
229 std::vector<MbsLight*> light_list;
231 std::vector< std::vector<Joint3D*> > joint_tab;
233 std::vector<Base3D*> mbs_list;
235 std::string main_vert_sh;
236 std::string main_frag_sh;
247 bool hasInitOwnWorldRenderer;
248 bool hasInitOwnWindowManager;