added Engine::pickOne()
git-svn-id: svn://anubis/anaglym/trunk@309 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
89e065ebb5
commit
a43935fdd6
34
Engine.cc
34
Engine.cc
@ -693,6 +693,40 @@ refptr< vector<Engine::PickedObjectRef> > Engine::pickObjects(int x, int y)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Engine::PickedObjectRef Engine::pickOne(int x, int y, Engine::Object *obj)
|
||||||
|
{
|
||||||
|
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_av.getWidth() / 2;
|
||||||
|
initial_direction[1] = m_screen_dist;
|
||||||
|
initial_direction[2] = y - m_av.getHeight() / 2;
|
||||||
|
dMultiply0(rotated_direction, r, initial_direction, 3, 3, 1);
|
||||||
|
normalize(rotated_direction);
|
||||||
|
|
||||||
|
OdeWorld::PickedObjectRef owpor =
|
||||||
|
m_world.pickOne(m_eye[0], m_eye[1], m_eye[2],
|
||||||
|
rotated_direction[0], rotated_direction[1], rotated_direction[2],
|
||||||
|
obj->getOdeWorldObject());
|
||||||
|
|
||||||
|
PickedObjectRef ret;
|
||||||
|
|
||||||
|
if (!owpor.isNull())
|
||||||
|
{
|
||||||
|
ret = new PickedObject(owpor);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void Engine::debug_hook(lua_Debug * debug)
|
void Engine::debug_hook(lua_Debug * debug)
|
||||||
{
|
{
|
||||||
Uint32 ticks = SDL_GetTicks();
|
Uint32 ticks = SDL_GetTicks();
|
||||||
|
2
Engine.h
2
Engine.h
@ -93,6 +93,7 @@ class Engine
|
|||||||
}
|
}
|
||||||
void setID(int id) { m_id = id; }
|
void setID(int id) { m_id = id; }
|
||||||
int getID() { return m_id; }
|
int getID() { return m_id; }
|
||||||
|
OdeWorld::Object *getOdeWorldObject() { return m_ode_object; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void createManagedObject();
|
void createManagedObject();
|
||||||
@ -216,6 +217,7 @@ class Engine
|
|||||||
}
|
}
|
||||||
bool getScriptCursorVisible() { return m_script_cursor_visible; }
|
bool getScriptCursorVisible() { return m_script_cursor_visible; }
|
||||||
refptr< std::vector<PickedObjectRef> > pickObjects(int x, int y);
|
refptr< std::vector<PickedObjectRef> > pickObjects(int x, int y);
|
||||||
|
PickedObjectRef pickOne(int x, int y, Object *obj);
|
||||||
|
|
||||||
void getScreenSize(int * width, int * height);
|
void getScreenSize(int * width, int * height);
|
||||||
void drawText(const char * text, GLfloat r, GLfloat g, GLfloat b,
|
void drawText(const char * text, GLfloat r, GLfloat g, GLfloat b,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user