December 01, 2024, 09:52:12 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


How to detect a mouse click on a mesh?

Started by barry, April 03, 2008, 01:31:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

barry

I have a little 3D object in a window and I can do some simple transformations on it.  The documentation really helped.  Thanks.

Now is there a simple way to detect if a mouse click was on an object in a 3D window, or do I have to learn the math to determine that for myself?

I'm exploring to see what fun I can have playing with all this without getting too deep.  I don't know what works and what doesn't in 3D yet.

Barry

Ionic Wind Support Team

The Unproject method of the camera does what you want
Ionic Wind Support Team

barry

Quote from: Paul Turley on April 03, 2008, 02:58:56 PM
The Unproject method of the camera does what you want

I think I sort of get it.  Then I can use mesh.RayColided with the 2 vectors as parameters.  Is that correct?

Is it possible to determine which plane of the mesh it goes through?  I'm not sure if that's important or not but if I was going to change a color it might be.  Or should this wait till I know more?

Also does the value of z in Unproject() really matter?

Thanks,
Barry


Barry

Ionic Wind Support Team

The z value of Unproject will be translated to the corresponding z value in 3D space.   On input a z of 0 = front clipping plane of the camera to 1 = back clipping plane.

I have an older example written by Todd Riggins that I can convert, might take me a bit though.

Paul
Ionic Wind Support Team

barry

Quote from: Paul Turley on April 03, 2008, 09:02:56 PM
The z value of Unproject will be translated to the corresponding z value in 3D space.   On input a z of 0 = front clipping plane of the camera to 1 = back clipping plane.

I don't understand what the returned z value is.  Is that the point of contact with some object?  And I don't understand the significance of the z value I input.  I realize that 0 is the front and 1 is the back plane but I'm not sure why that matters.

Quote
I have an older example written by Todd Riggins that I can convert, might take me a bit though.

That would be good.  Thanks.  And there's no rush on this.  I'm retired.  There's no rush on anything. :)

Barry

LarryMc

QuoteAnd there's no rush on this.  I'm retired.

Ain't it a great feeling!

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

barry

I've been googling and reading about unproject and I think im getting a glimmer...just barely though.

Would I use unproject twice, once with z = 0 and once with z = 1 to get a ray to test with ray colided?

Barry

Ionic Wind Support Team

Yes, that would be the way to do it.  I am sure there are other methods.

Paul.
Ionic Wind Support Team

J B Wood (Zumwalt)

I'll download the lastest build of EBasic tonight and do up a demo on selecting objects in 3D space and get it posted, just have had a stressful life these past few months so I have been lacking in the forums sorry about that.
-Jonathan

barry

Thanks a lot.  That would be appreciated.  Especially if it's simple, since I'm a bit simple, too. :)

I don't really have enough math for this stuff.  I never learned a thing about vectors or matrices in school.  I did some reading about matrices a few years ago and I have no slightest understanding of how they do what they do, but following the rules seems to make them work.  Could it be magic?  :)

Barry

J B Wood (Zumwalt)

Not the best example by far, but just threw it together. Move around until you are out of the bounds of the detected object, I am thinking a 3DS object is treated different than an X object or something, anyway, I'll look into this later.

REDEBOLT

Quote from: Larry McCaughn on April 04, 2008, 07:48:44 AM
QuoteAnd there's no rush on this.  I'm retired.

Ain't it a great feeling!

Larry

But the sand is slowly draining out from the hourglass.   :'(
Regards,
Bob

barry

Quote from: Jonathan (zumwalt) Wood on April 04, 2008, 06:02:07 PM
Not the best example by far, but just threw it together. Move around until you are out of the bounds of the detected object, I am thinking a 3DS object is treated different than an X object or something, anyway, I'll look into this later.

I just found this and ran it but I don't begin to understand it yet.  It's after midnight so I'll try to figure it out tomorrow.  Thank you for putting this together. :)

Barry

barry

Quote from: REDEBOLT on April 04, 2008, 09:31:17 PM
But the sand is slowly draining out from the hourglass.   :'(

There's only now!  The past is gone and the future is just possibility, as always.

Barry

J B Wood (Zumwalt)

April 05, 2008, 07:34:26 AM #14 Last Edit: April 05, 2008, 07:37:44 AM by Jonathan (zumwalt) Wood
Going to go get breakfast then create another example using an X mesh object that I will create with either Truespace or Gamespace.

See, the real deal in finding an object in 3d space is that you take the unproject, give it a max like Paul was stating, make sure the object is in the view frustum (which I am not doing in the code btw), take the X and Y (or Z if Z is depth but typically Y is Depth) then see if the object itself from camera or player view frustum based on the source to max depth of unproject and see if the point intersects the object or its children anywhere, unless you don't care about the children. At that point you get a true or false result. In the example I am changing the Alpha of the 3DS model of pauls playground (BTW put the code in the project folder where the other examples are for it to find the 3DS file) and I am changing the text from False to True.

This is a complex model to use for this example, and Front plane vs Back plane of the model is also skewing my results a little. So I will make a cube and place it in a scene then put some more stats on the screen. But first things first, breakfast!

Be back on later.
-Jonathan

Compiling...
3DS_example.eba
No Errors

Linking...
Emergence Linker v1.11 Copyright ÂÃ,© 2006 Ionic Wind Software
Generating C:\Program Files\EBDev\projects\3D samples\3DS_example.exe
Build completed


That is the location of mine btw.

barry

I've just spent a little while playing with this example but at the moment it's just way over my head.  I don't understand most of what's going on in the code or in the running program.  I think I don't have enough understanding of 3D at this point to follow it.

What I've been doing since I got the new help file is to build up a very simple scene with a custom cube and try various ways to transform it and the camera, as in some of the other sample programs.  Except that I've been trying to do this within a more usual windows program.  Even this has been a struggle, but a fun one. :)

I think I need a little more context before I'm going to understand your sample.  I'm going to spend some more time with it to learn what I can from it but I think I'll go back to what I was doing and when I feel a little more grounded I'll try to figure out how to do what you're doing.  Actually I think I was coming along pretty well with it so that might not take too long.

Thanks for the help.

Barry

LarryMc

Quote from: barry on April 04, 2008, 11:29:55 PM
There's only now! 
That's really what I meant:  Isn't NOW great without having to go to work each day! ;D

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

barry

Quote from: Larry McCaughn on April 05, 2008, 09:27:00 AM
That's really what I meant:  Isn't NOW great without having to go to work each day! ;D

That it is.  Even better is that I no longer have to maintain the productivity values I did when I was working.  I had to force myself to do all the un-fun things about programming like making it readable and maintainable.  I no longer have to tie up all the loose ends because most of what I write is just playing around and I don't keep most of it anyway.  I work on something while it's fun and then abandon it.

Retirement means I can be worthless. :)

Barry


aurelCB

I apologise to all ,error in my computer ???