PDA

View Full Version : Selection Problems



10-21-2003, 03:39 PM
Selection has been giving me some grief.
I seem to be able to select the player and level but when i add my list of monsters. the program starts to get inaccurate results or none at all. any ideas?

void GameClass::PickScene()
{

glPushMatrix();

glTranslatef(0.0f, 0.0f, -28.0f);
glRotatef(45.0f, 1.0, 0.0f, 0.0f);

glPushMatrix();

camera->ApplyCameraTransform();

glInitNames();
glPushName(0);

// draw the ground
glLoadName(LEVEL);
m_theLevel->DrawLevel();

// draw the player
glLoadName(PLAYER);
m_player->DrawModel();

for(int i=0; i<monsters.getListSize();i++)
{
glLoadName(m_monsters.getData(i).name);
DrawMonster(m_monsters.getData(i));
}

glPopMatrix();

glPopMatrix();

SwapBuffers(m_hDC);
}

147-2
10-24-2003, 01:19 PM
I dont see you going into the picking/selection render mode... I suppose you do that elsewhere? Anyways, what you need to do is create a pickmatrix which needs to be multiplied into your projection matrix before you multiply in your ortho or perspective projection matrix. Don't load your ortho or perspective matrix, I did that and ended up with a picker that picked everything visible http://www.opengl.org/discussion_boards/ubb/frown.gif

anyways, one thing I did notice... you dont need to swap buffers. When in selection mode, you're not actually drawing, so that particular rendering mode won't actually modify your buffers at all.