17 ReaderWriter::getStringValue(
name, pParametersNode,
"Name");
25 virtual void init(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) {
30 if (curWall != NULL) {
31 bool splitted =
false;
34 osg::Vec2 iPoint = osg::Vec2(intersection->getLocalIntersectPoint().x(), intersection->getLocalIntersectPoint().z());
51 if (qVec.length() < rVec.length()) {
66 osg::Vec2 dummy, normalI, mpNormal;
70 mpNormal = osg::Vec2(-mpVector.y(), mpVector.x());
72 for (
unsigned int i=0; i<walls->size(); i++) {
73 normalI = osg::Vec2(-walls->at(i)->getVector(
WG_Q_POINT).y(),walls->at(i)->getVector(
WG_Q_POINT).x());
74 if (WG_Geometry::getCrossingPoint(dummy,crossPoint, mpNormal, walls->at(i)->getPoint(
WG_Q_POINT)->getPosition(), normalI,
true)) {
81 logger.
warningLog(
"Cannot add wall. Not enough space for a new one. (A wall obstructs.)");
85 startingPoint =
new WG_Point(crossPoint);
86 startingPoint->
setId(points->size());
87 points->push_back(startingPoint);
89 newWall =
new WG_Wall(startingPoint, R);
90 newWall->
setId(walls->size());
91 walls->push_back(newWall);
95 if (startingPoint->
getWalls()->size() > 1) {
96 std::pair<osg::ref_ptr<WG_Wall>,
PointType> wallCW;
97 std::pair<osg::ref_ptr<WG_Wall>,
PointType> wallCCW;
102 osg::Vec2 vector(0.0,0.0);
104 osg::Vec2 vec1, vec2;
105 if (((type ==
WG_Q_POINT) && (Q == startingPoint))
106 || ((type ==
WG_R_POINT) && (R == startingPoint))) {
107 vec1 = wallCCW.first->getVector(wallCCW.second);
111 mpVector = vec1 + vec2;
113 angle = wallCCW.first->getAngle(wallCCW.second);
117 vec1 = wallCW.first->getVector(wallCW.second);
121 mpVector = vec1 + vec2;
122 angle2 = wallCW.first->getAngle(wallCW.second);
124 vector = wallCW.first->getVector(wallCW.second);
128 float angleCompare = angle - angle2;
129 if (angleCompare < 0)
131 if (angleCompare > 180.0f)
134 mpVector.normalize();
138 angleCompare = angle - mpAngle;
139 if (angleCompare < 0)
141 if ((!splitted) && (angleCompare <
RE_MIN_ANGLE(mpVector.length(), vector.length()))) {
142 logger.
warningLog(
"Cannot add wall. Not enough space for a new one. (Too small angle.)");
146 movingPoint->
setId(points->size());
147 points->push_back(movingPoint);
148 newWall =
new WG_Wall(startingPoint, movingPoint);
149 newWall->
setId(walls->size());
150 walls->push_back(newWall);
154 mpVector = osg::Vec2(intersection->getLocalIntersectNormal().x(), intersection->getLocalIntersectNormal().z());
155 mpVector.normalize();
158 movingPoint->
setId(points->size());
159 points->push_back(movingPoint);
160 newWall =
new WG_Wall(startingPoint, movingPoint);
161 newWall->
setId(walls->size());
162 walls->push_back(newWall);