|
@@ -28,7 +28,8 @@ glm::i32vec2 Selector::rayScreen(-1, -1);
|
28
|
28
|
glm::vec3 Selector::rayWorld, Selector::lastIntersectPos, Selector::lastIntersectNorm;
|
29
|
29
|
unsigned long Selector::lastIndexA, Selector::lastIndexB;
|
30
|
30
|
|
31
|
|
-void Selector::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
|
|
31
|
+void Selector::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button,
|
|
32
|
+ bool released) {
|
32
|
33
|
if ((button == leftmouseKey) && (!released)) {
|
33
|
34
|
// Calculate click ray
|
34
|
35
|
rayScreen = glm::vec2(x, y);
|
|
@@ -71,7 +72,8 @@ void Selector::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton b
|
71
|
72
|
if (clickOnObject[roomSpriteObject]) {
|
72
|
73
|
for (unsigned long j = 0; j < r.sizeSprites(); j++) {
|
73
|
74
|
RoomSprite& rs = r.getSprite(j);
|
74
|
|
- if (glm::intersectRaySphere(Camera::getPosition(), rayWorld, rs.getCenter(), rs.getRadius(), pos, norm)) {
|
|
75
|
+ if (glm::intersectRaySphere(Camera::getPosition(), rayWorld, rs.getCenter(), rs.getRadius(), pos,
|
|
76
|
+ norm)) {
|
75
|
77
|
float newDepth = glm::abs(glm::distance(rs.getCenter(), Camera::getPosition()));
|
76
|
78
|
if ((newDepth < depth) || (depth < 0.0f)) {
|
77
|
79
|
depth = newDepth;
|
|
@@ -96,9 +98,11 @@ void Selector::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton b
|
96
|
98
|
|
97
|
99
|
void Selector::displaySelection() {
|
98
|
100
|
if (lastClickedObject == roomModelObject) {
|
99
|
|
- World::getRoom(lastIndexA).getModel(lastIndexB).displayBoundingSphere(Camera::getProjectionMatrix() * Camera::getViewMatrix(), glm::vec3(1.0f, 0.0f, 0.0f));
|
|
101
|
+ World::getRoom(lastIndexA).getModel(lastIndexB).displayBoundingSphere(
|
|
102
|
+ Camera::getProjectionMatrix() * Camera::getViewMatrix(), glm::vec3(1.0f, 0.0f, 0.0f));
|
100
|
103
|
} else if (lastClickedObject == roomSpriteObject) {
|
101
|
|
- World::getRoom(lastIndexA).getSprite(lastIndexB).displayBoundingSphere(Camera::getProjectionMatrix() * Camera::getViewMatrix(), glm::vec3(1.0f, 0.0f, 0.0f));
|
|
104
|
+ World::getRoom(lastIndexA).getSprite(lastIndexB).displayBoundingSphere(
|
|
105
|
+ Camera::getProjectionMatrix() * Camera::getViewMatrix(), glm::vec3(1.0f, 0.0f, 0.0f));
|
102
|
106
|
} else {
|
103
|
107
|
lastClickedObject = WorldObjectCount;
|
104
|
108
|
}
|
|
@@ -122,15 +126,18 @@ void Selector::display() {
|
122
|
126
|
}
|
123
|
127
|
ImGui::Separator();
|
124
|
128
|
|
125
|
|
- ImGui::Text("Camera: (%.2f %.2f %.2f)", Camera::getPosition().x, Camera::getPosition().y, Camera::getPosition().z);
|
|
129
|
+ ImGui::Text("Camera: (%.2f %.2f %.2f)", Camera::getPosition().x, Camera::getPosition().y,
|
|
130
|
+ Camera::getPosition().z);
|
126
|
131
|
ImGui::Text("Last click: (%d %d)", rayScreen.x, rayScreen.y);
|
127
|
132
|
if ((rayScreen.x >= 0) && (rayScreen.y >= 0)) {
|
128
|
133
|
ImGui::Text("Normalized Ray: (%.3f %.3f %.3f)", rayWorld.x, rayWorld.y, rayWorld.z);
|
129
|
134
|
}
|
130
|
135
|
|
131
|
136
|
if (lastClickedObject != WorldObjectCount) {
|
132
|
|
- ImGui::Text("Intersect Pos: (%.2f %.2f %.2f)", lastIntersectPos.x, lastIntersectPos.y, lastIntersectPos.z);
|
133
|
|
- ImGui::Text("Intersect Norm: (%.2f %.2f %.2f)", lastIntersectNorm.x, lastIntersectNorm.y, lastIntersectNorm.z);
|
|
137
|
+ ImGui::Text("Intersect Pos: (%.2f %.2f %.2f)", lastIntersectPos.x, lastIntersectPos.y,
|
|
138
|
+ lastIntersectPos.z);
|
|
139
|
+ ImGui::Text("Intersect Norm: (%.2f %.2f %.2f)", lastIntersectNorm.x, lastIntersectNorm.y,
|
|
140
|
+ lastIntersectNorm.z);
|
134
|
141
|
}
|
135
|
142
|
|
136
|
143
|
if (lastClickedObject == roomModelObject) {
|