@@ -71,7 +71,14 @@ int ElevatorPart::hit(vrui::vruiHit *hit)
7171 else if (buttons->wasReleased (vruiButtons::ACTION_BUTTON ))
7272 {
7373 // left Button was released
74- elevator->cabin ->goTo (levelNumber);
74+ if (buttonLanding)
75+ {
76+ elevator->cabin ->goTo (buttonLanding->levelNumber );
77+ }
78+ else
79+ {
80+ elevator->cabin ->goTo (levelNumber);
81+ }
7582 }
7683
7784 return vrui::coAction::Result::ACTION_DONE ;
@@ -216,7 +223,7 @@ bool ElevatorPart::update(osg::Vec3& viewerPosition)
216223 v = 0 ;
217224 }
218225 osg::Matrix newTrans = transformNode->getMatrix ();
219- newTrans.setTrans (initialTranslation + osg::Vec3 (0 , 0 , carPos));
226+ newTrans.setTrans (initialTranslation + osg::Vec3 (0 , 0 , carPos - heightOffset ));
220227 transformNode->setMatrix (newTrans);
221228 }
222229 else // we are there
@@ -251,7 +258,7 @@ bool ElevatorPart::update(osg::Vec3& viewerPosition)
251258 float doorPos = direction * doorFraction * openingDistance * (doorNumber+1 );
252259
253260 osg::Matrix newTrans = transformNode->getMatrix ();
254- newTrans.setTrans (initialTranslation + osg::Vec3 (doorPos, 0 , 0 ));
261+ newTrans.setTrans (initialTranslation + osg::Vec3 (doorPos, 0 , -heightOffset ));
255262 transformNode->setMatrix (newTrans);
256263 }
257264 else // we are there
@@ -280,7 +287,7 @@ bool ElevatorPart::update(osg::Vec3& viewerPosition)
280287 float doorPos = direction * doorFraction * openingDistance * (doorNumber + 1 );
281288
282289 osg::Matrix newTrans = transformNode->getMatrix ();
283- newTrans.setTrans (initialTranslation + osg::Vec3 (doorPos, 0 , 0 ));
290+ newTrans.setTrans (initialTranslation + osg::Vec3 (doorPos, 0 , -heightOffset ));
284291 transformNode->setMatrix (newTrans);
285292 }
286293 else // we are there
@@ -378,7 +385,7 @@ void Elevator::addPart(const std::string &familyName, const std::string &subType
378385 {
379386 ep->type = ElevatorPart::Cabin;
380387 cabin = ep;
381- cabin->destinationY = cabin->carPos = cabin->elevation ; // car is on this elevation
388+ cabin->destinationY = cabin->carPos = cabin->heightOffset = cabin-> elevation ; // car is on this elevation
382389
383390 int levelNumber = 0 ;
384391 for (const auto &landingPart : landings)
@@ -441,6 +448,12 @@ void Elevator::addPart(const std::string &familyName, const std::string &subType
441448 std::sort (landings.begin (), landings.end (),
442449 [](ElevatorPart *const &a, ElevatorPart *const &b)
443450 { return a->elevation < b->elevation ; });
451+ int levelNumber = 0 ;
452+ for (const auto &landingPart : landings)
453+ {
454+ landingPart->levelNumber = levelNumber;
455+ levelNumber++;
456+ }
444457 // update cabin level numbers
445458 if (cabin)
446459 {
0 commit comments