Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Molecule_rendering.cpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #include <vlMolecule/Molecule.hpp>
34 #include <vlGraphics/Text.hpp>
35 #include <vlGraphics/Light.hpp>
36 
37 using namespace vl;
38 
39 //-----------------------------------------------------------------------------
40 class EffectCache
41 {
42 public:
43  EffectCache(): mLight(new Light) {}
44 
45  void clear() { effects().clear(); }
46 
47  Effect* acquireEffect(const fvec4& color)
48  {
49  for(unsigned i=0; i<effects().size(); ++i)
50  {
51  if (effects()[i]->shader()->gocMaterial()->frontDiffuse() == color)
52  {
53  return effects()[i].get();
54  }
55  }
56 
57  ref<Effect> fx = new Effect;
58  fx->shader()->enable(EN_DEPTH_TEST);
59  fx->shader()->enable(EN_CULL_FACE);
60  fx->shader()->enable(EN_LIGHTING);
61  fx->shader()->setRenderState(mLight.get(), 0);
62  fx->shader()->gocMaterial()->setDiffuse(color);
63  effects().push_back(fx.get());
64  return fx.get();
65  }
66 
67  const std::vector< ref<Effect> >& effects() const { return mEffects; }
68  std::vector< ref<Effect> >& effects() { return mEffects; }
69 
70  const Light* light() const { return mLight.get(); }
71  Light* light() { return mLight.get(); }
72 
73 protected:
74  std::vector< ref<Effect> > mEffects;
75  ref<Light> mLight;
76 };
77 //-----------------------------------------------------------------------------
78 class AtomGeometryCache
79 {
80 public:
81  AtomGeometryCache(): mDetail(1) {}
82 
83  void clear() { mGeometryMap.clear(); }
84  const std::map< float, ref<Geometry> >& geometryMap() const { return mGeometryMap; }
85  std::map< float, ref<Geometry> >& geometryMap() { return mGeometryMap; }
86  Geometry* acquireAtomGeometry(float radius)
87  {
88  std::map< float, ref<Geometry> >::iterator it = geometryMap().find(radius);
89  if (it!=geometryMap().end())
90  return it->second.get();
91  else
92  {
93  ref<Geometry> sphere = makeIcosphere( vec3(0,0,0), radius*2.0f, detail() );
94  geometryMap()[radius] = sphere;
95  return sphere.get();
96  }
97  }
98 
99  int detail() const { return mDetail; }
100  void setDetail(int detail) { mDetail = detail; }
101 
102 protected:
103  std::map< float, ref<Geometry> > mGeometryMap;
104  int mDetail;
105 };
106 //-----------------------------------------------------------------------------
107 class BondGeometryCache
108 {
109  class BondKey
110  {
111  public:
112  float height;
113  fvec4 col1;
114  fvec4 col2;
115  ECapsuleCap top_cap;
116  ECapsuleCap bottom_cap;
117 
118  BondKey(float h, const fvec4& c1, const fvec4& c2, ECapsuleCap topcap, ECapsuleCap bottomcap): height(h), col1(c1), col2(c2), top_cap(topcap), bottom_cap(bottomcap) {}
119  bool operator==(const BondKey& other) const
120  {
121  return height == other.height &&
122  col1 == other.col1 &&
123  col2 == other.col2 &&
124  top_cap == other.top_cap &&
125  bottom_cap == other.bottom_cap;
126  }
127  bool operator<(const BondKey& other) const
128  {
129  if (top_cap!=other.top_cap)
130  return top_cap<other.top_cap;
131  else
132  if (bottom_cap!=other.bottom_cap)
133  return bottom_cap<other.bottom_cap;
134  else
135  if (height!=other.height)
136  return height<other.height;
137  else
138  if (col1!=other.col1)
139  return col1<other.col1;
140  else
141  return col2<other.col2;
142  }
143  };
144 public:
145  BondGeometryCache(): mDetail(20), mDiameter(0.20f), mQuantization(100.0f) {}
146 
147  void clear() { mGeometryMap.clear(); }
148  const std::map< BondKey, ref<Geometry> >& geometryMap() const { return mGeometryMap; }
149  std::map< BondKey, ref<Geometry> >& geometryMap() { return mGeometryMap; }
150  Geometry* acquireBondGeometry(float length, const fvec4& c1, const fvec4& c2, ECapsuleCap top_cap, ECapsuleCap bottom_cap)
151  {
152  float quant_lenght = int(length*quantization()) / quantization();
153  BondKey key(quant_lenght,c1,c2,top_cap,bottom_cap);
154  std::map< BondKey, ref<Geometry> >::iterator it = geometryMap().find( key );
155  if (it!=geometryMap().end())
156  {
157  VL_CHECK(it->first == key)
158  return it->second.get();
159  }
160  else
161  {
162  ref<Geometry> cylinder = makeCapsule( diameter()/2.0f, quant_lenght+2.0f/quantization(), detail(), top_cap, bottom_cap, c2, c1 );
163  cylinder->computeNormals();
164  geometryMap()[key] = cylinder;
165  return cylinder.get();
166  }
167  }
168 
169  int detail() const { return mDetail; }
170  void setDetail(int detail) { mDetail = detail; }
171 
172  float diameter() const { return mDiameter; }
173  void setDiameter(float diameter) { mDiameter = diameter; }
174 
175  float quantization() const { return mQuantization; }
176  void setQuantization(float quantization) { mQuantization = quantization; }
177 
178 protected:
179  std::map< BondKey, ref<Geometry> > mGeometryMap;
180  int mDetail;
181  float mDiameter;
182  float mQuantization;
183 };
184 //-----------------------------------------------------------------------------
186 {
187  actorTree()->actors()->clear();
188  transformTree()->eraseAllChildren();
189 
190  switch(moleculeStyle())
191  {
192  case MS_Wireframe: wireframeStyle(); generateRings(); break;
193  case MS_BallAndStick: ballAndStickStyle(); generateRings(); break;
194  case MS_Sticks: sticksStyle(); generateRings(); break;
195  case MS_AtomsOnly: atomsStyle(); break;
196  }
197  generateAtomLabels();
198  transformTree()->computeWorldMatrixRecursive();
199 }
200 //-----------------------------------------------------------------------------
202 {
203  if (atomLabelTemplate()->font() &&
204  showAtomNames() &&
205  atom->visible() &&
206  atom->showAtomName() )
207  {
208  ref<Text> text = new Text;
209  // text label
210  text->setText( atom->atomName().c_str() );
211  // text template style
212  text->setViewportAlignment( atomLabelTemplate()->viewportAlignment() );
213  text->setTextAlignment( atomLabelTemplate()->textAlignment() );
214  text->setShadowVector( atomLabelTemplate()->shadowVector() );
215  text->setShadowEnabled( atomLabelTemplate()->shadowEnabled() );
216  text->setShadowColor( atomLabelTemplate()->shadowColor() );
217  text->setOutlineEnabled( atomLabelTemplate()->outlineEnabled() );
218  text->setOutlineColor( atomLabelTemplate()->outlineColor() );
219  text->setMode( atomLabelTemplate()->mode() );
220  text->setMargin( atomLabelTemplate()->margin() );
221  text->setKerningEnabled( atomLabelTemplate()->kerningEnabled() );
222  text->setFont( atomLabelTemplate()->font() );
223  text->setColor( atomLabelTemplate()->color() );
224  text->setBorderEnabled( atomLabelTemplate()->borderEnabled() );
225  text->setBorderColor( atomLabelTemplate()->borderColor() );
226  text->setBackgroundEnabled( atomLabelTemplate()->backgroundEnabled() );
227  text->setBackgroundColor( atomLabelTemplate()->backgroundColor() );
228  text->setAlignment( atomLabelTemplate()->alignment() );
229  // text actor
230  ref<Actor> text_act = new Actor( text.get(), mAtomLabelEffect.get(), tr );
231  actorTree()->actors()->push_back(text_act.get());
232  }
233 }
234 //-----------------------------------------------------------------------------
236 {
237  for(unsigned i=0; i<atoms().size(); ++i)
238  {
239  ref<Transform> tr = new Transform(mat4::getTranslation((vec3)atoms()[i]->coordinates()));
240  transformTree()->addChild(tr.get());
241  generateAtomLabel(atoms()[i].get(), tr.get());
242  }
243 }
244 //-----------------------------------------------------------------------------
246 {
247  // no maps are generated for this style.
248  mAtomToActorMap.clear();
249  mActorToAtomMap.clear();
250  mBondToActorMap.clear();
251  mActorToBondMap.clear();
252 
253  ref<Geometry> geom = new Geometry;
254  ref<ArrayFloat3> points = new ArrayFloat3;
255  geom->setVertexArray(points.get());
256  ref<ArrayFloat4> colors = new ArrayFloat4;
257  geom->setColorArray(colors.get());
258  std::vector<fvec3> pt;
259  std::vector<fvec4> cols;
260  for(unsigned ibond=0; ibond<bonds().size(); ++ibond)
261  {
262  Bond* b = bond(ibond);
263  if (b->visible() && b->atom1()->visible() && b->atom2()->visible())
264  {
265  fvec4 c1 = b->color();
266  fvec4 c2 = b->color();
267  if (b->useAtomColors())
268  {
269  c1 = b->atom1()->color();
270  c2 = b->atom2()->color();
271  }
272  if (c1 == c2)
273  {
274  pt.push_back( b->atom1()->coordinates() );
275  pt.push_back( b->atom2()->coordinates() );
276  cols.push_back(c1);
277  cols.push_back(c1);
278  }
279  else
280  {
281  fvec3 center = (b->atom1()->coordinates() + b->atom2()->coordinates())/2.0f;
282  pt.push_back( b->atom1()->coordinates() );
283  pt.push_back( center );
284  pt.push_back( center );
285  pt.push_back( b->atom2()->coordinates() );
286  cols.push_back(c1);
287  cols.push_back(c1);
288  cols.push_back(c2);
289  cols.push_back(c2);
290  }
291  }
292  }
293  points->initFrom(pt);
294  colors->initFrom(cols);
295  geom->drawCalls().push_back(new DrawArrays(PT_LINES, 0, (int)points->size()));
296 
297  ref<Effect> fx = new Effect;
298  fx->shader()->enable(EN_DEPTH_TEST);
299  if (smoothLines())
300  {
301  fx->shader()->enable(EN_BLEND);
302  fx->shader()->enable(EN_LINE_SMOOTH);
303  }
304  if (lineWidth() != 1.0f)
305  fx->shader()->gocLineWidth()->set(lineWidth());
306 
307  actorTree()->actors()->push_back( new Actor(geom.get(), fx.get(), NULL) );
308 }
309 //-----------------------------------------------------------------------------
311 {
312  mAtomToActorMap.clear();
313  mActorToAtomMap.clear();
314  mBondToActorMap.clear();
315  mActorToBondMap.clear();
316 
317  EffectCache fx_cache;
318  AtomGeometryCache atom_geom_cache;
319  atom_geom_cache.setDetail(atomDetail());
320  for(unsigned iatom=0; iatom<atoms().size(); ++iatom)
321  {
322  if (atom(iatom)->visible())
323  {
324  Effect* fx = fx_cache.acquireEffect(atom(iatom)->color());
325  float r = atom(iatom)->radius();
326  ref<Geometry> ball = atom_geom_cache.acquireAtomGeometry(r);
327  ref<Actor> atom_act = new Actor( ball.get(), fx, new Transform );
328  atom_act->transform()->setLocalMatrix( mat4::getTranslation( (vec3)atom(iatom)->coordinates()) );
329  transformTree()->addChild(atom_act->transform());
330  actorTree()->actors()->push_back( atom_act.get() );
331 
332  // actor -> atom map
333  if (isActorToMoleculeMapEnabled())
334  mActorToAtomMap.insert( std::pair< ref<Actor>, ref<Atom> >(atom_act, atom(iatom)) );
335  // atom -> actor map
336  if (isMoleculeToActorMapEnabled())
337  mAtomToActorMap.insert( std::pair< ref<Atom>, ref<Actor> >(atom(iatom), atom_act) );
338  }
339  }
340 }
341 //-----------------------------------------------------------------------------
343 {
344  mAtomToActorMap.clear();
345  mActorToAtomMap.clear();
346  mBondToActorMap.clear();
347  mActorToBondMap.clear();
348 
349  EffectCache fx_cache;
350  AtomGeometryCache atom_geom_cache;
351  atom_geom_cache.setDetail(atomDetail());
352  for(unsigned int iatom=0; iatom<atoms().size(); ++iatom)
353  {
354  if (atom(iatom)->visible())
355  {
356  Effect* fx = fx_cache.acquireEffect(atom(iatom)->color());
357  float r = atom(iatom)->radius();
358  ref<Geometry> ball = atom_geom_cache.acquireAtomGeometry(r);
359 
360  // mic fixme:
361  // it would be nice to have a pool to accelerate Actor and Transform allocation
362 
363  ref<Actor> atom_act = new Actor( ball.get(), fx, new Transform );
364  atom_act->transform()->setLocalMatrix( mat4::getTranslation( (vec3)atom(iatom)->coordinates()) );
365  transformTree()->addChild(atom_act->transform());
366  actorTree()->actors()->push_back( atom_act.get() );
367 
368  // actor -> atom map
369  if (isActorToMoleculeMapEnabled())
370  mActorToAtomMap.insert( std::pair< ref<Actor>, ref<Atom> >(atom_act, atom(iatom)) );
371  // atom -> actor map
372  if (isMoleculeToActorMapEnabled())
373  mAtomToActorMap.insert( std::pair< ref<Atom>, ref<Actor> >(atom(iatom), atom_act) );
374  }
375  }
376 
377  ref<Effect> fx = new Effect;
378  fx->shader()->enable(EN_DEPTH_TEST);
379  fx->shader()->enable(EN_CULL_FACE);
381  fx->shader()->gocLightModel()->setTwoSide(false);
382  fx->shader()->enable(EN_LIGHTING);
383  fx->shader()->setRenderState( fx_cache.light(), 0 );
384  // fx->shader()->gocPolygonMode()->set(PM_LINE, PM_LINE);
385 
386  BondGeometryCache bond_geom_cache;
387  bond_geom_cache.setDetail(bondDetail());
388  for(unsigned int ibond=0; ibond<bonds().size(); ++ibond)
389  {
390  if (bond(ibond)->visible() && bond(ibond)->atom1()->visible() && bond(ibond)->atom2()->visible())
391  {
392  Bond* b = bond(ibond);
393  fvec4 c1 = b->color();
394  fvec4 c2 = b->color();
395  if (b->useAtomColors())
396  {
397  c1 = b->atom1()->color();
398  c2 = b->atom2()->color();
399  }
400  float len = (b->atom1()->coordinates() - b->atom2()->coordinates()).length();
401  float diam = b->radius()*2.0f;
402  bond_geom_cache.setDiameter(diam);
403  ref<Geometry> geom = bond_geom_cache.acquireBondGeometry(len,c1,c2,CC_NoCap,CC_NoCap);
404  ref<Actor> bond_act = new Actor( geom.get(), fx.get(), new Transform );
405  transformTree()->addChild(bond_act->transform());
406  fvec3 center = (b->atom1()->coordinates() + b->atom2()->coordinates()) / 2.0f;
407  fvec3 direction = (b->atom2()->coordinates() - b->atom1()->coordinates()).normalize();
408  fmat4 mat = fmat4::getTranslation(center) * fmat4::getRotation(fvec3(0,1,0), direction);
409  bond_act->transform()->setLocalMatrix( (mat4)mat );
410  actorTree()->actors()->push_back( bond_act.get() );
411 
412  // actor -> bond map
413  if (isActorToMoleculeMapEnabled())
414  mActorToBondMap.insert( std::pair< ref<Actor>, ref<Bond> >(bond_act, bond(ibond)) );
415  // bond -> actor map
416  if (isMoleculeToActorMapEnabled())
417  mBondToActorMap.insert( std::pair< ref<Bond>, ref<Actor> >(bond(ibond), bond_act) );
418  }
419  }
420 }
421 //-----------------------------------------------------------------------------
423 {
424  mAtomToActorMap.clear();
425  mActorToAtomMap.clear();
426  mBondToActorMap.clear();
427  mActorToBondMap.clear();
428 
429  ref<Effect> fx = new Effect;
430  fx->shader()->enable(EN_DEPTH_TEST);
431  fx->shader()->enable(EN_CULL_FACE);
433  fx->shader()->gocLightModel()->setTwoSide(false);
434  fx->shader()->enable(EN_LIGHTING);
435  fx->shader()->setRenderState( new Light, 0 );
436  /*fx->shader()->gocPolygonMode()->set(PM_LINE, PM_LINE);*/
437 
438  BondGeometryCache bond_geom_cache;
439  bond_geom_cache.setDetail(bondDetail());
440  for(unsigned int ibond=0; ibond<bonds().size(); ++ibond)
441  {
442  if (bond(ibond)->visible() && bond(ibond)->atom1()->visible() && bond(ibond)->atom2()->visible())
443  {
444  Bond* b = bond(ibond);
445  fvec4 c1 = b->color();
446  fvec4 c2 = b->color();
447  if (b->useAtomColors())
448  {
449  c1 = b->atom1()->color();
450  c2 = b->atom2()->color();
451  }
452  float len = (b->atom1()->coordinates() - b->atom2()->coordinates()).length();
453  float diam = b->radius()*2.0f;
454  bond_geom_cache.setDiameter(diam);
455  ref<Geometry> geom = bond_geom_cache.acquireBondGeometry(len,c1,c2,CC_RoundedCap,CC_RoundedCap);
456  ref<Actor> bond_act = new Actor( geom.get(), fx.get(), new Transform );
457  transformTree()->addChild(bond_act->transform());
458  fvec3 center = (b->atom1()->coordinates() + b->atom2()->coordinates()) / 2.0f;
459  fvec3 direction = (b->atom2()->coordinates() - b->atom1()->coordinates()).normalize();
460  fmat4 mat = fmat4::getTranslation(center) * fmat4::getRotation(fvec3(0,1,0), direction);
461  bond_act->transform()->setLocalMatrix( (mat4)mat );
462  actorTree()->actors()->push_back( bond_act.get() );
463 
464  // actor -> bond map
465  if (isActorToMoleculeMapEnabled())
466  mActorToBondMap.insert( std::pair< ref<Actor>, ref<Bond> >(bond_act, bond(ibond)) );
467  // bond -> actor map
468  if (isMoleculeToActorMapEnabled())
469  mBondToActorMap.insert( std::pair< ref<Bond>, ref<Actor> >(bond(ibond), bond_act) );
470  }
471  }
472 }
473 //-----------------------------------------------------------------------------
475 {
476  if (!cycles().empty())
477  {
478  ref<Geometry> geom = new Geometry;
479  ref<ArrayFloat3> points = new ArrayFloat3;
480  geom->setVertexArray(points.get());
481  ref<ArrayFloat4> colors = new ArrayFloat4;
482  geom->setColorArray(colors.get());
483  std::vector<fvec3> pt;
484  std::vector<fvec4> cols;
485  for(unsigned icycle=0; icycle<cycles().size(); ++icycle)
486  {
487  AABB aabb;
488  for(unsigned iatom=0; iatom<cycle(icycle).size(); ++iatom)
489  aabb += (vec3)cycle(icycle)[iatom]->coordinates();
490  fvec3 center = (fvec3)aabb.center();
491 
492  for(unsigned iatom=0; iatom<cycle(icycle).size(); ++iatom)
493  {
494  int iatom2 = (iatom+1) % cycle(icycle).size();
495  fvec3 v1 = cycle(icycle)[iatom ]->coordinates();
496  fvec3 v2 = cycle(icycle)[iatom2]->coordinates();
497  v1 += (center-v1).normalize() * ringOffset();
498  v2 += (center-v2).normalize() * ringOffset();
499  pt.push_back( v1 );
500  pt.push_back( v2 );
501  cols.push_back( aromaticRingColor() );
502  cols.push_back( aromaticRingColor() );
503  }
504  }
505  points->initFrom(pt);
506  colors->initFrom(cols);
507  geom->drawCalls().push_back(new DrawArrays(PT_LINES, 0, (int)points->size()));
508 
509  ref<Effect> fx = new Effect;
510  fx->shader()->enable(EN_DEPTH_TEST);
511 
512  actorTree()->actors()->push_back( new Actor(geom.get(), fx.get(), NULL) );
513  }
514 }
515 //-----------------------------------------------------------------------------
Associates a Renderable object to an Effect and Transform.
Definition: Actor.hpp:130
bool visible() const
Definition: Bond.hpp:86
Material * gocMaterial()
Definition: Shader.cpp:119
const std::string & atomName() const
Definition: Atom.hpp:116
An array of vl::fvec4.
Definition: Array.hpp:416
Vector3< float > fvec3
A 3 components vector with float precision.
Definition: Vector3.hpp:252
LineWidth * gocLineWidth()
Definition: Shader.cpp:131
Transform * transform()
Returns the Transform bound tho an Actor.
Definition: Actor.hpp:190
Implements a 4x4 matrix transform used to define the position and orientation of an Actor...
Definition: Transform.hpp:72
void setShadowColor(const fvec4 &shadow_color)
Definition: Text.hpp:78
const T * get() const
Definition: Object.hpp:128
If enabled, do depth comparisons and update the depth buffer; Note that even if the depth buffer exis...
void prepareForRendering()
Generates the geometry representing the current molecule, atom and bond settings. ...
A Renderable that renders text with a given Font.
Definition: Text.hpp:50
void setLocalMatrix(const mat4 &m)
The matrix representing the transform&#39;s local space.
Definition: Transform.hpp:139
bool showAtomName() const
Defines whether the atom name should be rendered or not. See also Molecule::setShowAtomNames().
Definition: Atom.hpp:127
If enabled, use the current lighting parameters to compute the vertex color; Otherwise, simply associate the current color with each vertex, see also Material, LightModel, and Light.
void setText(const String &text)
Definition: Text.hpp:63
If enabled, blend the incoming RGBA color values with the values in the color buffers, see also BlendFunc for more information.
void setVertexArray(ArrayAbstract *data)
Conventional vertex array.
Definition: Geometry.cpp:155
vec3 center() const
Returns the center of the AABB.
Definition: AABB.cpp:184
void setFont(Font *font)
Definition: Text.hpp:88
bool useAtomColors() const
Definition: Bond.hpp:92
void setBorderEnabled(bool border)
Definition: Text.hpp:112
void generateAtomLabel(const Atom *atom, Transform *tr)
void setColorArray(const fvec4 &color)
Fills the color array with the given color.
Definition: Geometry.hpp:108
Atom * atom2() const
Definition: Bond.hpp:83
Atom * atom1() const
Definition: Bond.hpp:80
bool visible() const
Definition: Atom.hpp:121
const fvec3 & coordinates() const
Definition: Atom.hpp:106
size_t size() const
Returns the number of elements of an array.
Definition: Array.hpp:235
The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.
Definition: Geometry.hpp:66
Visualization Library main namespace.
void setMode(ETextMode mode)
Definition: Text.hpp:103
void set(float linewidth)
Definition: Shader.hpp:1097
void setDiffuse(const fvec4 &color)
Definition: Shader.hpp:794
void setRenderState(RenderStateNonIndexed *renderstate)
Definition: Shader.hpp:2172
void setKerningEnabled(bool kerning)
Definition: Text.hpp:118
void setBackgroundColor(const fvec4 &background_color)
Definition: Text.hpp:75
void setOutlineColor(const fvec4 &outline_color)
Definition: Text.hpp:72
The AABB class implements an axis-aligned bounding box using vl::real precision.
Definition: AABB.hpp:44
void initFrom(const std::vector< T_VectorType > &vector)
Definition: Array.hpp:395
void setShadowVector(const fvec2 &shadow_vector)
Definition: Text.hpp:81
If enabled, draw lines with correct filtering; Otherwise, draw aliased lines, see also LineWidth...
VLGRAPHICS_EXPORT ref< Geometry > makeCapsule(float radius, float height, int segments, ECapsuleCap top_cap, ECapsuleCap bottom_cap, const fvec4 &top_col, const fvec4 &bottom_col)
Creates a 3d capsule with rounded, flat or no caps.
void computeNormals(bool verbose=false)
Computes the normals in a "smooth" way, i.e.
Definition: Geometry.cpp:269
LightModel * gocLightModel()
Definition: Shader.cpp:121
#define NULL
Definition: OpenGLDefs.hpp:81
Shader * shader(int lodi=0, int pass=0)
Utility function, same as &#39;lod(lodi)->at(pass);&#39;.
Definition: Effect.hpp:178
const fvec4 & color() const
Definition: Atom.hpp:118
Defines the sequence of Shader objects used to render an Actor.
Definition: Effect.hpp:91
static Matrix4 & getRotation(Matrix4 &out, float degrees, float x, float y, float z)
Definition: Matrix4.hpp:904
void setColor(const fvec4 &color)
Definition: Text.hpp:66
fvec3 vec3
Defined as: &#39;typedef fvec3 vec3&#39;. See also VL_PIPELINE_PRECISION.
Definition: Vector3.hpp:269
VLGRAPHICS_EXPORT ref< Geometry > makeIcosphere(const vec3 &pos, real diameter=1, int detail=2, bool remove_doubles=true)
Creates a sphere by iteratively subdividing an icosahedron.
void setShadowEnabled(bool shadow)
Definition: Text.hpp:124
void setMargin(int margin)
Definition: Text.hpp:84
void setColorMaterialEnabled(bool enabled)
Definition: Shader.hpp:828
static Matrix4 & getTranslation(Matrix4 &out, const Vector3< float > &v)
Definition: Matrix4.hpp:548
bool operator==(const ref< T1 > &o1, const ref< T2 > &o2)
Definition: Object.hpp:144
Wraps the OpenGL function glLight().
Definition: Light.hpp:51
The Bond class represents a bond to be used with the Molecule class.
Definition: Bond.hpp:62
void setViewportAlignment(int align)
Definition: Text.hpp:97
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
T length(T v)
Definition: glsl_math.hpp:1084
An array of vl::fvec3.
Definition: Array.hpp:414
The Atom class represents an atom to be used with the Molecule class.
Definition: Atom.hpp:51
void setBorderColor(const fvec4 &border_color)
Definition: Text.hpp:69
Wraps the OpenGL function glDrawArrays().
Definition: DrawArrays.hpp:57
const fvec4 & color() const
Definition: Bond.hpp:89
void setAlignment(int align)
Definition: Text.hpp:94
void setTwoSide(bool twoside)
Definition: Shader.hpp:875
#define VL_CHECK(expr)
Definition: checks.hpp:73
void enable(EEnable capability)
Definition: Shader.hpp:2158
void setBackgroundEnabled(bool background)
Definition: Text.hpp:115
T normalize(T)
Definition: glsl_math.hpp:1128
Collection< DrawCall > & drawCalls()
Returns the list of DrawCall objects bound to a Geometry.
Definition: Geometry.hpp:102
If enabled, cull polygons based on their winding in window coordinates, see also CullFace.
void setTextAlignment(ETextAlign align)
Definition: Text.hpp:109
void setOutlineEnabled(bool outline)
Definition: Text.hpp:121
float radius() const
Definition: Bond.hpp:94