I missed the SetTexCoord function. I now understand it better. Thanks for that.
Regarding the object selection:
I have 5 objects on the screen (E3DSurface), and 5 positions (EVECTOR3D)
Here is how I draw the scene:
- Code:
ERESULT OnNextFrame(ClassEDisplay* pDisplay, unsigned long nDelta)
{
if (ecd.input->KeyHold(DIAM_MENUUP))
m_nZoom += (long)(nDelta * 8);
else if (ecd.input->KeyHold(DIAM_MENUDOWN))
m_nZoom -= (long)(nDelta * 8);
if (ecd.input->KeyHold(DIAM_MENULEFT))
m_nRotation -= (short)nDelta*2;
else if (ecd.input->KeyHold(DIAM_MENURIGHT))
m_nRotation += (short)nDelta*2;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
pDisplay->Perspective2D(256, 256, false);
pDisplay->Perspective3D(pDisplay->GetWidth(), pDisplay->GetHeight());
pDisplay->WorldReset();
pDisplay->WorldTranslate(0, 0, m_nZoom);
pDisplay->WorldRotate(256, m_nRotation, 0);
pDisplay->BindTexture(&m_Texture);
pDisplay->SetShading(E3D_GOURAUD | E3D_TEXTURE);
for (int nIndex=0;nIndex<5;nIndex++)
{
m_Item[nIndex].Reset();
m_Item[nIndex].Translate(m_Position[nIndex].x,m_Position[nIndex].y,m_Position[nIndex].z);
pDisplay->Render(&m_Item[nIndex]);
}
return E_OK;
}
I've added a handler for OnStylusDown. From what I understood, I need to use a matrix to translate the 2D point into a 3D point or a 3D vector. My items will never overlap, so I can use a cube for testing of collision with the vector, but I have no clue on how to create/use the matrix.
BTW: This is one of the examples I think should be posted into the website as a code snippet ("adding 3D selection to your code").
P.S.
I've sent you an email.
- Gilad