KrisLibrary  1.0.0
GeometryAppearance.h
1 #ifndef GLDRAW_GEOMETRY_APPEARANCE_H
2 #define GLDRAW_GEOMETRY_APPEARANCE_H
3 
5 #include <KrisLibrary/meshing/TriMesh.h>
6 #include "GLColor.h"
7 #include "GLTextureObject.h"
8 #include "GLDisplayList.h"
9 #include <KrisLibrary/image/image.h>
10 #include <memory>
11 
12 namespace Geometry {
13  //forward declaration
14  class AnyGeometry3D;
15  class AnyCollisionGeometry3D;
16 }// namespace Geometry
17 //forward declaration
18 class Image;
19 
20 namespace GLDraw {
21 
22 void draw(const Geometry::AnyGeometry3D& geom);
23 void drawPoints(const Geometry::AnyGeometry3D& geom);
24 void drawFaces(const Geometry::AnyGeometry3D& geom);
25 
32 
34 void drawExpanded(Geometry::AnyCollisionGeometry3D& geom,Math::Real p=-1);
35 
54 {
55  public:
56  enum Element { ALL, VERTICES, EDGES, FACES, SILHOUETTE, ALL_TRANSPARENT, ALL_OPAQUE };
57 
60  void CopyMaterial(const GeometryAppearance& rhs);
65  void CopyCache(const GeometryAppearance& rhs,bool if_cache_exists=false);
66  void Set(const Geometry::AnyGeometry3D& geom);
67  void Set(const Geometry::AnyCollisionGeometry3D& geom);
70  void Refresh();
72  void DrawGL(Element e=ALL);
75  void SetColor(float r,float g, float b, float a);
76  void SetColor(const GLColor& color);
79  void ModulateColor(const GLColor& color,float fraction);
80 
84  std::vector<GeometryAppearance> subAppearances;
85 
86  bool drawVertices,drawEdges,drawFaces;
87  float vertexSize,edgeSize;
89  bool lightFaces;
91  GLColor vertexColor,edgeColor,faceColor;
93  std::vector<GLColor> vertexColors,faceColors;
95  std::shared_ptr<Image> tex1D,tex2D;
97  bool texWrap;
99  std::vector<Math3D::Vector2> texcoords;
103  std::vector<Math3D::Vector4> texgen;
106  float creaseAngle;
109  GLColor silhouetteColor;
110 
112  std::shared_ptr<Meshing::TriMesh> tempMesh,tempMesh2;
114  GLDisplayList vertexDisplayList,edgeDisplayList,faceDisplayList,silhouetteDisplayList;
115  GLTextureObject textureObject;
116 };
117 
118 } //namespace GLDraw
119 
120 #endif
void drawWorld(const Geometry::AnyCollisionGeometry3D &geom)
draw the collision geometry in its world coordinates
Definition: GeometryAppearance.cpp:155
Definition: GLDisplayList.h:8
std::vector< GLColor > vertexColors
Optional: per-element colors.
Definition: GeometryAppearance.h:93
std::vector< Math3D::Vector2 > texcoords
Optional: per-element texture mapping coordinates (up to 2D)
Definition: GeometryAppearance.h:99
A class for coloring, texturing, and drawing meshes in OpenGL.
Definition: GeometryAppearance.h:53
std::vector< Math3D::Vector4 > texgen
Definition: GeometryAppearance.h:103
bool lightFaces
Use lighting or not (with lighting, will always do ambient and diffuse)
Definition: GeometryAppearance.h:89
GLDisplayList vertexDisplayList
Temporary: The display lists and texture lists for vertices, edges, faces, and silhouette.
Definition: GeometryAppearance.h:114
std::vector< GeometryAppearance > subAppearances
For group geometries.
Definition: GeometryAppearance.h:84
std::shared_ptr< Meshing::TriMesh > tempMesh
Temporary: Mesh computed for implicit surfaces, point clouds, silhouettes.
Definition: GeometryAppearance.h:112
Class declarations for useful 3D math types.
An AnyGeometry with collision detection information.
Definition: AnyGeometry.h:112
GLColor vertexColor
Global color.
Definition: GeometryAppearance.h:91
void drawFacesWorld(const Geometry::AnyCollisionGeometry3D &geom)
draw the collision geometry&#39;s faces in its world coordinates
Definition: GeometryAppearance.cpp:171
bool texWrap
If true, the texture will wrap. Default false.
Definition: GeometryAppearance.h:97
float silhouetteRadius
Optional: draw meshes with a silhouette outline (default 0)
Definition: GeometryAppearance.h:108
void drawExpanded(Geometry::AnyCollisionGeometry3D &geom, Real p)
draw the expansion of the collision geometry, in its local coordinates
Definition: GeometryAppearance.cpp:179
Contains all definitions in the GLDraw package.
Definition: AnyGeometry.h:14
A class that stores any kind of geometry we&#39;ve defined.
Definition: AnyGeometry.h:37
void drawPointsWorld(const Geometry::AnyCollisionGeometry3D &geom)
draw the collision geometry&#39;s points in its world coordinates
Definition: GeometryAppearance.cpp:163
const Geometry::AnyGeometry3D * geom
Geometry pointer.
Definition: GeometryAppearance.h:82
An rgba color.
Definition: GLColor.h:9
float creaseAngle
Definition: GeometryAppearance.h:106
Definition: image.h:6
std::shared_ptr< Image > tex1D
Optional: set to non-null if you want to texture the object.
Definition: GeometryAppearance.h:95
Contains all definitions in the Geometry package.
Definition: AnyGeometry.cpp:26
A GL texture object class. Simplifies allocating and cleaning up texture objects. Usually you only ne...
Definition: GLTextureObject.h:13