vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
functions.h
Go to the documentation of this file.
1 #ifndef FUNCTIONS_H
2 #define FUNCTIONS_H
3 
4 //#include <vrecko/EnvironmentObject.h>
5 //#include <vrecko/PluginManager.h>
7 //#include <osgDB/ReadFile>
8 #include <osg/Geometry>
9 
10 using namespace osg;
11 using namespace vrecko;
12 
13 
15 //GET DATA OF ENVIRONMENT OBJECT
16 
17 //*******************
18 //get geode of node graf
19 osg::Geode* getGeodeOf(osg::Node *eo);
20 
21 //*******************
22 //get geometry of node graf
23 osg::Geometry* getGeometryOf(osg::Node *eo);
24 
25 //*******************
26 //get vertices
27 osg::Vec3Array* getVerticesOf(osg::Node *eo);
28 
29 //*******************
30 //get normals
31 osg::Vec3Array* getNormalsOf(osg::Node *eo);
32 
33 //*******************
34 //get faces
35 DrawElementsUShort* getFacesOf(osg::Node *eo);
36 
37 
38 
39 
40 
42 //PRINT MESSAGES
43 
44 //print message and time
45 void printMessageTime(string str, float time);
46 
47 //print text message only
48 void printMessage(string str);
49 
50 //print text message and number
51 void printMessage(string str, float number);
52 
53 //print error text message only
54 void printErrorMessage(string str);
55 
56 
57 
58 
59 
61 //ADD OBJECT TO SCENE
62 //to show some object like cut or debugging
63 
64 //add lines into scene
65 bool addLinesToScene(map<int, int> lines, Vec3Array *sourceVertices, Vec3Array *targetVertices, EnvironmentObject *eoParent);
66 
67 //add lines to scene
68 bool addLinesToScene(vector<int> lines, Vec3Array *vertices, EnvironmentObject *eoParent, int color, std::string name);
69 
70 //add lines to environment object
71 bool addLinesToEo(vector<int> lines, Vec3Array *vertices, EnvironmentObject *eo, int color, std::string name);
72 
73 //add object created from specified points of given object
74 bool addMeshToScene(vector<int> boundaryLoop, EnvironmentObject *eoLoop);
75 bool addMeshToScene(vector<int> boundaryLoop, EnvironmentObject *eoLoop, int color);
76 bool addMeshToScene(vector<int> boundaryLoop, Vec3Array *vertices, EnvironmentObject *parent);
77 bool addMeshToScene(vector<int> boundaryLoop, Vec3Array *vertices, EnvironmentObject *parent, int color);
78 bool addMeshToScene(vector<int> boundaryLoop, Vec3Array *vertices, EnvironmentObject *parent, int color, std::string name);
79 
80 //add object to scene created from given points
81 bool addVerticesToScene(osg::Vec3Array* vertices, Group *parent);
82 
83 //bool addPointToScene(osg::Vec3 point, EnvironmentObject *parentEnvironmentObject);
84 bool addPointToScene(osg::Vec3 point, osg::Group *parentEnvironmentObject);
85 
86 //the same functiuon but rotation 90 added
87 bool addPointToScene90(osg::Vec3 point, osg::Group *parentEnvironmentObject);
88 
89 
90 
91 
92 
93 
95 //MATRIX, QUATERNION AND OTHER MATH FUNCTIONS
96 
97 //udela trace(stopu) od matice
98 float matrixTrace3x3(float matrix[3][3]);
99 
100 //we get matrix of rotation from 4 koeficients of quaternion of rotaion
101 bool getMatrixOfRotation(float q[7], float R[4][4]);
102 
103 //we get matrix of rotation from 4 koeficients of quaternion of rotaion - to osg::Matrix
104 bool getMatrixOfRotation(float q[7], osg::Matrix &m);
105 
106 //transpose matrix of size 4x4
107 void matrixTranspose4x4(float m[4][4], float mt[4][4]);
108 
109 //Normalize quaternion
110 void quaternionNormalize(float q[7], float qNormalized[7]);
111 
112 //Length of quaternion - used for normalizing quaternion
113 float quaternionLength(float q[7]);
114 
115 //get matrix of source and target object and combine them to apply on target/source object to get same position in case of merge (matrix is id)
116 bool getMergeMatrix(EnvironmentObject *targetEo, EnvironmentObject *sourceEo, osg::Matrix& matrix);
117 
118 
119 
120 
121 
122 
123 
125 //DISTANCE AND CLOSEST POINT
126 
127 //find out closest point to given point on line
128 osg::Vec3 findClosestPointOnLine(osg::Vec3 point, osg::Vec3 pointA, osg::Vec3 pointB);
129 
130 //euclidean distance of point and face construct of triangles threre points abc
131 osg::Vec3 findClosestPointOnFace(osg::Vec3 point, osg::Vec3 pointA, osg::Vec3 pointB, osg::Vec3 pointC, bool &onFace);
132 
133 //euclidean distance of two points
134 float p2pEuclideanDistance(osg::Vec3 point1, osg::Vec3 point2);
135 
136 //find closest point - snapping region to snapping region
137 vector<int> findClosestPoint(vector<int> snappingRegion, Vec3Array *points, vector<int> browsingSnappingRegion, Vec3Array *browsingPoints);
138 vector<int> findClosestPointNorm(vector<int> boundarySnappingRegion, Vec3Array *boundaryPoints, Vec3Array *boundaryNormals, vector<int> browsingSnappingRegion, Vec3Array *browsingPoints, Vec3Array *browsingNormals);
139 
140 
141 
142 
143 
144 
146 //OTHER FUNCTIONS
147 
148 //find out if face is in faces
149 bool includeFace(unsigned long pointA, unsigned long pointB, unsigned long pointC, osg::DrawElementsUShort *vertices);
150 
151 //erase face from faces
152 bool eraseFace(unsigned long pointA, unsigned long pointB, unsigned long pointC, osg::DrawElementsUShort *faces);
153 
154 //get center of mass of given points
155 osg::Vec3 centerOfMass(osg::Vec3Array* points);
156 
157 //center of mass of given area of given points
158 osg::Vec3 centerOfMass(osg::Vec3Array* points, vector<int> area);
159 
160 //normals variance
161 float normalsVariance(osg::Vec3 n1, osg::Vec3 n2);
162 
163 
164 
165 #endif
166