0

Hello,

I want to implement a 3d environment, at first will start with a cube.
And i want to implement a click event for this object, like Click event for a button.
The problem is i don't know how to implement this, or where to start.
Can someone give me some advice and/or references?

Thank you, Chris

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by skatamatic
0

As a starting point, you need to think of your mouse cursor as a "ray" that intersects through your 3D world at an angle that is perpendicular to your current projection.

Then you check which object you hit first with your "mouse ray" and that is the object you have clicked on.

0

No, sorry, i think i asked wrong, i know how to do that, what i want to know
is how i can add a feature like this:
mnuPaste.Click += new EventHandler(mnuPaste_Click);
the result should be
cube.Click += new EventHandler(cube_Click); for example
But the question is, can it be done in the case the object is not a button, but a object i created

0

If the object you created doesn't already have that event. Then you need to write you own, which involves the procedure I laid out above.

0

Yes. You will need to look into event programming though. I suspect you are using a Direct3D environment - if this is the case you may want to set up an on-click event for the 3D area, then inside that event use Ketsuekiame's method of finding which object was clicked on, then fire the on-click event for that object.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.