• Create Account

# Trying to project a point onto a cubemap

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1Nairou  Members   -  Reputation: 403

Like
0Likes
Like

Posted 22 December 2013 - 12:08 PM

I've got a simple test program with a camera within a cubemap (skybox). You can look around, and it feels like you're in a 3D room, but really it's just a cubemap image.

Now I want to draw a point (well, ultimately, a large number of points) on the screen, such that it appears to be anchored at a point on the cubemap. For example, if the cubemap is of a room, then I want to put a point on the "wall", and have it appear to be stationary when you look around.

Given that there is no actual environment, it's just a cubemap, the points I want to project are represented as x/y rotational angles, rather than absolute 3D vertices. I tried calculating the position manually, using the camera x/y angles and interpolating across the screen. However because the cubemap is distorted at the edges due to the camera's projection matrix, my linear calculations don't match up, so the point appears to wobble as you look around.

I know I need to incorporate the camera's projection matrix to get it to appear in the correct position, but I'm not sure how. I'm using the CML math library, and I noticed it has a project_point() function, but it works with absolute 3D coordinates, so I don't know how that helps me when starting with angles instead of coordinates.

If someone could get me pointed in the right direction, I would appreciate it.

### #2Waterlimon  Crossbones+   -  Reputation: 1894

Like
0Likes
Like

Posted 22 December 2013 - 01:40 PM

Convert your angles into a vector direction and render that as a point position. Then it should go through the projection matrix at least.

The lack of awesome free resource gathering building sandbox games capable of running an user made 8 bit computer in the world disturbs me.

### #3Nairou  Members   -  Reputation: 403

Like
0Likes
Like

Posted 22 December 2013 - 03:19 PM

Thanks for the reply. I actually had that thought as well, but got stuck trying to implement it. I'm pretty sure I could create a forward vector and use matrices to rotate that by the x and y angles, and then extract the position. But I don't know if there is a more direct way to convert it. I thought I could use the angles directly and just normalize them to get a point, but if the camera looks directly at the point then the angles are zero, and I get an invalid result doing that.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS