1 #ifndef _WALL_MOVEMENT_H
2 #define _WALL_MOVEMENT_H
15 ReaderWriter::getStringValue(
name, pParametersNode,
"Name");
17 name =
"WallMovement";
23 virtual void update(osgUtil::LineSegmentIntersector::Intersection* intersection,
WG_Wall* curWall,
WG_Point* curPoint,
PointType type,
vrecko::EnvironmentObject* pEOOwner, std::vector<osg::ref_ptr<WG_Wall> >* walls, std::vector<osg::ref_ptr<WG_Point> >* points, osg::Geode* pOSGGeode, osg::Vec3Array* pOSGVertexArray, osg::Vec3& movingVector) {
25 if (curWall != NULL) {
27 float scalar = wallNormal.x() * movingVector.x() + wallNormal.y() * movingVector.z();
28 wallNormal.normalize();
38 for (
unsigned int i=0; i<walls->size(); i++) {
39 WG_Wall* wallI = walls->at(i).get();
43 for (
unsigned int j=0; j<Q->
getWalls()->size(); j++) {
44 skipQ = (wallI == Q->
getWalls()->at(j).first.get());
48 for (
unsigned int j=0; j<R->
getWalls()->size(); j++) {
49 skipR = (wallI == R->
getWalls()->at(j).first.get());
56 bool b1 = WG_Geometry::barycentricTest(posQ,
60 bool b2 = WG_Geometry::barycentricTest(posQ,
68 bool b3 = WG_Geometry::barycentricTest(posR,
72 bool b4 = WG_Geometry::barycentricTest(posR,
83 for (
unsigned int k=0; k<Q->
getWalls()->size(); k++) {
92 float angleCW, angleCCW,
angle, angleCompare, angleMin;
94 std::pair<osg::ref_ptr<WG_Wall>,
PointType> wallCW;
95 std::pair<osg::ref_ptr<WG_Wall>,
PointType> wallCCW;
97 angleCW = wallCW.first->getAngle(wallCW.second);
98 angleCCW = wallCCW.first->getAngle(wallCCW.second);
101 angleCompare = angleCCW -
angle;
103 wallCCW.first->getVector(
WG_Q_POINT).length());
104 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
106 angleCompare = angle - angleCW;
108 wallCW.first->getVector(
WG_Q_POINT).length());
109 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
114 angleCW = wallCW.first->getAngle(wallCW.second);
115 angleCCW = wallCCW.first->getAngle(wallCCW.second);
118 angleCompare = angleCCW -
angle;
120 wallCCW.first->getVector(
WG_Q_POINT).length());
121 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
123 angleCompare = angle - angleCW;
125 wallCW.first->getVector(
WG_Q_POINT).length());
126 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
132 for (
unsigned int k=0; k<R->
getWalls()->size(); k++) {
141 float angleCW, angleCCW,
angle, angleCompare, angleMin;
143 std::pair<osg::ref_ptr<WG_Wall>,
PointType> wallCW;
144 std::pair<osg::ref_ptr<WG_Wall>,
PointType> wallCCW;
146 angleCW = wallCW.first->getAngle(wallCW.second);
147 angleCCW = wallCCW.first->getAngle(wallCCW.second);
150 angleCompare = angleCCW -
angle;
152 wallCCW.first->getVector(
WG_Q_POINT).length());
153 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
155 angleCompare = angle - angleCW;
157 wallCW.first->getVector(
WG_Q_POINT).length());
158 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
163 angleCW = wallCW.first->getAngle(wallCW.second);
164 angleCCW = wallCCW.first->getAngle(wallCCW.second);
167 angleCompare = angleCCW -
angle;
169 wallCCW.first->getVector(
WG_Q_POINT).length());
170 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
172 angleCompare = angle - angleCW;
174 wallCW.first->getVector(
WG_Q_POINT).length());
175 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
183 for (
unsigned int l=0; l<Q->
getWalls()->size(); l++) {
191 for (
unsigned int l=0; l<R->
getWalls()->size(); l++) {