How to get 3D position ON object of cursor (where the cursor is on the object)?

2.49b: In BGE, moving cursor over an object, how can I get the location on the object that the mouse is over?
(using Rasterizer.showMouse(1)) (not position OF the object, position on the object of the cursor). This would have to be a 3D point, to be able to draw a line from that point (on the object).

This would be so I can make a line be drawn from that point on the object to another object (a font/label describing that object). I can make the line go from the center of the hit object, but that may be covered by another object, making what the line is designating unclear. Moving the cursor to a not covered part of the partly covered object could then allow the line to be drawn from that point instead of the covered center of the hit object.

And it would be useful if the script could know if the center of the partly covered object is covered or not, so I could make the line preferentially go from the center if it’s not covered, but from the cursor if the center is covered.

Do you have a drawing or the blend file so I can better imagine what you want.

Yes, although the scripts are filled with a lot of ignorant experimental stuff; it’s derived from an improvement/solution you provided me.

To see what I’m trying to solve, play it, then rotate the monkeys until one partly covers the other, covering at least the center of the other, then move mouse to an uncovered part of the partly covered one; the line that will then nominally go from the monkey to its label will actually go more from the label toward the center of the touched monkey, but stop at the first surface reached on the obscuring monkey, making it sortof look like the label applies to the wrong monkey.

What I’d like, then, would be to have, when cursor touches a monkey, is that if the center of the touched monkey is obscured by the other one, the line to the associated label would come from the point on the monkey where it was touched, or, if the the center of the touched monkey is not obscured, then the line to the label would then come from the center of the touched monkey as normal.

(edit) Nevermind, agoose77 informed me about hitPosition, and that works fine.

Attachments

TwoMonkeys2with2LinesTo1LabelOnMOverFromAnyObjectAndTextOFF_3bwithGrid.blend (828 KB)

I think you want a mouse overany sensor, and hitPosition

agoose77, oh! I’m so nube I didn’t know there was a hitPosition, just familiar with hitObject!

Any way to tell if center of one object is “behind” another object? (so script would know if it needed to drawLine from different point?)

You’d need to use vectors, i presume you mean behind, relative to you…
The easiest thing to do would be to get the vector to each object, and compare magnitudes.

Not exactly, I think. test situation is: two objects in BGE, rotating around a common center; touch either with cursor, label appears with line coming from it to the object touched. If objects are rotated such that one partly obscures the other, then if the center of the one is obscured, then the line to the label will seem to come from the label to the first surface of the obscuring one that it encounters.

Idea would be to know specifically if CENTER of an partly obscured object is itself obscured; if not, then can let line from label go to that unobscured center.

(edit) Above wish for line to go to center of object if center not obscured may not really be necessary, looks fine for line to come always from point of cursor contact with object.

agoose77, yes, thanks, hitPosition works FINE!

All I really have to do is make sure my labels are far enough in front of the objects that the lines will always be on top of whichever object may be on top of the other.

I see I wast to lat. But here is the changed file.

Attachments

TwoMonkeys2with2LinesTo1LabelOnMOverFromAnyObjectAndTextOFF_3bwithGrid.blend (830 KB)

HG1, not late by much, and thanks for taking the time! Yours wouldn’t load in 2.49b (haven’t upgraded yet), but that’s ok, mine draws from cursor-on-object-position to label almost perfectly now (only little hiccup is that if object has font/label directly on top of it and mouse moves over font, then line to label flickers on & off, but that’s not important, I’m not concerned about that at all). And I took the grid off my latest version as it wasn’t now needed.

I guess I should really start paying more attention to at least an index of Python in Blender commands/functions!