My Project
Loading...
Searching...
No Matches
CMultiPoint.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \version 3.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CMultiPointH
46#define CMultiPointH
47//------------------------------------------------------------------------------
49#include "materials/CMaterial.h"
51#include "graphics/CColor.h"
52//------------------------------------------------------------------------------
53#include <vector>
54#include <list>
55//------------------------------------------------------------------------------
56
57//------------------------------------------------------------------------------
58namespace chai3d {
59//------------------------------------------------------------------------------
60
61//------------------------------------------------------------------------------
62class cWorld;
63//------------------------------------------------------------------------------
64
65//==============================================================================
72//==============================================================================
73
74//------------------------------------------------------------------------------
76class cVertexArray;
77typedef std::shared_ptr<cVertexArray> cVertexArrayPtr;
78
80class cPointArray;
81typedef std::shared_ptr<cPointArray> cPointArrayPtr;
82//------------------------------------------------------------------------------
83
84//==============================================================================
95//==============================================================================
97{
98 //--------------------------------------------------------------------------
99 // CONSTRUCTOR & DESTRUCTOR:
100 //--------------------------------------------------------------------------
101
102public:
103
105 cMultiPoint();
106
108 virtual ~cMultiPoint();
109
110
111 //--------------------------------------------------------------------------
112 // PUBLIC METHODS - GENERAL
113 //--------------------------------------------------------------------------
114
115public:
116
118 virtual std::string getClassName() { return ("MultiPoint"); }
119
121 virtual cMultiPoint* copy(const bool a_duplicateMaterialData = false,
122 const bool a_duplicateTextureData = false,
123 const bool a_duplicateMeshData = false,
124 const bool a_buildCollisionDetector = false);
125
126
127 //--------------------------------------------------------------------------
128 // PUBLIC METHODS - VERTICES
129 //--------------------------------------------------------------------------
130
131public:
132
134 unsigned int newVertex(const double a_x = 0.0,
135 const double a_y = 0.0,
136 const double a_z = 0.0);
137
139 unsigned int newVertex(const cVector3d& a_pos,
140 const cColorf& a_color = cColorf(0,0,0,1));
141
143 inline unsigned int getNumVertices() const { return (unsigned int)(m_vertices->getNumElements()); }
144
145
146 //--------------------------------------------------------------------------
147 // PUBLIC METHODS - POINTS
148 //--------------------------------------------------------------------------
149
150public:
151
153 unsigned int newPoint(const unsigned int a_indexVertex0);
154
156 unsigned int newPoint(const cVector3d& a_vertex0 = cVector3d(0,0,0),
157 const cColorf& a_colorVertex0 = cColorf(0,0,0,1));
158
160 bool removePoint(const unsigned int a_index);
161
163 unsigned int getNumPoints();
164
166 void clear();
167
168
169 //-----------------------------------------------------------------------
170 // PUBLIC METHODS - GRAPHIC PROPERTIES:
171 //-----------------------------------------------------------------------
172
173public:
174
176 virtual void setTransparencyLevel(const float a_level,
177 const bool a_applyToVertices = false,
178 const bool a_applyToTextures = false,
179 const bool a_affectChildren = false,
180 const bool a_affectComponents = true);
181
182
183 //-----------------------------------------------------------------------
184 // PUBLIC METHODS - DISPLAY LISTS:
185 //-----------------------------------------------------------------------
186
187public:
188
190 virtual void markForUpdate(const bool a_affectChildren = false, const bool a_affectComponents = true);
191
192
193 //--------------------------------------------------------------------------
194 // PUBLIC METHODS - POINTS GRAPHIC PROPERTIES
195 //--------------------------------------------------------------------------
196
197public:
198
200 void setPointColor(const cColorf& a_color);
201
203 inline void setPointSize(const double a_pointSize) { m_pointSize = fabs(a_pointSize); }
204
206 inline double getPointSize() const { return (m_pointSize); }
207
208
209 //--------------------------------------------------------------------------
210 // PUBLIC METHODS - COLLISION DETECTION:
211 //--------------------------------------------------------------------------
212
213public:
214
217
219 virtual void createAABBCollisionDetector(const double a_radius);
220
221
222 //--------------------------------------------------------------------------
223 // PUBLIC VIRTUAL METHODS - FILES:
224 //--------------------------------------------------------------------------
225
226public:
227
229 virtual bool loadFromFile(std::string a_filename);
230
232 virtual bool saveToFile(std::string a_filename);
233
234
235 //--------------------------------------------------------------------------
236 // PUBLIC METHODS - GEOMETRY:
237 //--------------------------------------------------------------------------
238
239public:
240
242 void scaleXYZ(const double a_scaleX, const double a_scaleY, const double a_scaleZ);
243
245 virtual void offsetVertices(const cVector3d& a_offset,
246 const bool a_updateCollisionDetector = true);
247
249 virtual cVector3d getCenterOfMass();
250
251
252 //--------------------------------------------------------------------------
253 // PROTECTED METHODS - INTERNAL
254 //--------------------------------------------------------------------------
255
256protected:
257
259 virtual void render(cRenderOptions& a_options);
260
262 virtual void renderPoints(cRenderOptions& a_options);
263
265 virtual void updateGlobalPositions(const bool a_frameOnly);
266
268 virtual void updateBoundaryBox();
269
272 const bool a_duplicateMaterialData = false,
273 const bool a_duplicateTextureData = false,
274 const bool a_duplicateMeshData = false,
275 const bool a_buildCollisionDetector = false);
276
278 virtual void scaleObject(const double& a_scaleFactor) { scaleXYZ(a_scaleFactor, a_scaleFactor, a_scaleFactor); }
279
280
281 //--------------------------------------------------------------------------
282 // PROTECTED MEMBERS - DISPLAY PROPERTIES:
283 //--------------------------------------------------------------------------
284
285protected:
286
289
292
293
294 //--------------------------------------------------------------------------
295 // PUBLIC MEMBERS - POINT AND VERTEX DATA:
296 //--------------------------------------------------------------------------
297
298public:
299
302
305};
306
307//------------------------------------------------------------------------------
308} // namespace chai3d
309//------------------------------------------------------------------------------
310
311//------------------------------------------------------------------------------
312#endif
313//------------------------------------------------------------------------------
Implements color properties.
Implements a base class for all objects.
Implements material properties.
Implements 2D textures.
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition CGenericObject.h:113
This class implements 3D point cloud object.
Definition CMultiPoint.h:97
unsigned int getNumPoints()
This method returns the number of stored points.
Definition CMultiPoint.cpp:238
virtual void renderPoints(cRenderOptions &a_options)
This method renders all points.
Definition CMultiPoint.cpp:773
void setPointSize(const double a_pointSize)
This method sets the point size that is used to graphically render the points.
Definition CMultiPoint.h:203
cMultiPoint()
Constructor of cMultiPoint.
Definition CMultiPoint.cpp:71
void copyMultiPointProperties(cMultiPoint *a_obj, const bool a_duplicateMaterialData=false, const bool a_duplicateTextureData=false, const bool a_duplicateMeshData=false, const bool a_buildCollisionDetector=false)
This method copies all properties of this point cloud to another.
Definition CMultiPoint.cpp:151
void scaleXYZ(const double a_scaleX, const double a_scaleY, const double a_scaleZ)
This method scales this point cloud by using different scale factors along X, Y and Z axes.
Definition CMultiPoint.cpp:389
unsigned int getNumVertices() const
This method returns the number of stored vertices.
Definition CMultiPoint.h:143
virtual std::string getClassName()
This method returns the name of the object class.
Definition CMultiPoint.h:118
virtual void createBruteForceCollisionDetector()
This method builds a brute force collision detector for this mesh.
Definition CMultiPoint.cpp:591
unsigned int newVertex(const double a_x=0.0, const double a_y=0.0, const double a_z=0.0)
This method creates a new vertex and adds it to the vertex list.
Definition CMultiPoint.cpp:255
virtual bool loadFromFile(std::string a_filename)
This method loads a 3D point cloud from a file.
Definition CMultiPoint.cpp:640
void setPointColor(const cColorf &a_color)
This method sets a color for all points.
Definition CMultiPoint.cpp:485
double m_pointSize
Display size of point.
Definition CMultiPoint.h:291
virtual void createAABBCollisionDetector(const double a_radius)
This method builds an AABB collision detector for this mesh.
Definition CMultiPoint.cpp:612
virtual bool saveToFile(std::string a_filename)
This method saves a 3D point cloud to a file.
Definition CMultiPoint.cpp:697
virtual cVector3d getCenterOfMass()
This method computes the center of mass of this point cloud, based on vertex positions.
Definition CMultiPoint.cpp:212
bool m_showPoints
If true, then segments are displayed.
Definition CMultiPoint.h:288
cPointArrayPtr m_points
Array of points.
Definition CMultiPoint.h:304
virtual void offsetVertices(const cVector3d &a_offset, const bool a_updateCollisionDetector=true)
This method shifts all vertex positions by the specified amount.
Definition CMultiPoint.cpp:505
virtual cMultiPoint * copy(const bool a_duplicateMaterialData=false, const bool a_duplicateTextureData=false, const bool a_duplicateMeshData=false, const bool a_buildCollisionDetector=false)
This method creates a copy of itself.
Definition CMultiPoint.cpp:120
virtual void updateGlobalPositions(const bool a_frameOnly)
This method updates the global position of each vertex.
Definition CMultiPoint.cpp:410
virtual ~cMultiPoint()
Destructor of cMultiPoint.
Definition CMultiPoint.cpp:101
void clear()
This method clears all points and vertices.
Definition CMultiPoint.cpp:369
virtual void updateBoundaryBox()
This method updates the boundary box dimensions based on the vertices.
Definition CMultiPoint.cpp:534
virtual void markForUpdate(const bool a_affectChildren=false, const bool a_affectComponents=true)
This method invalidates any existing display lists and marks the mesh for update.
Definition CMultiPoint.cpp:433
cVertexArrayPtr m_vertices
Array of vertices.
Definition CMultiPoint.h:301
virtual void render(cRenderOptions &a_options)
This method renders this object graphically using OpenGL.
Definition CMultiPoint.cpp:740
double getPointSize() const
This method returns the point size.
Definition CMultiPoint.h:206
bool removePoint(const unsigned int a_index)
This method removed a selected point.
Definition CMultiPoint.cpp:352
unsigned int newPoint(const unsigned int a_indexVertex0)
This method creates a new point by passing a vertex index.
Definition CMultiPoint.cpp:302
virtual void setTransparencyLevel(const float a_level, const bool a_applyToVertices=false, const bool a_applyToTextures=false, const bool a_affectChildren=false, const bool a_affectComponents=true)
This method sets the alpha value at each vertex and in all of my material colors.
Definition CMultiPoint.cpp:455
virtual void scaleObject(const double &a_scaleFactor)
This method scales this object by a scale factor.
Definition CMultiPoint.h:278
Definition CAudioBuffer.cpp:57
std::shared_ptr< cPointArray > cPointArrayPtr
Definition CPointArray.h:72
std::shared_ptr< cVertexArray > cVertexArrayPtr
Definition CVertexArray.h:108
This class defines a color using a GLfloat representation for each component.
Definition CColor.h:139
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition CRenderOptions.h:83
This class implements a 3D vector.
Definition CVector3d.h:89