diff --git a/examples/gfx/ambient_occlusion1.py b/examples/gfx/ambient_occlusion1.py new file mode 100644 index 0000000000000000000000000000000000000000..afacacc51a8c792cb7de12c8513b3fb4bb28cba1 --- /dev/null +++ b/examples/gfx/ambient_occlusion1.py @@ -0,0 +1,24 @@ +s=io.LoadSurface("../surf/sdh","msms") +scene.Add(gfx.Surface("s",s)) + +# alternative shading mode +scene.SetShadingMode("hf") + +# add outlines to surface +scene["s"].Outline(True) +scene["s"].SetOutlineMode(3) + +# turn on realtime ambient occlusion +scene.SetAmbientOcclusion(True) + +# strength of the AO effect, default is 1.0 +scene.SetAmbientOcclusionWeight(1.0) + +# AO algorithms 0-3, default is 1 +scene.SetAmbientOcclusionMode(1) + +# orientation +scene.SetRTC(geom.Mat4(0.827929,-0.460893,-0.319547,29.688, + 0.174973,0.753608,-0.633609,19.9405, + 0.532839,0.468671,0.704578,73.0075, + -5.4704,1.54823,-116,1)) diff --git a/examples/gfx/ambient_occlusion2.py b/examples/gfx/ambient_occlusion2.py new file mode 100644 index 0000000000000000000000000000000000000000..d22af87f3db3345057a15de16b417f1a67d74478 --- /dev/null +++ b/examples/gfx/ambient_occlusion2.py @@ -0,0 +1,20 @@ +e=io.LoadPDB("../entity/sdh.pdb") +scene.Add(gfx.Entity("x",gfx.CPK,e.Select("chain=A"))) + +# fast spheres with 3D sprites, default +scene["x"].GetOptions(gfx.CPK).SetSphereMode(1) + +# turn on realtime ambient occlusion +scene.SetAmbientOcclusion(True) + +# strength of the AO effect, default is 1.0 +scene.SetAmbientOcclusionWeight(1.0) + +# AO algorithms 0-3, default is 1 +scene.SetAmbientOcclusionMode(1) + +# orientation +scene.SetRTC(geom.Mat4(0.827929,-0.460893,-0.319547,29.688, + 0.174973,0.753608,-0.633609,19.9405, + 0.532839,0.468671,0.704578,73.0075, + -5.4704,1.54823,-116,1)) diff --git a/examples/gfx/hsc_hemilight.py b/examples/gfx/hsc_hemilight.py new file mode 100644 index 0000000000000000000000000000000000000000..b02b76f3131590cef390689d21144448abebb4a3 --- /dev/null +++ b/examples/gfx/hsc_hemilight.py @@ -0,0 +1,30 @@ +e=io.LoadPDB("../entity/sdh.pdb") +scene.Add(gfx.Entity("x",gfx.HSC,e.Select("chain=A"))) +scene["x"].GetOptions(gfx.HSC).SetTubeRadius(0.6) +# spiral helices (default) +scene["x"].GetOptions(gfx.HSC).SetHelixMode(0) +# straight strands +scene["x"].GetOptions(gfx.HSC).SetStrandMode(1) +# colors +scene["x"].SetColor(gfx.Color(0.9,0.95,1.0)) +scene["x"].SetColor(gfx.Color(1.0,0.9,0.7),"rtype=helix") +scene["x"].SetDetailColor(gfx.Color(1.0,0.95,0.78),"rtype=helix") +scene["x"].SetColor(gfx.Color(0.5,1.0,0.7),"rtype=strand") +scene["x"].SetDetailColor(gfx.Color(0.7,1.0,0.79),"rtype=strand") + +# switch to hemilighting mode +scene.SetShadingMode("hf") +# add outline to improved visibility +scene["x"].Outline(True) +scene["x"].SetOutlineMode(1) +scene["x"].SetOutlineWidth(4.5) + +# looks best on white bg +scene.bg=gfx.WHITE + +scene.SetRTC(geom.Mat4(-0.589889,-0.594876,0.546034,28.2245, + 0.806165,-0.472502,0.356147,20.1685, + 0.0461388,0.65028,0.758291,73.5665, + -3.52709,1.72253,-120,1)) + + diff --git a/examples/gfx/shadow_mapping.py b/examples/gfx/shadow_mapping.py new file mode 100644 index 0000000000000000000000000000000000000000..bba436139aab664361e0617208b7e1a0cfa7b85e --- /dev/null +++ b/examples/gfx/shadow_mapping.py @@ -0,0 +1,22 @@ +s=io.LoadSurface("../surf/sdh","msms") +scene.Add(gfx.Surface("s",s)) + +# alternative shading mode +scene.SetShadingMode("hf") + +# add outlines to surface +scene["s"].Outline(True) +scene["s"].SetOutlineMode(3) + +# turn on realtime shadow mapping +scene.SetShadow(True) + +# this influences the size of the shadow map +# size = (quality+1)*256, up to quality=8 +scene.SetShadowQuality(1) # default + +# orientation +scene.SetRTC(geom.Mat4(0.827929,-0.460893,-0.319547,29.688, + 0.174973,0.753608,-0.633609,19.9405, + 0.532839,0.468671,0.704578,73.0075, + -5.4704,1.54823,-116,1)) diff --git a/examples/gfx/transp.py b/examples/gfx/transp.py new file mode 100644 index 0000000000000000000000000000000000000000..dba10b4c9a73b8b13c68dd372e5a0188daa76186 --- /dev/null +++ b/examples/gfx/transp.py @@ -0,0 +1,20 @@ +e=io.LoadPDB("../entity/sdh.pdb") +s=io.LoadSurface("../surf/sdh","msms") + +scene.Add(gfx.Entity("x",gfx.HSC,e.Select("chain=A"))) +scene["x"].SetColor(gfx.Color(0.9,0.95,1.0)) +scene["x"].SetColor(gfx.Color(1.0,0.9,0.7),"rtype=helix") +scene["x"].SetColor(gfx.Color(0.5,1.0,0.7),"rtype=strand") + +scene.Add(gfx.Surface("s",s)) +scene["s"].SetOpacity(0.4) +scene["s"].SetMat(0,1,0,0) + +scene.bg=gfx.WHITE + +scene.SetRTC(geom.Mat4(-0.589889,-0.594876,0.546034,28.2245, + 0.806165,-0.472502,0.356147,20.1685, + 0.0461388,0.65028,0.758291,73.5665, + -3.52709,1.72253,-120,1)) + + diff --git a/modules/gfx/pymod/export_gfx_obj.cc b/modules/gfx/pymod/export_gfx_obj.cc index 825ac0d91da088b68a540a15d41f12fe46a6ebe8..fe0aaad905afa939a5c464ffd2828df48b6273e9 100644 --- a/modules/gfx/pymod/export_gfx_obj.cc +++ b/modules/gfx/pymod/export_gfx_obj.cc @@ -76,9 +76,6 @@ void export_GfxObj() .def("SetOutlineWidth",&GfxObjBase::SetOutlineWidth) .def("SetOutlineExpandFactor",&GfxObjBase::SetOutlineExpandFactor) .def("SetOutlineExpandColor",&GfxObjBase::SetOutlineExpandColor) - .def("AmbientOcclusion",&GfxObjBase::AmbientOcclusion) - .def("SetAmbientLocalWeight",&GfxObjBase::SetAmbientLocalWeight) - .def("SetAmbientOcclusionWeight",&GfxObjBase::SetAmbientOcclusionWeight) .def("SetOpacity",&GfxObjBase::SetOpacity) .def("GetOpacity",&GfxObjBase::GetOpacity) .add_property("center", &GfxObjBase::GetCenter) diff --git a/modules/gfx/pymod/export_render_options.cc b/modules/gfx/pymod/export_render_options.cc index 51e9829c7ca6fa7ae4d2d80fce7d2bf430c072fd..28911a236eaa47b6077be0fb9e5ab8ff9faebc97 100644 --- a/modules/gfx/pymod/export_render_options.cc +++ b/modules/gfx/pymod/export_render_options.cc @@ -63,8 +63,8 @@ void export_RenderOptions() class_<CPKRenderOptions, boost::shared_ptr<CPKRenderOptions>, bases<RenderOptions>, boost::noncopyable>("CPKRenderOptions") .def("SetSphereDetail", &CPKRenderOptions::SetSphereDetail) .def("GetSphereDetail", &CPKRenderOptions::GetSphereDetail) - .def("SetCPKMode", &CPKRenderOptions::SetCPKMode) - .def("GetCPKMode", &CPKRenderOptions::GetCPKMode) + .def("SetSphereMode", &CPKRenderOptions::SetSphereMode) + .def("GetSphereMode", &CPKRenderOptions::GetSphereMode) ; class_<CustomRenderOptions, boost::shared_ptr<CustomRenderOptions>, bases<RenderOptions>, boost::noncopyable>("CustomRenderOptions") diff --git a/modules/gfx/src/CMakeLists.txt b/modules/gfx/src/CMakeLists.txt index 3dd5c381c4d67f25de3021f0df1b1f6326f68ab8..3c6e8b1f86fa0d4e9c81c3118505a7d836f170de 100644 --- a/modules/gfx/src/CMakeLists.txt +++ b/modules/gfx/src/CMakeLists.txt @@ -62,7 +62,6 @@ trace_render_options.hh set(OST_GFX_IMPL_HEADERS -calc_ambient.hh cartoon_renderer.hh custom_renderer.hh cpk_renderer.hh @@ -116,7 +115,6 @@ color_ops/gradient_color_op.cc color_ops/entity_view_color_op.cc color_ops/basic_gradient_color_op.cc color_ops/gradient_level_color_op.cc -impl/calc_ambient.cc impl/entity_renderer.cc impl/entity_detail.cc impl/cartoon_renderer.cc diff --git a/modules/gfx/src/gfx_object.cc b/modules/gfx/src/gfx_object.cc index 645e01708265c2a2a50bafd746643b4953bc469c..10d4bf23dd9808a8dd25340d0bda4e36a2dad54f 100644 --- a/modules/gfx/src/gfx_object.cc +++ b/modules/gfx/src/gfx_object.cc @@ -325,24 +325,6 @@ void GfxObj::SetOutlineExpandColor(const Color& c) Scene::Instance().RequestRedraw(); } -void GfxObj::AmbientOcclusion(bool f) -{ - va_.UseAmbient(f); - Scene::Instance().RequestRedraw(); -} - -void GfxObj::SetAmbientLocalWeight(float w) -{ - va_.AmbientLocalWeight(w); - Scene::Instance().RequestRedraw(); -} - -void GfxObj::SetAmbientOcclusionWeight(float w) -{ - va_.AmbientOcclusionWeight(w); - Scene::Instance().RequestRedraw(); -} - void GfxObj::SetOpacity(float o) { opacity_=o; diff --git a/modules/gfx/src/gfx_object.hh b/modules/gfx/src/gfx_object.hh index 8d004e3cc9d1cabf7bad5e275495b197102a450f..4f6ebb8a461b9355c6b92c6fc7ef27a4210512c2 100644 --- a/modules/gfx/src/gfx_object.hh +++ b/modules/gfx/src/gfx_object.hh @@ -79,9 +79,6 @@ public: virtual void SetOutlineWidth(float f); virtual void SetOutlineExpandFactor(float f); virtual void SetOutlineExpandColor(const Color& c); - virtual void AmbientOcclusion(bool f); - virtual void SetAmbientLocalWeight(float w); - virtual void SetAmbientOcclusionWeight(float w); virtual void SetOpacity(float f); virtual float GetOpacity() const {return opacity_;} virtual void ColorBy(const mol::EntityView& ev, diff --git a/modules/gfx/src/gfx_object_base.hh b/modules/gfx/src/gfx_object_base.hh index 0ffb6d94a968bafeaf436aae29dc9351599f89d4..7b3812d6653d1e257f1e64a52f3c59897526b868 100644 --- a/modules/gfx/src/gfx_object_base.hh +++ b/modules/gfx/src/gfx_object_base.hh @@ -100,14 +100,6 @@ class DLLEXPORT_OST_GFX GfxObjBase: public GfxNode /// \brief set outline color (mode 3) virtual void SetOutlineExpandColor(const Color& c) = 0; - /// \brief ambient occlusion rendering - /// results are cached, but may be very slow on first call - virtual void AmbientOcclusion(bool f) = 0; - /// \brief blending weight of local color to fragment color - virtual void SetAmbientLocalWeight(float w) = 0; - /// \brief blending weight of occlusion factor - virtual void SetAmbientOcclusionWeight(float w) = 0; - /// \brief set opacity (1 = no transparency) virtual void SetOpacity(float f) = 0; /// \brief returns a value smaller than 1.0 if transparency is used in this object diff --git a/modules/gfx/src/impl/calc_ambient.cc b/modules/gfx/src/impl/calc_ambient.cc deleted file mode 100644 index cfbbdacc183db740b9156b214a791693d74eca3d..0000000000000000000000000000000000000000 --- a/modules/gfx/src/impl/calc_ambient.cc +++ /dev/null @@ -1,360 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2010 by the OpenStructure authors -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License as published by the Free -// Software Foundation; either version 3.0 of the License, or (at your option) -// any later version. -// This library is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -// details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this library; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ - -/* - Author: Ansgar Philippsen -*/ - -#include <map> -#include <vector> -#include <limits> - -#include <ost/geom/geom.hh> -#include <ost/gfx/vertex_array.hh> - -#include "calc_ambient.hh" - -using namespace ost; -using namespace ost::gfx; - -namespace { - - typedef IndexedVertexArray::EntryList EntryList; - typedef IndexedVertexArray::IndexList IndexList; - - geom::Vec3 abs(const geom::Vec3& v) { - geom::Vec3 nrvo(std::abs(v[0]),std::abs(v[1]),std::abs(v[2])); - return nrvo; - } - - std::pair<geom::Vec3, geom::Vec3> calc_limits(const EntryList& elist) - { - geom::Vec3 minc(std::numeric_limits<float>::max(), - std::numeric_limits<float>::max(), - std::numeric_limits<float>::max()); - geom::Vec3 maxc(-std::numeric_limits<float>::max(), - -std::numeric_limits<float>::max(), - -std::numeric_limits<float>::max()); - - for(EntryList::const_iterator it=elist.begin();it!=elist.end();++it) { -#if OST_DOUBLE_PRECISION - minc[0]=std::min(static_cast<double>(it->v[0]),minc[0]); - minc[1]=std::min(static_cast<double>(it->v[1]),minc[1]); - minc[2]=std::min(static_cast<double>(it->v[2]),minc[2]); - maxc[0]=std::max(static_cast<double>(it->v[0]),maxc[0]); - maxc[1]=std::max(static_cast<double>(it->v[1]),maxc[1]); - maxc[2]=std::max(static_cast<double>(it->v[2]),maxc[2]); -#else - minc[0]=std::min(it->v[0],minc[0]); - minc[1]=std::min(it->v[1],minc[1]); - minc[2]=std::min(it->v[2],minc[2]); - maxc[0]=std::max(it->v[0],maxc[0]); - maxc[1]=std::max(it->v[1],maxc[1]); - maxc[2]=std::max(it->v[2],maxc[2]); -#endif - } - return std::make_pair(minc,maxc); - } - - struct CIndex { - CIndex(): u(0),v(0),w(0) {} - CIndex(long uu, long vv, long ww): u(uu), v(vv), w(ww) {} - long u,v,w; - bool operator<(const CIndex& rhs) const { - return u==rhs.u ? (v==rhs.v ? w<rhs.w : v<rhs.v) : u<rhs.u; - } - }; - - struct CEntry { - CEntry(): id(0), type(0) {} - CEntry(unsigned int ii, const geom::Vec3& vv1, const geom::Vec3& vv2, const geom::Vec3& vv3, const geom::Vec4& cc): - id(ii), type(3), - v0(1.0f/3.0f*(vv1+vv2+vv3)), - v1(vv1), v2(vv2), v3(vv3), v4(), - n(geom::Normalize(geom::Cross(v1-v2,v1-v3))), - c(cc) {} - CEntry(unsigned int ii, const geom::Vec3& vv1, const geom::Vec3& vv2, const geom::Vec3& vv3, const geom::Vec3& vv4, const geom::Vec4& cc): - id(ii), type(3), - v0(1.0f/4.0f*(vv1+vv2+vv3+vv4)), - v1(vv1), v2(vv2), v3(vv3), v4(vv4), - n(geom::Normalize(geom::Cross(v1-v2,v1-v3))), - c(cc) {} - - unsigned int id; // original entry id - unsigned int type; // type - geom::Vec3 v0; // center position - geom::Vec3 v1; // edge positions - geom::Vec3 v2; // edge positions - geom::Vec3 v3; // edge positions - geom::Vec3 v4; // edge positions - geom::Vec3 n; // face normal - geom::Vec4 c; // average color - }; - - struct RayEntry { - RayEntry(): v(), d2(0.0), c() {} - RayEntry(const geom::Vec3& vv, float dd): v(vv), d2(dd), c() {} - geom::Vec3 v; - float d2; - geom::Vec4 c; - bool hit; - bool back; - }; - - typedef std::vector<CEntry> CList; - typedef std::map<CIndex,CList > CMap; - - class AmbientOcclusionBuilder { - public: - AmbientOcclusionBuilder(IndexedVertexArray& va): - va_(va), cmap_(), bsize_(5.0), weight_(0.5), cutoff_(bsize_), rays_(), density_(20) - { - float delta=2.0*M_PI/static_cast<float>(density_); - for(unsigned int s=0;s<density_/2;++s) { - float a=s*delta; - float z=std::cos(a); - float x=std::sin(a); - unsigned int tmp_subdiv=static_cast<unsigned int>(round(2.0*M_PI*std::abs(x)/delta)); - if(tmp_subdiv==0) { - rays_.push_back(RayEntry(geom::Vec3(0.0,0.0,z/std::abs(z)),cutoff_*cutoff_)); - } else { - float tmp_delta=2.0*M_PI/static_cast<float>(tmp_subdiv); - for(unsigned int t=0;t<tmp_subdiv;++t) { - float b=t*tmp_delta; - rays_.push_back(RayEntry(geom::Normalize(geom::Vec3(x*std::cos(b),x*std::sin(b),z)),cutoff_*cutoff_)); - } - } - } - } - - CIndex coord_to_index(const geom::Vec3& v) - { - return CIndex(static_cast<int>(floor(v[0]/bsize_)), - static_cast<int>(floor(v[1]/bsize_)), - static_cast<int>(floor(v[2]/bsize_))); - } - - void build_cmap() { - const EntryList& elist = va_.GetEntries(); - const IndexList& tlist = va_.GetTriIndices(); - const IndexList& qlist = va_.GetQuadIndices(); - - cmap_.clear(); - float inv3 = 1.0f/3.0; - for(unsigned int c=0;c<tlist.size();c+=3) { - geom::Vec4 c0(elist[tlist[c+0]].c); - geom::Vec4 c1(elist[tlist[c+1]].c); - geom::Vec4 c2(elist[tlist[c+2]].c); - CEntry ce = add_to_cmap(c,geom::Vec3(elist[tlist[c+0]].v),geom::Vec3(elist[tlist[c+1]].v),geom::Vec3(elist[tlist[c+2]].v),inv3*(c0+c1+c2)); - //std::cerr << c << " " << ce.n << " "; - //std::cerr << geom::Vec3(elist[tlist[c+0]].n) << " "; - //std::cerr << geom::Vec3(elist[tlist[c+1]].n) << " "; - //std::cerr << geom::Vec3(elist[tlist[c+2]].n) << std::endl; - } - float inv4 = 1.0f/4.0; - for(unsigned int c=0;c<qlist.size();c+=4) { - geom::Vec4 c0(elist[qlist[c+0]].c); - geom::Vec4 c1(elist[qlist[c+1]].c); - geom::Vec4 c2(elist[qlist[c+2]].c); - geom::Vec4 c3(elist[qlist[c+3]].c); - add_to_cmap(c,geom::Vec3(elist[qlist[c+0]].v),geom::Vec3(elist[qlist[c+1]].v),geom::Vec3(elist[qlist[c+2]].v),geom::Vec3(elist[qlist[c+3]].v),inv4*(c0+c1+c2+c3)); - } - } - - CEntry add_to_cmap(unsigned int id, const geom::Vec3& v1, const geom::Vec3& v2, const geom::Vec3& v3, const geom::Vec4& c) - { - CEntry ce(id,v1,v2,v3,c); - CIndex cindex=coord_to_index(ce.v0); - CMap::iterator it=cmap_.find(cindex); - if(it==cmap_.end()) { - std::vector<CEntry> tmplist(1); - tmplist[0]=ce; - cmap_[cindex]=tmplist; - } else { - it->second.push_back(ce); - } - return ce; - } - - CEntry add_to_cmap(unsigned int id, const geom::Vec3& v1, const geom::Vec3& v2, const geom::Vec3& v3, const geom::Vec3& v4, const geom::Vec4& c) - { - CEntry ce(id,v1,v2,v3,v4,c); - CIndex cindex=coord_to_index(ce.v0); - CMap::iterator it=cmap_.find(cindex); - if(it==cmap_.end()) { - std::vector<CEntry> tmplist(1); - tmplist[0]=ce; - cmap_[cindex]=tmplist; - } else { - it->second.push_back(ce); - } - return ce; - } - - void accumulate(const CIndex& cindex, const CEntry& ce) - { - float cutoff2=cutoff_*cutoff_; - CMap::iterator mit=cmap_.find(cindex); - if(mit==cmap_.end()) return; - for(std::vector<CEntry>::const_iterator eit=mit->second.begin();eit!=mit->second.end();++eit) { - geom::Vec3 dir0=(eit->v0-ce.v0); // vector from reference entry to current entry - float l2=geom::Length2(dir0); - if(l2>cutoff2 || l2<0.01) continue; - - dir0=geom::Normalize(dir0); - - if(geom::Dot(dir0,ce.n)<1e-6) continue; - - // largest opening angle from reference entry to corners - float a0=1.0; - if(eit->type==3) { - a0 = (geom::Dot(dir0,geom::Normalize(eit->v1-ce.v0))+ - geom::Dot(dir0,geom::Normalize(eit->v2-ce.v0))+ - geom::Dot(dir0,geom::Normalize(eit->v3-ce.v0)))/3.0; - } else if(eit->type==4) { - a0 = (geom::Dot(dir0,geom::Normalize(eit->v1-ce.v0))+ - geom::Dot(dir0,geom::Normalize(eit->v2-ce.v0))+ - geom::Dot(dir0,geom::Normalize(eit->v3-ce.v0))+ - geom::Dot(dir0,geom::Normalize(eit->v4-ce.v0)))/4.0; - } - - for(std::vector<RayEntry>::iterator rit=rays_.begin();rit!=rays_.end();++rit) { - if(rit->back) continue; - if(geom::Dot(ce.n,rit->v)<1e-6) { - rit->back=true; - continue; - } - if(geom::Dot(dir0,rit->v)<a0) continue; - if(rit->d2<l2) continue; - rit->d2=l2; - rit->c=eit->c; - rit->hit=true; - } - } - } - - void calc_all() { - const EntryList& elist = va_.GetEntries(); - const IndexList& tlist = va_.GetTriIndices(); - const IndexList& qlist = va_.GetQuadIndices(); - float cutoff2=cutoff_*cutoff_; - float isig2 = 1.0/(2.0*2.0*cutoff_/3.0*cutoff_/3.0); - - std::vector<std::pair<geom::Vec4, int> > entry_accum(elist.size()); - - for(CMap::iterator mit=cmap_.begin();mit!=cmap_.end();++mit) { - for(CList::iterator lit=mit->second.begin();lit!=mit->second.end();++lit) { - // reset rays - for(std::vector<RayEntry>::iterator rit=rays_.begin();rit!=rays_.end();++rit) { - rit->d2=cutoff2; - rit->hit=false; - rit->back=false; - } - // visit all 27 quadrants - for(int w=-1;w<=1;++w) { - for(int v=-1;v<=1;++v) { - for(int u=-1;u<=1;++u) { - accumulate(CIndex(mit->first.u+u,mit->first.v+v,mit->first.w+w),*lit); - } - } - } - - // sum up ray contributions - float occl=0.0; - float occl_sum=0.0; - geom::Vec4 col(0.0,0.0,0.0,0.0); - float col_weight_sum=0.0; - for(std::vector<RayEntry>::iterator rit=rays_.begin();rit!=rays_.end();++rit) { - if(!rit->back) { - float ca=std::max(Real(0.0),geom::Dot(rit->v,lit->n)); - occl_sum += ca; - if(!rit->hit) { - occl += ca; - float col_weight=exp(-rit->d2*isig2); - col[0] += col_weight*rit->c[0]; - col[1] += col_weight*rit->c[1]; - col[2] += col_weight*rit->c[2]; - col_weight_sum+=col_weight; - } - } - } - if(occl_sum>0.0) occl/=occl_sum; - if(col_weight_sum>0.0) col/=col_weight_sum; - - col[3]=occl; - if(lit->type==3) { - unsigned int litid=lit->id; - /* - entry_accum[tlist[litid+0]].first+=col; - entry_accum[tlist[litid+0]].second+=1; - entry_accum[tlist[litid+1]].first+=col; - entry_accum[tlist[litid+1]].second+=1; - entry_accum[tlist[litid+2]].first+=col; - entry_accum[tlist[litid+2]].second+=1; - */ - std::pair<geom::Vec4,int>* e=&entry_accum[tlist[litid++]]; - e->first+=col; ++e->second; - e=&entry_accum[tlist[litid++]]; - e->first+=col; ++e->second; - e=&entry_accum[tlist[litid++]]; - e->first+=col; ++e->second; - } else if(lit->type==4) { - unsigned int litid=lit->id; - std::pair<geom::Vec4,int>* e=&entry_accum[qlist[litid++]]; - e->first+=col; ++e->second; - e=&entry_accum[qlist[litid++]]; - e->first+=col; ++e->second; - e=&entry_accum[qlist[litid++]]; - e->first+=col; ++e->second; - e=&entry_accum[qlist[litid++]]; - e->first+=col; ++e->second; - } - } - } - for(unsigned int i=0;i<elist.size();++i) { - float fact = entry_accum[i].second==0 ? 1.0f : 1.0f/static_cast<float>(entry_accum[i].second); - va_.SetAmbientColor(i,Color(entry_accum[i].first[0]*fact, - entry_accum[i].first[1]*fact, - entry_accum[i].first[2]*fact, - entry_accum[i].first[3]*fact)); - } - } - - private: - IndexedVertexArray& va_; - CMap cmap_; - float bsize_; - float weight_; - float cutoff_; - std::vector<RayEntry> rays_; - unsigned int density_; - }; - -} // ns - - - -void ost::gfx::CalcAmbientTerms(IndexedVertexArray& va) -{ - AmbientOcclusionBuilder aob(va); - LOGN_VERBOSE("building component map"); - aob.build_cmap(); - LOGN_VERBOSE("calculating ambient terms"); - aob.calc_all(); -} diff --git a/modules/gfx/src/impl/calc_ambient.hh b/modules/gfx/src/impl/calc_ambient.hh deleted file mode 100644 index 6064f84c9aabf4344734254461e91a2b67683788..0000000000000000000000000000000000000000 --- a/modules/gfx/src/impl/calc_ambient.hh +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2010 by the OpenStructure authors -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License as published by the Free -// Software Foundation; either version 3.0 of the License, or (at your option) -// any later version. -// This library is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -// details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this library; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ -#ifndef OST_CALC_AMBIENT_HH -#define OST_CALC_AMBIENT_HH - -/* - calculate ambient contributions per VA entry - - Author: Ansgar Philippsen -*/ - -namespace ost { namespace gfx { - - class IndexedVertexArray; - void CalcAmbientTerms(IndexedVertexArray& va); - -}} // ns - -#endif diff --git a/modules/gfx/src/impl/cpk_renderer.cc b/modules/gfx/src/impl/cpk_renderer.cc index 2d94c8a577a7ded825b60dc28c37180008fbdb94..f2d74a4d2fdeec173258e53211d292ef7cb7af03 100644 --- a/modules/gfx/src/impl/cpk_renderer.cc +++ b/modules/gfx/src/impl/cpk_renderer.cc @@ -74,8 +74,8 @@ void CPKRenderer::Render(RenderPass pass) { if(options_!=NULL){ #if OST_SHADER_SUPPORT_ENABLED - if(pass==STANDARD_RENDER_PASS && (options_->GetCPKMode()==1 || options_->GetCPKMode()==2)) { - this->RenderCPK2(); + if(pass==STANDARD_RENDER_PASS && (options_->GetSphereMode()==1 || options_->GetSphereMode()==2)) { + this->Render3DSprites(); return; } #endif @@ -110,78 +110,11 @@ RenderOptionsPtr CPKRenderer::GetOptions(){ return options_; } -std::vector<impl::AtomEntry*> CPKRenderer::CPKOcclusion() -{ - - std::vector<impl::AtomEntry*> aelist; - -#if OST_SHADER_SUPPORT_ENABLED - static const float isq2 = 1.0/sqrt(2.0); - geom::Mat3 irot=geom::Transpose(Scene::Instance().GetTransform().GetRot()); - geom::Vec3 cx=irot*geom::Vec3(isq2,0.0,0.0); - geom::Vec3 cy=irot*geom::Vec3(0.0,isq2,0.0); - - Shader::Instance().PushProgram(); - Shader::Instance().Activate(""); - - glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glDisable(GL_LIGHTING); - glDisable(GL_CULL_FACE); - glDisable(GL_FOG); - glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); - - glBegin(GL_QUADS); - for(AtomEntryMap::const_iterator it=view_.atom_map.begin(); - it!=view_.atom_map.end();++it) { - geom::Vec3 pos = it->second.atom.GetPos(); - float rad = it->second.vdwr; - glVertex3v((pos-rad*cx-rad*cy).Data()); - glVertex3v((pos-rad*cx+rad*cy).Data()); - glVertex3v((pos+rad*cx+rad*cy).Data()); - glVertex3v((pos+rad*cx-rad*cy).Data()); - } - glEnd(); - - cx=irot*geom::Vec3(1.0,0.0,0.0); - cy=irot*geom::Vec3(0.0,1.0,0.0); - - glDepthMask(GL_FALSE); - - uint query_id; - glGenQueries(1,&query_id); - - for(AtomEntryMap::iterator it=view_.atom_map.begin(); - it!=view_.atom_map.end();++it) { - geom::Vec3 pos = it->second.atom.GetPos(); - float rad = it->second.vdwr; - glBeginQuery(GL_SAMPLES_PASSED, query_id); - glBegin(GL_QUADS); - glVertex3v((pos-rad*cx-rad*cy).Data()); - glVertex3v((pos-rad*cx+rad*cy).Data()); - glVertex3v((pos+rad*cx+rad*cy).Data()); - glVertex3v((pos+rad*cx-rad*cy).Data()); - glEnd(); - glEndQuery(GL_SAMPLES_PASSED); - GLint samples=0; - glGetQueryObjectiv(query_id,GL_QUERY_RESULT,&samples); - if(samples>0) aelist.push_back(&it->second); - } - - glDeleteQueries(1,&query_id); - - glPopAttrib(); - - Shader::Instance().PopProgram(); -#endif - - return aelist; -} - namespace { -void RenderCPK2InnerLoop(const AtomEntry* ae, const geom::Vec3& cx, - const geom::Vec3& cy, const geom::Vec3& cz, - GLdouble* gl_mmat, GLdouble* gl_pmat, GLint* gl_vp) +void Render3DSpritesInnerLoop(const AtomEntry* ae, const geom::Vec3& cx, + const geom::Vec3& cy, const geom::Vec3& cz, + GLdouble* gl_mmat, GLdouble* gl_pmat, GLint* gl_vp) { geom::Vec3 pos = ae->atom.GetPos(); float rad = ae->vdwr; @@ -206,7 +139,7 @@ void RenderCPK2InnerLoop(const AtomEntry* ae, const geom::Vec3& cx, } -void CPKRenderer::RenderCPK2() +void CPKRenderer::Render3DSprites() { #if OST_SHADER_SUPPORT_ENABLED if(options_!=NULL){ @@ -215,19 +148,13 @@ void CPKRenderer::RenderCPK2() geom::Vec3 cy=irot*geom::Vec3(0.0,1.0,0.0); geom::Vec3 cz=irot*geom::Vec3(0.0,0.0,1.0); - std::vector<AtomEntry*> aelist; - if(options_->GetCPKMode()==2) { - aelist = CPKOcclusion(); - } - - uint write_normals = Shader::Instance().GetCurrentName()=="dumpnorm" ? 1 : 0; Shader::Instance().PushProgram(); Shader::Instance().Activate("fast_sphere"); Shader::Instance().UpdateState(); glUniform1i(glGetUniformLocation(Shader::Instance().GetCurrentProgram(),"write_normals"),write_normals); - glPushAttrib(GL_ENABLE_BIT); + glPushAttrib(GL_ALL_ATTRIB_BITS); glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); @@ -239,14 +166,8 @@ void CPKRenderer::RenderCPK2() glBegin(GL_QUADS); - if(options_->GetCPKMode()==2) { - for(std::vector<AtomEntry*>::const_iterator it=aelist.begin();it!=aelist.end();++it) { - RenderCPK2InnerLoop(*it,cx,cy,cz,gl_mmat,gl_pmat,gl_vp); - } - } else { - for(AtomEntryMap::const_iterator it=view_.atom_map.begin();it!=view_.atom_map.end();++it) { - RenderCPK2InnerLoop(&it->second,cx,cy,cz,gl_mmat,gl_pmat,gl_vp); - } + for(AtomEntryMap::const_iterator it=view_.atom_map.begin();it!=view_.atom_map.end();++it) { + Render3DSpritesInnerLoop(&it->second,cx,cy,cz,gl_mmat,gl_pmat,gl_vp); } glEnd(); @@ -259,51 +180,4 @@ void CPKRenderer::RenderCPK2() #endif } -void CPKRenderer::RenderCPK3() -{ -#if OST_SHADER_SUPPORT_ENABLED - if(options_!= NULL){ - std::vector<AtomEntry*> aelist = CPKOcclusion(); - - IndexedVertexArray cpk_va; - detail::PrebuildSphereEntry pre=detail::GetPrebuildSphere(options_->GetSphereDetail()); - GLuint dlist; - dlist = glGenLists(1); - glNewList(dlist,GL_COMPILE); - glBegin(GL_TRIANGLES); - for(uint c=0;c<pre.ilist.size();c+=3) { - geom::Vec3 v0 = pre.vlist[pre.ilist[c+0]]; - geom::Vec3 v1 = pre.vlist[pre.ilist[c+1]]; - geom::Vec3 v2 = pre.vlist[pre.ilist[c+2]]; - glNormal3v(v0.Data()); - glVertex3v(v0.Data()); - glNormal3v(v1.Data()); - glVertex3v(v1.Data()); - glNormal3v(v2.Data()); - glVertex3v(v2.Data()); - } - glEnd(); - glEndList(); - - glEnable(GL_NORMALIZE); - - for(std::vector<AtomEntry*>::const_iterator it=aelist.begin();it!=aelist.end();++it) { - geom::Vec3 pos = (*it)->atom.GetPos(); - float rad = (*it)->vdwr; - glPushMatrix(); - glColor3fv((*it)->color); - glTranslated(pos[0],pos[1],pos[2]); - glScaled(rad,rad,rad); - glCallList(dlist); - glPopMatrix(); - } - glDisable(GL_NORMALIZE); - } -#endif -} - -CPKRenderer::~CPKRenderer() { - -} - }}} diff --git a/modules/gfx/src/impl/cpk_renderer.hh b/modules/gfx/src/impl/cpk_renderer.hh index e5d0503f0be4556429957a3732f63dfca1762512..241602b88aef133f722751339e14cbf79ebb9e15 100644 --- a/modules/gfx/src/impl/cpk_renderer.hh +++ b/modules/gfx/src/impl/cpk_renderer.hh @@ -43,13 +43,9 @@ public: virtual void SetOptions(RenderOptionsPtr& render_options); virtual RenderOptionsPtr GetOptions(); - virtual ~CPKRenderer(); - private: void PrepareRendering(GfxView& view, IndexedVertexArray& va, bool is_sel); - std::vector<impl::AtomEntry*> CPKOcclusion(); - void RenderCPK2(); - void RenderCPK3(); + void Render3DSprites(); CPKRenderOptionsPtr options_; }; diff --git a/modules/gfx/src/render_options/cpk_render_options.cc b/modules/gfx/src/render_options/cpk_render_options.cc index 797fcf760bcd87fd731d5b4eb82a05e3d7547abf..a8cca254d46dd64dbf8c5698556a7353724f5688 100644 --- a/modules/gfx/src/render_options/cpk_render_options.cc +++ b/modules/gfx/src/render_options/cpk_render_options.cc @@ -28,7 +28,7 @@ namespace gfx { CPKRenderOptions::CPKRenderOptions(): sphere_detail_(4) { #if OST_SHADER_SUPPORT_ENABLED - cpk_mode_=0; + cpk_mode_=1; #else cpk_mode_=0; #endif @@ -46,7 +46,7 @@ void CPKRenderOptions::ApplyRenderOptions(RenderOptionsPtr render_options){ CPKRenderOptionsPtr options = boost::static_pointer_cast<CPKRenderOptions>(render_options); sphere_detail_=options->GetSphereDetail(); - cpk_mode_=options->GetCPKMode(); + cpk_mode_=options->GetSphereMode(); this->NotifyStateChange(); } @@ -61,14 +61,14 @@ uint CPKRenderOptions::GetSphereDetail(){ return sphere_detail_; } -void CPKRenderOptions::SetCPKMode(uint mode){ +void CPKRenderOptions::SetSphereMode(uint mode){ if(cpk_mode_!=mode) { cpk_mode_=mode; this->NotifyStateChange(); } } -uint CPKRenderOptions::GetCPKMode(){ +uint CPKRenderOptions::GetSphereMode(){ return cpk_mode_; } diff --git a/modules/gfx/src/render_options/cpk_render_options.hh b/modules/gfx/src/render_options/cpk_render_options.hh index 079822fbdb2d5fd76872df6d6c34cf32c6ec0d4e..478765ce1724a5c759653a1a3bfbb79a828a3ee4 100644 --- a/modules/gfx/src/render_options/cpk_render_options.hh +++ b/modules/gfx/src/render_options/cpk_render_options.hh @@ -42,9 +42,8 @@ public: virtual void SetSphereDetail(uint detail); virtual uint GetSphereDetail(); - virtual void SetCPKMode(uint mode); - virtual uint GetCPKMode(); - + virtual void SetSphereMode(uint mode); + virtual uint GetSphereMode(); virtual ~CPKRenderOptions(); diff --git a/modules/gfx/src/vertex_array.cc b/modules/gfx/src/vertex_array.cc index 1e870c10520b15bfa18ad091e38b524bcbca6f04..3551ab8ada8b31dbc3627604468353b16dfc385e 100644 --- a/modules/gfx/src/vertex_array.cc +++ b/modules/gfx/src/vertex_array.cc @@ -31,8 +31,6 @@ #include "vertex_array_helper.hh" #include "povray.hh" -#include "impl/calc_ambient.hh" - #if OST_SHADER_SUPPORT_ENABLED #include "shader.hh" #endif @@ -142,7 +140,6 @@ VertexID IndexedVertexArray::Add(const Vec3& vert, const Color& col) { dirty_=true; - ambient_dirty_=true; entry_list_.push_back(Entry(vert,norm,col)); return entry_list_.size()-1; } @@ -163,7 +160,6 @@ LineID IndexedVertexArray::AddLine(VertexID id0, VertexID id1) { assert(id0<entry_list_.size() && id1<entry_list_.size()); dirty_=true; - ambient_dirty_=true; line_index_list_.push_back(id0); line_index_list_.push_back(id1); return line_index_list_.size()-2; @@ -173,7 +169,6 @@ TriID IndexedVertexArray::AddTri(VertexID id0, VertexID id1, VertexID id2) { assert(id0<entry_list_.size() && id1<entry_list_.size() && id2<entry_list_.size()); dirty_=true; - ambient_dirty_=true; tri_index_list_.push_back(id0); tri_index_list_.push_back(id1); tri_index_list_.push_back(id2); @@ -203,7 +198,6 @@ QuadID IndexedVertexArray::AddQuad(VertexID id0, VertexID id1, VertexID id2, Ver { assert(id0<entry_list_.size() && id1<entry_list_.size() && id2<entry_list_.size() && id3<entry_list_.size()); dirty_=true; - ambient_dirty_=true; quad_index_list_.push_back(id0); quad_index_list_.push_back(id1); quad_index_list_.push_back(id2); @@ -214,7 +208,6 @@ QuadID IndexedVertexArray::AddQuad(VertexID id0, VertexID id1, VertexID id2, Ver void IndexedVertexArray::AddSphere(const SpherePrim& prim, unsigned int detail) { dirty_=true; - ambient_dirty_=true; unsigned int level= std::min(VA_SPHERE_MAX_DETAIL,detail); @@ -235,7 +228,6 @@ void IndexedVertexArray::AddSphere(const SpherePrim& prim, unsigned int detail) void IndexedVertexArray::AddIcoSphere(const SpherePrim& prim, unsigned int detail) { dirty_=true; - ambient_dirty_=true; unsigned int level= std::min(VA_ICO_SPHERE_MAX_DETAIL,detail); @@ -252,7 +244,6 @@ void IndexedVertexArray::AddIcoSphere(const SpherePrim& prim, unsigned int detai void IndexedVertexArray::AddCylinder(const CylinderPrim& prim, unsigned int detail,bool cap) { dirty_=true; - ambient_dirty_=true; unsigned int level = std::min(VA_CYL_MAX_DETAIL,detail); @@ -390,11 +381,6 @@ void IndexedVertexArray::RenderGL() if(dirty_) { dirty_=false; #if OST_SHADER_SUPPORT_ENABLED - if(ambient_dirty_ && use_ambient_) { - LOGN_DUMP("re-calculating ambient occlusion terms"); - recalc_ambient_occlusion(); - ambient_dirty_=false; - } LOGN_DUMP("checking buffer object availability"); if(mode_&0x2 && aalines_flag_) { @@ -476,16 +462,6 @@ void IndexedVertexArray::RenderGL() } else { glDisable(GL_CULL_FACE); } -#if OST_SHADER_SUPPORT_ENABLED - if(use_ambient_ && !ambient_data_.empty()) { - glUniform1i(glGetUniformLocation(Shader::Instance().GetCurrentProgram(),"occlusion_flag"),1); - glUniform2f(glGetUniformLocation(Shader::Instance().GetCurrentProgram(),"ambient_weight"), - local_ambient_weight_, - ambient_occlusion_weight_); - } else { - glUniform1i(glGetUniformLocation(Shader::Instance().GetCurrentProgram(),"occlusion_flag"),0); - } -#endif } if(mode_&0x1) { @@ -647,14 +623,11 @@ void IndexedVertexArray::RenderPov(PovState& pov, const std::string& name) void IndexedVertexArray::Clear() { dirty_=true; - ambient_dirty_=true; entry_list_.clear(); quad_index_list_.clear(); tri_index_list_.clear(); line_index_list_.clear(); ntentry_list_.clear(); - ambient_data_.clear(); - use_ambient_=false; } void IndexedVertexArray::Reset() @@ -677,8 +650,6 @@ void IndexedVertexArray::Reset() outline_exp_factor_=0.1; outline_exp_color_=Color(0,0,0); draw_normals_=false; - local_ambient_weight_=0.3; - ambient_occlusion_weight_=1.0; } void IndexedVertexArray::FlagRefresh() @@ -951,36 +922,6 @@ void IndexedVertexArray::SmoothVertices(float smoothf) } } -void IndexedVertexArray::UseAmbient(bool f) -{ - if(use_ambient_==f) return; - use_ambient_=f; - FlagRefresh(); -} - -Color IndexedVertexArray::GetAmbientColor(VertexID id) const -{ - Color nrvo; - if(id*4>=ambient_data_.size()) return nrvo; - unsigned int offset=id*4; - nrvo = Color(ambient_data_[offset+0], - ambient_data_[offset+1], - ambient_data_[offset+2], - ambient_data_[offset+3]); - return nrvo; -} - -void IndexedVertexArray::SetAmbientColor(VertexID id, const Color& c) -{ - if(id*4>=ambient_data_.size()) return; - unsigned int offset=id*4; - ambient_data_[offset+0]=c[0]; - ambient_data_[offset+1]=c[1]; - ambient_data_[offset+2]=c[2]; - ambient_data_[offset+3]=c[3]; -} - - namespace { uint npatch_tab_id(uint u, uint v, uint N) @@ -1086,7 +1027,6 @@ void IndexedVertexArray::copy(const IndexedVertexArray& va) line_index_list_=va.line_index_list_; ntentry_list_=va.ntentry_list_; dirty_=true; - ambient_dirty_=va.ambient_dirty_; mode_=va.mode_; poly_mode_=va.poly_mode_; lighting_=va.lighting_; @@ -1104,10 +1044,6 @@ void IndexedVertexArray::copy(const IndexedVertexArray& va) outline_exp_factor_=va.outline_exp_factor_; outline_exp_color_=va.outline_exp_color_; draw_normals_=va.draw_normals_; - use_ambient_=va.use_ambient_; - ambient_data_=va.ambient_data_; - local_ambient_weight_=va.local_ambient_weight_; - ambient_occlusion_weight_=va.ambient_occlusion_weight_; } bool IndexedVertexArray::prep_buff() @@ -1177,24 +1113,6 @@ bool IndexedVertexArray::prep_buff() VERTEX_ARRAY_CHECK_GL_ERROR("set qindex buf"); } - if(use_ambient_) { - if(ambient_data_.empty()) { - LOGN_VERBOSE("ambient data empty"); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } else { - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glBindBuffer(GL_ARRAY_BUFFER, buffer_id_[VA_AMBIENT_BUFFER]); - VERTEX_ARRAY_CHECK_GL_ERROR("bind ambient buf"); - glBufferData(GL_ARRAY_BUFFER, - sizeof(float) * ambient_data_.size(), - &ambient_data_[0], - GL_STATIC_DRAW); - VERTEX_ARRAY_CHECK_GL_ERROR("set ambient buf"); - } - } else { - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - return true; #else return false; @@ -1221,12 +1139,6 @@ void IndexedVertexArray::draw_ltq(bool use_buff) glInterleavedArrays(GetFormat(),sizeof(Entry),NULL); #endif - if(use_ambient_) { - if(!ambient_data_.empty()) { - glBindBuffer(GL_ARRAY_BUFFER, buffer_id_[VA_AMBIENT_BUFFER]); - glTexCoordPointer(4,GL_FLOAT,0,NULL); - } - } glBindBuffer(GL_ARRAY_BUFFER,0); if(!tri_index_list_.empty() && (mode_ & 0x4)) { @@ -1457,10 +1369,4 @@ void IndexedVertexArray::draw_line_halo(bool use_buff) glLineWidth(line_width_); } -void IndexedVertexArray::recalc_ambient_occlusion() -{ - ambient_data_.resize(4*entry_list_.size()); - CalcAmbientTerms(*this); -} - }} // ns diff --git a/modules/gfx/src/vertex_array.hh b/modules/gfx/src/vertex_array.hh index c11de523f8c8108d81cf217561922515b751b1d9..c1916dc7ffe52f091c7a4e7adccedf530f87b9b8 100644 --- a/modules/gfx/src/vertex_array.hh +++ b/modules/gfx/src/vertex_array.hh @@ -153,17 +153,6 @@ class DLLEXPORT_OST_GFX IndexedVertexArray { // POVray export void RenderPov(PovState& pov, const std::string& name); - // turn on ambient lighting, first call may take a while - void UseAmbient(bool f); - - // see fraglight_lf_fs shader - void AmbientLocalWeight(float w) {local_ambient_weight_=w;} - // see fraglight_lf_fs shader - void AmbientOcclusionWeight(float w) {ambient_occlusion_weight_=w;} - - Color GetAmbientColor(VertexID id) const; - void SetAmbientColor(VertexID id, const Color& col); - // only removes the drawing elements void Clear(); // removes all elements and resets internal state to default @@ -229,19 +218,12 @@ class DLLEXPORT_OST_GFX IndexedVertexArray { unsigned int buffer_id_[7]; // magic number related to the .cc buffer use - bool use_ambient_; - bool ambient_dirty_; - std::vector<float> ambient_data_; - float local_ambient_weight_; - float ambient_occlusion_weight_; - void copy(const IndexedVertexArray& va); bool prep_buff(); void draw_ltq(bool use_buff); void draw_p(bool use_buff); void draw_aalines(); void draw_line_halo(bool use_buff); - void recalc_ambient_occlusion(); }; }} // ns diff --git a/modules/gui/pymod/scene/cpk_widget.py b/modules/gui/pymod/scene/cpk_widget.py index 7df40874321a6023caa3c7f5495379c4e5dfe69e..cb47ba742eeaf00ed818121e0ea957dfcb2cab1b 100644 --- a/modules/gui/pymod/scene/cpk_widget.py +++ b/modules/gui/pymod/scene/cpk_widget.py @@ -46,8 +46,7 @@ class CPKWidget(RenderModeWidget): cpk_mode_label = QtGui.QLabel("Rendering Mode") self.cpk_mode_ = QtGui.QComboBox() self.cpk_mode_.addItem("Triangles") - self.cpk_mode_.addItem("Fast Spheres (exp") - self.cpk_mode_.addItem("Fast Spheres ++ (exp)") + self.cpk_mode_.addItem("3D Sprites") cpk_label = QtGui.QLabel(self.text_) font = cpk_label.font() @@ -68,19 +67,19 @@ class CPKWidget(RenderModeWidget): self.setLayout(grid) QtCore.QObject.connect(self.sphere_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSphereDetail) - QtCore.QObject.connect(self.cpk_mode_, QtCore.SIGNAL("currentIndexChanged(int)"), self.UpdateCPKMode) + QtCore.QObject.connect(self.cpk_mode_, QtCore.SIGNAL("currentIndexChanged(int)"), self.UpdateSphereMode) self.setMinimumSize(250,60) def UpdateSphereDetail(self, value): self.GetOptions().SetSphereDetail(value) - def UpdateCPKMode(self, value): - self.GetOptions().SetCPKMode(value) + def UpdateSphereMode(self, value): + self.GetOptions().SetSphereMode(value) def UpdateGui(self,options): self.sphere_spinbox_.setValue(options.GetSphereDetail()) - self.cpk_mode_.setCurrentIndex(options.GetCPKMode()) + self.cpk_mode_.setCurrentIndex(options.GetSphereMode()) def GetText(self): return self.text_