Alright,

I need help for a shooting game I'm working on.

I current have a box that is 3d ( x, y, z)

I'm trying to perform a check to see if my cursor is inside this 3D box.

I understand how to make it 2d by using the max and min values but that creates a 2D box which will say I'm inside the box when in reality I'm not.

Hope someone understand this.

Maybe ill draw a pic and post it.

Its the same as checking for a point in a 2D rectangle. But depending on the view of the person, you need to determine which face of the cube to check on.

see attachment for what i mean

I need to check if mouse is inside the box but not in the red area

- Rotate the world axis such that the cube has no rotation( i.e 'unrotate' the cube relative to the world axis)
- transform the point to be relative to the cube's position
- check if the relative point is in the un-rotated cube by doing simple bounding min-max check

Do you have any examples for this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.