RayTest in an orthographic world

Post Reply
helpless
Posts: 3
Joined: Tue Oct 25, 2016 12:42 pm

RayTest in an orthographic world

Post by helpless »

Hi!

I need help performing ray picking on orthographically rendered planes. I'm able to both render and pick object in perspective mode, but I'm clueless when it comes to orthographically rendered objects.

The orthographical projection matrix is configured to have 0;0 at the top left, and width;height att the bottom right. Near plane is 0 and far is 100. The view matrix is simply an identity matrix:

Code: Select all

glm::mat4 orthoProjectionMatrix = glm::ortho(0.0f, (GLfloat)width, (GLfloat)height, 0.0f, 0.0f, 100.0f);
glm::mat4 orthoViewMatrix = glm::mat4(1.0f);
I have a two-dimensional plane (along the X and Y axes). The plane is 100 pixels in both width and height. To render it in the top left, I created a vertex buffer where the vertices map 1:1 to the pixels, and left the transformation matrix as an identity.

How do I set up a btCollisionShape to match my on-screen plane? I'm currently creating it like this, which is wrong:

Code: Select all

		// Box, 100*100*0 (this is in NDC? Local space?)
		collisionShape = new btBoxShape(btVector3(50.0f,50.0f,0.0f));
		btQuaternion rot = btQuaternion::getIdentity();
		btVector3 pos = btVector3(0,0,0);
		btTransform trans = btTransform(rot, pos);

		motionState = new btDefaultMotionState(trans);
		btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(0, motionState, collisionShape, btVector3(0,0,0));
		rigidBody = new btRigidBody(rigidBodyCI);
Let's say I want a 100*100 pixel collision plane in the top left, where I've rendered my 100*100 pixels ortho plane. How do I configure my btCollisionShape?

And what do I pass to my btDiscreteDynamicsWorld.rayTest? My start and end vector right now are (x,y,0) respectively (x,y,-1000), should I transform them somehow?.
Post Reply