started working on Engine::pickObjects()
git-svn-id: svn://anubis/anaglym/trunk@249 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
f8fbdf8fcb
commit
e2dc4529cc
25
Engine.cc
25
Engine.cc
@ -14,7 +14,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <math.h> /* fabs() */
|
||||
#include <math.h> /* fabs(), tan() */
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "SDL.h"
|
||||
@ -99,6 +99,7 @@ Engine::Engine(const string & path, Video & video)
|
||||
m_engine_cursor_visible = m_video.getCursorVisible();
|
||||
m_script_cursor_visible = false;
|
||||
m_input_grabbed = m_video.getInputGrabbed();
|
||||
m_screen_dist = (m_video.getWidth() / 2.0) / tan(30.0 * M_PI / 180.0);
|
||||
|
||||
size_t pos = path.find_last_of("\\/");
|
||||
m_engine_path = (pos != string::npos) ? string(path, 0, pos) : ".";
|
||||
@ -622,6 +623,28 @@ void Engine::clearWorld()
|
||||
}
|
||||
}
|
||||
|
||||
refptr< vector<int> > Engine::pickObjects(int x, int y)
|
||||
{
|
||||
dMatrix3 r;
|
||||
dVector3 right, forward, up;
|
||||
dVector3 rotated_direction, initial_direction;
|
||||
up[0] = m_up[0];
|
||||
up[1] = m_up[1];
|
||||
up[2] = m_up[2];
|
||||
forward[0] = m_center[0] - m_eye[0];
|
||||
forward[1] = m_center[1] - m_eye[1];
|
||||
forward[2] = m_center[2] - m_eye[2];
|
||||
cross_product(right, forward, up);
|
||||
dRFrom2Axes(r, right[0], right[1], right[2],
|
||||
forward[0], forward[1], forward[2]);
|
||||
initial_direction[0] = x - m_video.getWidth() / 2;
|
||||
initial_direction[1] = m_screen_dist;
|
||||
initial_direction[2] = m_video.getHeight() / 2 - y;
|
||||
dMultiply0(rotated_direction, initial_direction, r, 1, 3, 3);
|
||||
|
||||
/* TODO: finish */
|
||||
}
|
||||
|
||||
void Engine::debug_hook(lua_Debug * debug)
|
||||
{
|
||||
Uint32 ticks = SDL_GetTicks();
|
||||
|
2
Engine.h
2
Engine.h
@ -195,6 +195,7 @@ class Engine
|
||||
updateCursorVisibility();
|
||||
}
|
||||
bool getScriptCursorVisible() { return m_script_cursor_visible; }
|
||||
refptr< std::vector<int> > pickObjects(int x, int y);
|
||||
|
||||
void getScreenSize(int * width, int * height);
|
||||
void drawText(const char * text, GLfloat r, GLfloat g, GLfloat b,
|
||||
@ -274,6 +275,7 @@ class Engine
|
||||
SDL_Event m_exitEvent;
|
||||
Uint32 m_event_time;
|
||||
FTFont * m_font;
|
||||
double m_screen_dist;
|
||||
|
||||
bool m_event_init_present;
|
||||
bool m_event_reinit_present;
|
||||
|
Loading…
x
Reference in New Issue
Block a user