You need to unproject your mouse position. I can't tell you how it exactly works with OpenGL, but I can give you some DirectX-code with a little explanation, you should be able to figure out the rest yourself:
//todo: access camera differently const Camera* pCamera = m_pGfx3D->GetCamera(); //todo: access cursor differently Vector2 mousePos = Input::GetMousePos(); //translate mouse coordinates to scene area mousePos.x -= m_pArea->GetX(); mousePos.y -= m_pArea->GetY(); D3DXVECTOR3 vMouse((float)mousePos.x, (float)mousePos.y, 0.0f); D3DXVECTOR3 vMouse2((float)mousePos.x, (float)mousePos.y, 1.0f); const D3DVIEWPORT9& ViewPort(m_pGfx3D->GetViewport()); D3DXMATRIX mWorld; D3DXMatrixIdentity(&mWorld); D3DXVECTOR3 vP1, vP2; D3DXVec3Unproject(&vP1, &vMouse, &ViewPort, &pCamera->GetProjectionMatrix(), &pCamera->GetViewMatrix(), &mWorld); D3DXVec3Unproject(&vP2, &vMouse2, &ViewPort, &pCamera->GetProjectionMatrix(), &pCamera->GetViewMatrix(), &mWorld); D3DXVECTOR3 vDist = vP2; vDist -= vP1; D3DXVec3Normalize(&vDist, &vDist); const Ray mouseRay(vP1, vDist);
You basically create two points from the mouse, one on the near and one on the far clip plane. Now given the view matrix, projection matrix, viewport and (most likely identity) world matrix you can unproject these two points to their location in the world. You then construct your ray from these two points an voîla, you're done.
I used some of what you said, did a heap of research... and Now it works ^^ - thanks - except the mouse seems to be like 8 pixels off... idk. It works for the most part, so I will probably leave it for now, and start building this program up with other features.
Just as a small observation, what you're calling "logic.cpp" is in fact the input portion of your program. This would run in the input function of your game loop, while logic is a separate function of the game loop that would run after the input.
Alright, So I'll just make a "handle_input" function in my main file then. I'm just worried that it's gonna be huge.
Also to the Animation stuff - seems like bones are the way to go, which means I'll just use static models to start off with lol.
I'm sure I'm way outta my league here - but how feasible is it to make your own modelling program? I mean, I already got the camera and mouse stuff sorted. Just need modelling tools... Animation tools... bone tools, ik tools, texturing tools. Not sure how big of a thing this would be. I'm not talking 3ds or blender, just something for models, and a bit of animation.