17 std::string mode =
"";
19 ReaderWriter::getStringValue(mode, pParametersNode,
"Mode");
22 simple = (mode ==
"simple");
26 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) {
27 if (simple && (curWall != NULL) && (curPoint->
getWalls()->size()>1)) {
35 osg::Vec2 tempVector = curWall->
getVector(Type);
37 movingPoint = curPoint;
40 tempVector.normalize();
43 curWall->
setPoint(movingPoint, Type);
44 movingPoint->
setId(points->size());
45 points->push_back(movingPoint);
49 movingPoint = curPoint;
54 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) {
55 osg::Vec2 tempPosition = movingPoint->
getPosition() + osg::Vec2(movingVector.x(), movingVector.z());
58 osg::Vec2 vector, position;
59 osg::Vec2 curVec, minVec = osg::Vec2(10000.0, 10000.0);
61 bool oneWall = (movingPoint->
getWalls()->size()==1);
64 wall = movingPoint->
getWalls()->at(0).first.get();
65 if (wall->getPoint(
WG_Q_POINT) == movingPoint) {
66 position = wall->getPoint(
WG_R_POINT)->getPosition();
70 position = wall->getPoint(
WG_Q_POINT)->getPosition();
73 vector.set(-vector.y(), vector.x());
77 for (
unsigned int i=0; i<walls->size(); i++) {
78 WG_Wall* wallI = walls->at(i).get();
84 tvector.set(-tvector.y(), tvector.x());
87 if (WG_Geometry::getCrossingPoint(crossPoint, position, vector, tposition, tvector,
true)) {
88 curVec = position - crossPoint;
89 if (curVec.length() < minVec.length()) {
95 if (resWall != NULL) {
96 tempPosition = (minVec - position)*(-1);
102 for (
unsigned int j=0; j<movingPoint->
getWalls()->size(); j++) {
103 skip = (wallI == movingPoint->
getWalls()->at(j).first.get());
110 bool b1 = WG_Geometry::barycentricTest(tempPosition,
114 bool b2 = WG_Geometry::barycentricTest(tempPosition,
125 for (
unsigned int k=0; k<movingPoint->
getWalls()->size(); k++) {
134 float angleCW, angleCCW,
angle, angleCompare, angleMin;
136 std::pair<osg::ref_ptr<WG_Wall>,
PointType> wallCW;
137 std::pair<osg::ref_ptr<WG_Wall>,
PointType> wallCCW;
139 angleCW = wallCW.first->getAngle(wallCW.second);
140 angleCCW = wallCCW.first->getAngle(wallCCW.second);
143 angleCompare = angleCCW -
angle;
145 wallCCW.first->getVector(
WG_Q_POINT).length());
146 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
148 angleCompare = angle - angleCW;
150 wallCW.first->getVector(
WG_Q_POINT).length());
151 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
156 angleCW = wallCW.first->getAngle(wallCW.second);
157 angleCCW = wallCCW.first->getAngle(wallCCW.second);
160 angleCompare = angleCCW -
angle;
162 wallCCW.first->getVector(
WG_Q_POINT).length());
163 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
165 angleCompare = angle - angleCW;
167 wallCW.first->getVector(
WG_Q_POINT).length());
168 if ((angleCompare < angleMin) && (angleCompare > - angleMin))
176 for (
unsigned int l=0; l<movingPoint->
getWalls()->size(); l++) {
187 virtual void terminate(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) {
190 if (movingPoint->
getWalls()->size()==1) {
205 for (
unsigned int i=0; i<walls->size(); i++) {
206 WG_Wall* wallI = walls->at(i).get();
209 bool b1 = WG_Geometry::barycentricTest(movingPoint->
getPosition(),
213 bool b2 = WG_Geometry::barycentricTest(movingPoint->
getPosition(),
218 if (wallI != mpWall) {
225 if (crossedWall != NULL) {
231 osg::Vec2 crossPoint;
234 osg::Vec2 qNormal = osg::Vec2(-resQvector.y(), resQvector.x());
236 if (WG_Geometry::getCrossingPoint(crossPoint, movingPoint->
getPosition(), mpNormal, resQ->
getPosition(), qNormal,
false)) {
237 osg::Vec2 resQvec = resQ->
getPosition() - crossPoint;
238 osg::Vec2 resRvec = resR->
getPosition() - crossPoint;
239 if (resQvec.length() < resRvec.length()) {
245 newWall =
new WG_Wall(resR, movingPoint);
246 newWall->
setId(walls->size());
247 walls->push_back(newWall);
257 newWall =
new WG_Wall(resR, movingPoint);
258 newWall->
setId(walls->size());
259 walls->push_back(newWall);