30 #include <boost/shared_array.hpp>
49 namespace ost {
namespace gfx {
63 namespace impl {
class SceneFX;}
82 friend class impl::SceneFX;
88 struct SceneViewStackEntry {
94 typedef std::stack<SceneViewStackEntry> SceneViewStack;
97 static Scene& Instance();
104 void SetFogColor(
const Color& c);
106 Color GetFogColor()
const;
109 void SetShadow(
bool f);
111 bool GetShadow()
const;
113 void SetShadowQuality(
int q);
115 int GetShadowQuality()
const;
117 void SetShadowWeight(
float w);
119 float GetShadowWeight()
const;
122 void SetDepthDarkening(
bool f);
124 void SetDepthDarkeningWeight(
float f);
127 void SetAmbientOcclusion(
bool f);
129 bool GetAmbientOcclusion()
const;
131 void SetAmbientOcclusionWeight(
float f);
133 float GetAmbientOcclusionWeight()
const;
135 void SetAmbientOcclusionMode(
uint m);
137 uint GetAmbientOcclusionMode()
const;
139 void SetAmbientOcclusionQuality(
uint q);
141 uint GetAmbientOcclusionQuality()
const;
143 void SetAmbientOcclusionSize(
float f);
145 float GetAmbientOcclusionSize()
const;
149 void SetShadingMode(
const std::string& smode);
157 float GetNear()
const;
160 void SetNear(
float n);
163 float GetFar()
const;
166 void SetFar(
float f);
169 void SetNearFar(
float n,
float f);
172 void SetFOV(
float f);
175 float GetFOV()
const;
180 void SetFogNearOffset(
float o);
183 float GetFogNearOffset()
const;
186 void SetFogFarOffset(
float o);
189 float GetFogFarOffset()
const;
192 void SetFogOffsets(
float no,
float fo);
195 void Autoslab(
bool fast);
198 void Autoslab(
bool fast,
bool);
220 autoslab_mode_=std::min(2,std::max(0,mode));
225 return autoslab_mode_;
233 void AutoAutoslab(
bool f);
242 void SetStereoMode(
unsigned int mode);
246 void SetStereoFlip(
bool f);
252 void SetStereoView(
int);
257 void SetStereoIOD(
Real);
262 void SetStereoDistance(
Real);
268 void SetStereoAlg(
unsigned int);
275 void SetLightProp(
const Color& amb,
const Color& diff,
const Color& spec);
277 void SetLightProp(
float amb,
float diff,
float spec);
287 void SetSelectionMode(
uint m);
288 uint GetSelectionMode()
const;
295 void Export(
const String& fname,
unsigned int w,
296 unsigned int h,
bool transparent=
false);
299 void Export(
const String& fname,
bool transparent=
false);
302 void ExportPov(
const std::string& fname,
const std::string& wdir=
".");
312 void InitGL(
bool full=
true);
315 void Resize(
int w,
int h);
318 void Pick(
int mx,
int my,
int mask);
320 float GetDefaultTextSize();
323 std::pair<GfxObjP, mol::AtomHandle> PickAtom(
int mx,
int my);
329 void RequestRedraw();
332 void StatusMessage(
const String& s);
335 void SetViewport(
int w,
int h);
338 void SetBackground(
const Color& c);
341 void SetBackground(
const Gradient& g);
344 void SetBackground(
const Bitmap& bm);
347 Color GetBackground()
const;
356 void CenterOn(
const String& s);
359 void CenterOn(
const GfxObjP& s);
397 void ResetProjection();
407 void Add(
const GfxNodeP& go,
bool redraw=
true);
412 void Remove(
const String& name);
419 bool Rename(
const String& old_name,
const String& new_name);
425 bool HasNode(
const String& name)
const;
428 void Apply(
const InputEvent& ie,
bool request_redraw=
true);
437 size_t GetNodeCount()
const;
448 bool InOffscreenMode()
const;
451 void SetTestMode(
bool t);
453 float ElapsedTime()
const;
470 bool StartOffscreenMode(
unsigned int w,
unsigned int h);
472 void StopOffscreenMode();
475 void SetShowCenter(
bool f);
486 void SetBlur(
uint n);
494 void SetBeacon(
int wx,
int wy);
498 void SetExportAspect(
float a);
500 void SetShowExportAspect(
bool f);
510 void ObjectChanged(
const String& name);
512 void NodeTransformed(
const GfxObjP&
object);
513 void NodeAdded(
const GfxNodeP& node);
514 void RenderModeChanged(
const String& name);
519 template <
typename ACTION>
520 void NotifyObservers(
const ACTION&
action) {
521 std::for_each(observers_.begin(), observers_.end(),
action);
525 Scene& operator=(
const Scene&) {
return *
this;}
541 unsigned int vp_width_,vp_height_;
543 SceneViewStack scene_view_stack_;
563 bool offscreen_flag_;
564 OffscreenBuffer* main_offscreen_buffer_;
566 std::string def_shading_mode_;
568 uint selection_mode_;
571 std::vector<unsigned char> tmp_tex_;
573 GLuint glyph_tex_id_;
574 std::vector<geom::Vec2> glyph_map_;
575 float def_text_size_;
578 std::vector<boost::shared_array<unsigned char> > blur_buffer_;
580 unsigned int stereo_mode_;
581 unsigned int stereo_alg_;
582 bool stereo_inverted_;
583 unsigned int stereo_eye_;
584 Real stereo_iod_,stereo_distance_;
585 unsigned int scene_left_tex_;
586 unsigned int scene_right_tex_;
587 unsigned int bg_mode_;
591 unsigned int bg_tex_;
593 float export_aspect_;
594 bool show_export_aspect_;
596 void set_near(
float n);
597 void set_far(
float f);
599 void flag_all_dirty();
602 void stereo_projection(
int view);
604 void render_export_aspect();
607 void render_stereo();
611 bool IsNameAvailable(
const String& name)
const;