<p>In games and other 3D scenes, generally when the user clicks the mouse, a ray is cast into the scene in the direction the camera is facing, and a check is done to see what geometry in the scene it intersects. If it intersects nothing, it is ignored. If it intersects a single object, then the application processes a click on that object (at the location of the intersection). If more than one object is intersected, then usually the front-most object is assumed to be the on the user wanted to click on, so that is processed.</p>

<p>In general, geometry is stored using x,y,z coordinates rather than spherical coordinates, as the GPU hardware works in cartesian coordinates.</p>

CC BY-SA 4.0
2019-01-06T17:15:20.493Z
2019-01-06T17:15:20.493Z
user1118321
<p>What would be the best way to make a texture a clickable button? Suppose I have a Room (respresented by a 2D texture), where there are buttons. </p>

<p>Would I in the main loop:</p>

<ul>
<li><p>check when the mouse is clicked if it is in any region of a button? (<span class="math-container">$\mathcal{O}(n_{Button})$</span>)</p></li>
<li><p>Do something entirely different that I can't think of?</p></li>
</ul>

<p>I may be overthinking this, maybe this isn't a problem at all, but somehow, what I came up with sounds way to "stupid" to me to be the right solution. It sounds like a hack to me, but maybe this is the way to do it? In 3D Games, would the check than be just radial coordinates (<span class="math-container">$r,\phi,\theta$</span>)?</p>

<texture><algorithm>
Make a texture a clickable Button
Fl.pf.
# Make a texture a clickable Button

(Asked by: username_0 on 2019-01-06)

What would be the best way to make a texture a clickable button? Suppose I have a Room (respresented by a 2D texture), where there are buttons.

Would I in the main loop:

* check when the mouse is clicked if it is in any region of a button? ($\mathcal{O}(n\_{Button})$)
* Do something entirely different that I can't think of?

I may be overthinking this, maybe this isn't a problem at all, but somehow, what I came up with sounds way to "stupid" to me to be the right solution. It sounds like a hack to me, but maybe this is the way to do it? In 3D Games, would the check than be just radial coordinates ($r,\phi,\theta$)?

**Tags:** texture, algorithm


---

## 1 answers

### Answer by username_1 on 2019-01-06. Score: 3 | Accepted answer

In games and other 3D scenes, generally when the user clicks the mouse, a ray is cast into the scene in the direction the camera is facing, and a check is done to see what geometry in the scene it intersects. If it intersects nothing, it is ignored. If it intersects a single object, then the application processes a click on that object (at the location of the intersection). If more than one object is intersected, then usually the front-most object is assumed to be the on the user wanted to click on, so that is processed.

In general, geometry is stored using x,y,z coordinates rather than spherical coordinates, as the GPU hardware works in cartesian coordinates.


---

