This commit is contained in:
Atlante45 2014-04-08 16:35:46 -07:00
commit 7e33ed0c91
3 changed files with 29 additions and 12 deletions

View file

@ -524,10 +524,22 @@ void Application::paintGL() {
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
_myCamera.setTightness(0.0f); _myCamera.setTightness(0.0f);
float headHeight = _myAvatar->getHead()->calculateAverageEyePosition().y - _myAvatar->getPosition().y; glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition();
float headHeight = eyePosition.y - _myAvatar->getPosition().y;
_myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale());
_myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0));
_myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
// if the head would intersect the near clip plane, we must push the camera out
glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) *
(eyePosition - _myCamera.getTargetPosition());
const float PUSHBACK_RADIUS = 0.2f;
float pushback = relativePosition.z + _myCamera.getNearClip() +
_myAvatar->getScale() * PUSHBACK_RADIUS - _myCamera.getDistance();
if (pushback > 0.0f) {
_myCamera.setTargetPosition(_myCamera.getTargetPosition() +
_myCamera.getTargetRotation() * glm::vec3(0.0f, 0.0f, pushback));
}
} }
// Update camera position // Update camera position

View file

@ -54,6 +54,7 @@ public:
const glm::quat& getRotation() const { return _rotation; } const glm::quat& getRotation() const { return _rotation; }
CameraMode getMode() const { return _mode; } CameraMode getMode() const { return _mode; }
float getModeShiftPeriod() const { return _modeShiftPeriod; } float getModeShiftPeriod() const { return _modeShiftPeriod; }
float getDistance() const { return _distance; }
const glm::vec3& getTargetPosition() const { return _targetPosition; } const glm::vec3& getTargetPosition() const { return _targetPosition; }
const glm::quat& getTargetRotation() const { return _targetRotation; } const glm::quat& getTargetRotation() const { return _targetRotation; }
float getFieldOfView() const { return _fieldOfView; } float getFieldOfView() const { return _fieldOfView; }

View file

@ -143,6 +143,7 @@ void generateOutput (QTextStream& out, const QList<Streamable>& streamables) {
out << " }\n"; out << " }\n";
out << " index = nextIndex;\n"; out << " index = nextIndex;\n";
} }
if (!str.fields.isEmpty()) {
out << " switch (index) {\n"; out << " switch (index) {\n";
for (int i = 0; i < str.fields.size(); i++) { for (int i = 0; i < str.fields.size(); i++) {
out << " case " << i << ":\n"; out << " case " << i << ":\n";
@ -150,6 +151,7 @@ void generateOutput (QTextStream& out, const QList<Streamable>& streamables) {
out << " break;\n"; out << " break;\n";
} }
out << " }\n"; out << " }\n";
}
out << "}\n"; out << "}\n";
out << "QVariant " << name << "::getField(int index) const {\n"; out << "QVariant " << name << "::getField(int index) const {\n";
@ -162,12 +164,14 @@ void generateOutput (QTextStream& out, const QList<Streamable>& streamables) {
out << " }\n"; out << " }\n";
out << " index = nextIndex;\n"; out << " index = nextIndex;\n";
} }
if (!str.fields.isEmpty()) {
out << " switch (index) {\n"; out << " switch (index) {\n";
for (int i = 0; i < str.fields.size(); i++) { for (int i = 0; i < str.fields.size(); i++) {
out << " case " << i << ":\n"; out << " case " << i << ":\n";
out << " return QVariant::fromValue(this->" << str.fields.at(i).name << ");\n"; out << " return QVariant::fromValue(this->" << str.fields.at(i).name << ");\n";
} }
out << " }\n"; out << " }\n";
}
out << " return QVariant();\n"; out << " return QVariant();\n";
out << "}\n"; out << "}\n";