PDA

View Full Version : cursor change on mouse over - at a specific distance


Gimungus
09-22-2008, 03:52 PM
Hi,
I'm trying to set a cursor change on mouse over but I only want it to occur when within a set distance of the object. I know I can plug a value into the Act Dist Min field but I have hundreds of objects and I'm using a distance variable. Is there some way I can check for mouse over and distance (say, in the sceneloop) and still use my global disance variable before triggering the cursor change?

I hope that made sense.

Lots of objects,
Arrow to hand on rollover if within a global variable.

Thanks
Chris

Radishworks
09-23-2008, 07:01 AM
I'm not exactly sure I understand what you are looking for, but you might experiment with the Scene Setting "Show Distance to Camera", it can be found in the Scene Settings tab, in the General Scene Settings area.

This setting will show the distance of objects to the camera in play mode - when they are selected in the objects tree.

Mike

Gimungus
09-23-2008, 01:22 PM
Basically I have a lot of 3d objects in a first person shooter environment.

I want to change the cursor from arrow to hand on rollover of those objects. (I already know how to do this).

I only want the cursor change to occur when the camera is within a specific distance "D" of the objects.

Rather than enter the distance in the Act Dist Min field of the change cursor animation many times I want to use a variable that I can change globally.

I'm already running a script to check to see if an object is within my minimum pick distance before whenever I click on it to determine if it is eligible to select, I just want to give a visual cue by making the cursor change on rollover so I can tell when I'm close enough to select it.

Thanks

Radishworks
09-23-2008, 01:48 PM
Ahh, I understand. Yes, that can easily be done.

Just get the location of the object "GetObjectLocation" function and the location of the scenes camera (or eye point) using "GetViewSettings" function. Given those two points you can calculate the distance between them.

Code that would get the distance between two points is pretty easy, here's a C example of that:

float rw_Distance(ec_pVectPt pt1, ec_pVectPt pt2){
return((float)sqrt((pt2->x-pt1->x)*(pt2->x-pt1->x)+(pt2->y-pt1->y)*(pt2->y-pt1->y)+(pt2->z-pt1->z)*(pt2->z-pt1->z)));
}

Once you have a distance, you can use your scripting logic to do whatever you like.

I think we'll add a built in API function to get the distance between two points, I think that's logged a feature request someplace.

Regards,
Mike

Radishworks
09-23-2008, 01:50 PM
Or there is also an API function GetDistanceToCamera, that you can pass an object and it will return the distance.

M :-)

Radishworks
09-23-2008, 07:12 PM
Here's even a sample scene. Thanks to Sue.