SplatRenderObject.hpp

00001 #ifndef __SPLATRENDEROBJECT_HPP
00002 #define __SPLATRENDEROBJECT_HPP
00003 
00004 #include <bone/BundleInput.hpp>
00005 #include <bone/FishField.hpp>
00006 
00007 //#include <ocean/GLvish/VGLRenderObject.hpp>
00008 #include <ocean/GLvish/BoundingBox.hpp>
00009 #include <ocean/GLvish/Shader.hpp>
00010 
00011 #include <ocean/eagle/PhysicalSpace.hpp>
00012 
00013 #include <ocean/shrimp/VEnum.hpp>
00014 
00015 #include <GL/fieldGL.hpp>
00016 #include <GL/FieldBuffer.hpp>
00017 #include <GL/PartialElementRenderer.hpp>
00018 
00019 #include <eye/retina/VertexRenderObject.hpp>
00020 #include <eye/retina/Iris.hpp>
00021 
00022 namespace Wizt
00023 {
00024 
00025 using namespace Fiber;
00026 using namespace Eagle;
00027 
00028 
00039 class   fisheye_API SplatRenderObject : public VertexRenderObject, public Iris
00040 {
00041 public:
00043         TypedSlot<double>       sizeFactor;
00044 
00046         TypedSlot<double>       AnimationSpeed;
00047 
00049         TypedSlot<double>       MaxSize; 
00050 
00051         TypedSlot<VEnum>        renderMode; 
00052 
00061         SplatRenderObject(const string&name, int p, const RefPtr<VCreationPreferences>&VP,
00062                           double SizeScale = 5.0, 
00063                           int AnimationVisibility = 5);
00064 
00066         ~SplatRenderObject(); 
00067 
00071         struct  fisheye_API Renderer : GL::PartialElementRenderer
00072         {
00073                 RefPtr<Iris::PointShape> Shape; 
00074 
00078                 enum    mode
00079                 {
00081                         accumulative,
00083                         depthsorted,
00085                         alphaclamped,
00087                         accumulative_absorption,
00088 
00089                         starlike  = accumulative,
00090                         particles = depthsorted,
00091                         massive   = alphaclamped
00092                 }; 
00093 
00094                 mode    render_mode; 
00095 
00100                 double  AlphaThreshold; 
00101 
00117                 GLenum  AlphaClampMode; 
00118 
00119                 Renderer(const RefPtr<MemBase>&FieldCoordinates,
00120                          const RefPtr<FragmentSelector>&FS);
00121 
00122                 ~Renderer(); 
00123 
00124                 override void prefix(); 
00125 
00131                 override bool draw();
00132 
00133                 override void postfix();
00134         };
00135 
00170 static  const char*setPointAttenuation();
00171 
00190 static  const char default_vertex_shader[];
00191 
00192         virtual string splat_vertex_shader(VGLRenderContext&Context) const = 0;
00193 
00212 static  const char default_fragment_shader[]; 
00213 
00214         virtual string splat_fragment_shader(VGLRenderContext&Context) const = 0;
00215 
00243         virtual void setShaderVariables(VGLRenderContext&Context, const RefPtr<GLProgram>&ShaderProgram) const;
00244 
00248         override RefPtr<VBO::Renderer> createRenderer(VGLRenderContext&Context,
00249                                                       const RefPtr<MemBase>&FieldCoordinates,
00250                                                       const RefPtr<FragmentSelector>&FS) const;
00251 
00255 /*
00256         virtual void    updateRenderer(VRenderContext&Context,
00257                                        const RefPtr<VBO::Renderer>&R,
00258                                        const RefPtr<MemBase>&FieldCoordinates,
00259                                        const RefPtr<FragmentSelector>&FS) const;
00260 */
00261 
00263         override void   setRendererParameters(VGLRenderContext&Context,
00264                                               const RefPtr<VBO::Renderer>&theRenderer, 
00265                                               const RefPtr<CreativeArrayBase>&VertexCoordinates,
00266                                               const RefPtr<GLProgram>&theShaderProgram) const; 
00267 
00268 
00269         override bool request(VRequest&R, double precision); 
00270 
00279         override void render(VGLRenderContext&Context) const; 
00280 
00284 static  string createChildname(const string&parent_name);
00285 };
00286 
00287 } // namespace Wizt
00288 
00289 #endif // __SPLATRENDEROBJECT_HPP