Pick face from mouse click

Software: Away3D 4.x

Koga73, Newbie
Posted: 15 November 2012 08:13 PM   Total Posts: 13

Hi,
I want to get the normal of whatever face the user clicked on.

I’m using:
_view.mousePicker = PickingType.RAYCAST_BEST_HIT;
_mesh.pickingCollider = PickingColliderType.PB_BEST_HIT;

The mouse event is firing I’m just not sure how to determine what face was clicked on… and subsequently the normal for that face.

Thanks!

   

Avatar
Alejandro Santander, Administrator
Posted: 15 November 2012 08:16 PM   Total Posts: 414   [ # 1 ]

Hey, the MouseEvent3D carries information about the normal. Have a look at the new picking tutorial.

The 3 last demos on the tutorial make use of the event’s normal property.

   

Koga73, Newbie
Posted: 15 November 2012 08:42 PM   Total Posts: 13   [ # 2 ]

Thanks I hadn’t seen that tutorial. The last example is the most similar.

When I get the sceneNormal property from the MouseEvent3D instance its always one of the following:
(1, 0, 0)
(0, 0, 1)

This seems strange as my mesh is in the shape of a cylinder. I would expect to see normal values that have a decimal for both the x and z coordinates.

Is this correct… any ideas?

   

Avatar
Alejandro Santander, Administrator
Posted: 15 November 2012 08:51 PM   Total Posts: 414   [ # 3 ]

yeah, you are correct

can you try setting view.forceMouseMove = true?

   

Koga73, Newbie
Posted: 15 November 2012 08:53 PM   Total Posts: 13   [ # 4 ]

Just tried it same result… no matter where I click on the model either the x or z value is 1 with the other values being 0 for the sceneNormal property.

   

Avatar
Alejandro Santander, Administrator
Posted: 15 November 2012 08:54 PM   Total Posts: 414   [ # 5 ]

What happens if you listen to mouse moves instead of mouse clicks?

   

Koga73, Newbie
Posted: 15 November 2012 09:03 PM   Total Posts: 13   [ # 6 ]

Interesting… If I listen for move events with forceMouseMove=false I get the same result I’ve been getting however when forceMouseMove=true the move event’s sceneNormal property looks correct.

   

Avatar
Alejandro Santander, Administrator
Posted: 15 November 2012 09:05 PM   Total Posts: 414   [ # 7 ]

Seems like you’ve found a bug! Assuming that you are up to date with the lib, let me know what branch you are observing this in and I’ll fix it later today or early tomorrow.

   

Koga73, Newbie
Posted: 15 November 2012 09:09 PM   Total Posts: 13   [ # 8 ]

Thanks!
I’m using away3d-core-fp11_4_0_9_gold.

I suppose for the time being I can record the sceneNormal value on mouseMove and then do what I want with it on click.

After you get the bug fixed do I go to github for the latest? Also will there be an updated swc with the fix?

   

Avatar
Alejandro Santander, Administrator
Posted: 15 November 2012 09:11 PM   Total Posts: 414   [ # 9 ]

Sure, thx for finding the bug! As soon as it’s fixed I’ll notify you here and leave instructions.

   

Avatar
Alejandro Santander, Administrator
Posted: 16 November 2012 02:07 PM   Total Posts: 414   [ # 10 ]

Alright, it should be fixed now, can you give it another try?

You’d need to update your away3d-core-fp11 library from github, in either the master branch or the dev branch.

   

Koga73, Newbie
Posted: 16 November 2012 03:18 PM   Total Posts: 13   [ # 11 ]

Thanks!!!
I grabbed the latest code off of github and it looks like its working now. I really need a swc due to compile time. Could you post one?

   

Avatar
Alejandro Santander, Administrator
Posted: 16 November 2012 04:23 PM   Total Posts: 414   [ # 12 ]

I’m afraid I don’t have one. Can’t you just compile the library and use the outputted swc?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X