30 #include <boost/shared_array.hpp>
49 namespace ost {
namespace gfx {
63 namespace impl {
class 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;
152 void SetShadingMode(
const std::string& smode);
159 float GetNear()
const;
163 void SetNear(
float n);
166 float GetFar()
const;
169 void SetFar(
float f);
172 void SetNearFar(
float n,
float f);
175 void SetFOV(
float f);
178 float GetFOV()
const;
183 void SetFogNearOffset(
float o);
186 float GetFogNearOffset()
const;
189 void SetFogFarOffset(
float o);
192 float GetFogFarOffset()
const;
195 void SetFogOffsets(
float no,
float fo);
198 void Autoslab(
bool fast);
201 void Autoslab(
bool fast,
bool);
223 autoslab_mode_=std::min(2,std::max(0,mode));
228 return autoslab_mode_;
236 void AutoAutoslab(
bool f);
245 void SetStereoMode(
unsigned int mode);
249 void SetStereoFlip(
bool f);
255 void SetStereoView(
int);
260 void SetStereoIOD(
Real);
265 void SetStereoDistance(
Real);
271 void SetStereoAlg(
unsigned int);
278 void SetLightProp(
const Color& amb,
const Color& diff,
const Color& spec);
280 void SetLightProp(
float amb,
float diff,
float spec);
290 void SetSelectionMode(
uint m);
291 uint GetSelectionMode()
const;
295 void Export(
const String& fname,
unsigned int w,
299 unsigned int h,
bool transparent=
false);
301 void Export(
const String& fname,
unsigned int w,
302 unsigned int h,
int max_samples,
bool transparent=
false);
305 void Export(
const String& fname,
bool transparent=
false);
308 void ExportPov(
const std::string& fname,
const std::string& wdir=
".");
318 void InitGL(
bool full=
true);
321 void Resize(
int w,
int h);
324 void Pick(
int mx,
int my,
int mask);
326 float GetDefaultTextSize();
329 std::pair<GfxObjP, mol::AtomHandle> PickAtom(
int mx,
int my);
335 void RequestRedraw();
338 void StatusMessage(
const String& s);
341 void SetViewport(
int w,
int h);
344 void SetBackground(
const Color& c);
347 void SetBackground(
const Gradient& g);
350 void SetBackground(
const Bitmap& bm);
353 Color GetBackground()
const;
357 void SetBackgroundStereoMode(
bool);
361 void SetBackgroundStereoOffset(
float);
371 void CenterOn(
const String& s);
374 void CenterOn(
const GfxObjP& s);
412 void ResetProjection();
421 void Add(
const GfxNodeP& go,
bool redraw=
true);
427 void Remove(
const String& name);
434 bool Rename(
const String& old_name,
const String& new_name);
440 bool HasNode(
const String& name)
const;
443 void Apply(
const InputEvent& ie,
bool request_redraw=
true);
452 size_t GetNodeCount()
const;
463 bool InOffscreenMode()
const;
466 void SetTestMode(
bool t);
468 float ElapsedTime()
const;
492 bool StartOffscreenMode(
unsigned int w,
unsigned int h,
int max_samples);
493 bool StartOffscreenMode(
unsigned int w,
unsigned int h);
496 void StopOffscreenMode();
499 void SetShowCenter(
bool f);
510 void SetBlur(
uint n);
518 void SetBeacon(
int wx,
int wy);
522 void SetExportAspect(
float a);
524 void SetShowExportAspect(
bool f);
535 void ObjectChanged(
const String& name);
537 void NodeTransformed(
const GfxObjP&
object);
538 void NodeAdded(
const GfxNodeP& node);
539 void RenderModeChanged(
const String& name);
544 template <
typename ACTION>
545 void NotifyObservers(
const ACTION&
action) {
546 std::for_each(observers_.begin(), observers_.end(),
action);
550 Scene& operator=(
const Scene&) {
return *
this;}
566 unsigned int vp_width_,vp_height_;
568 SceneViewStack scene_view_stack_;
589 bool offscreen_flag_;
590 OffscreenBuffer* main_offscreen_buffer_;
592 std::string def_shading_mode_;
594 uint selection_mode_;
597 std::vector<unsigned char> tmp_tex_;
599 GLuint glyph_tex_id_;
600 std::vector<geom::Vec2> glyph_map_;
601 float def_text_size_;
604 std::vector<boost::shared_array<unsigned char> > blur_buffer_;
606 unsigned int stereo_mode_;
607 unsigned int stereo_alg_;
608 bool stereo_inverted_;
610 Real stereo_iod_,stereo_distance_;
611 unsigned int scene_left_tex_;
612 unsigned int scene_right_tex_;
613 unsigned int bg_mode_;
615 bool bg_stereo_mode_;
616 float bg_stereo_offset_;
619 unsigned int bg_tex_;
623 float export_aspect_;
624 bool show_export_aspect_;
626 void set_near(
float n);
627 void set_far(
float f);
629 void flag_all_dirty();
632 void stereo_projection(
int view);
634 void render_export_aspect();
637 void render_stereo();
641 bool IsNameAvailable(
const String& name)
const;
geom::Mat3 GetLightRot() const
get main light orientation (internal debugging use)
bool HasMultisample() const
boost::shared_ptr< GfxObj > GfxObjP
bool GetShowExportAspect() const
geom::Vec4 GetHemiParams() const
void SetAutoslabMode(int mode)
set autoslab mode
bool GetShowCenter() const
main class for organization and root for the graphical display
geom::Vec3 GetLightDir() const
get main light direction
main class for all graphic objects
Interface for observing graphical objects.
int GetStereoMode() const
geom::Mat4 GetProjection() const
graphical rendering of mol::EntityHandle entites
#define DLLEXPORT_OST_GFX
bool GetAutoAutoslab() const
get current state of automatic autoslab'bing
int GetStereoView() const
return current stereo view mode
bool GetBackgroundStereoMode() const
Real GetStereoIOD() const
return current stereo eye distance
int GetAutoslabMode() const
return current autoslab mode
bool GetStereoFlip() const
return invert flag for stereo
std::vector< SceneObserver * > SceneObserverList
void SetFixCenter(bool f)
if true fix center of rotation upon input induced shift
Real GetStereoDistance() const
return current stereo distance offset from COR
Three dimensional vector class, using Real precision.
geom::Mat4 GetInvertedProjection() const
float GetExportAspect() const
boost::shared_ptr< GfxNode > GfxNodeP
float GetBackgroundStereoOffset() const
bool GetFixCenter() const
return flag
unsigned int GetStereoAlg() const
return current stereo algorithm