ItHadToComeToThis Posted March 7 Share Posted March 7 If I shoot a ray at a prim, I can detect the position that the ray hit at in region coords. Is there a way to convert this to a surface position. Similar to how you can use llDetectedTouchST to determine click coords, can you do anything similar with raycast? I have a target that has circles in, each circle has a number, I would like to be able to create a scoring system. Link to comment Share on other sites More sharing options...
Love Zhaoying Posted March 7 Share Posted March 7 Interesting, you can do more than I thought.. https://wiki.secondlife.com/wiki/LlCastRay#RC_DATA_FLAGS Which link, the "surface normal", only return the Root UUID.. Link to comment Share on other sites More sharing options...
ItHadToComeToThis Posted March 7 Author Share Posted March 7 7 minutes ago, Love Zhaoying said: Interesting, you can do more than I thought.. https://wiki.secondlife.com/wiki/LlCastRay#RC_DATA_FLAGS Which link, the "surface normal", only return the Root UUID.. I looked on there but I didn't see the answer to my question. The target is one single object, so there won't be any other links. Link to comment Share on other sites More sharing options...
animats Posted March 7 Share Posted March 7 The data you get with default settings has what you want. The hit position is where the ray hit the object, in region coordinates. Note that ray casting tests against the physics model, not the visible mesh. So your target needs a physics model that matches what you see. 1 Link to comment Share on other sites More sharing options...
Love Zhaoying Posted March 7 Share Posted March 7 11 minutes ago, animats said: The hit position is where the ray hit the object, in region coordinates. Good point! But, how is this useful to you, @ItHadToComeToThis? (It sounded more to me like, where the object "is" than "where exactly ON the object a ray hit".) Link to comment Share on other sites More sharing options...
Qie Niangao Posted March 7 Share Posted March 7 I knew I remembered this came up somewhere fairly recently. This is extracted from chat at the Simulator User Group a few weeks ago (eliding interspersed discussion of swimming): Quote [2024/02/13 12:31] dantia Gothly: I have a question about raycast results, would it be possible to get the texture cords for the area where the ray hit the surface of a face. [...] [2024/02/13 12:33] Leviathan Linden: Getting the texture coords of raycast on the server seems... nigh impossible in general. [2024/02/13 12:38] dantia Gothly: it would be like, detectedtouchST but for raycast result [2024/02/13 12:38] dantia Gothly: as if I clicked the texture myself with the mouse [...] [2024/02/13 12:38] dantia Gothly: that same result is what im looking for [2024/02/13 12:38] Qie Niangao: hmm... how *does* raycast do surface normal? that must be the physics surface? [...] [2024/02/13 12:38] Rider Linden: /me is looking at the doc for cast ray now. [2024/02/13 12:39] Vale (thunder.rahja): I believe it looks at the surface of the physics mesh, Qie [2024/02/13 12:40] Vale (thunder.rahja): As llCastRay is a function that talks with the physics engine, and the simulator is unaware of the visual mesh of objects [2024/02/13 12:40] Rider Linden: It looks as though llCastRay returns a list. That means we would be able to expand what it returns. [2024/02/13 12:40] Qie Niangao: so can't just stretch the texture over the physics surface and get a UV that means anything, I suppose [2024/02/13 12:40] Vale (thunder.rahja): Take sculpted prims for example. To the simulator, they are spheres, but the viewer turns them into whatever shape the texture describes. [2024/02/13 12:40] Rider Linden: Not sure about being able to send back a UV though. [2024/02/13 12:41] dantia Gothly: https://wiki.secondlife.com/wiki/LlDetectedTouchST this returns the vector coords where it was clicked, [2024/02/13 12:41] URL Reader HUD: https://wiki.secondlife.com/wiki/LlDetectedTouchST = "<nolink>llDetectedTouchST - Second Life Wiki</nolink>" [...] [2024/02/13 12:41] Qie Niangao: right, with llDetectedTouchUV, the viewer is in the act [2024/02/13 12:41] Rider Linden: Oh! But it change the stride. 😞 [2024/02/13 12:42] dantia Gothly: yeah and detectedUV was the other one [2024/02/13 12:42] Rider Linden: but wait... it takes flags about what to return. [2024/02/13 12:43] Vale (thunder.rahja): I've had to troubleshoot a handful of issues related to an object's physics mesh mismatching (and overextending from) the visual mesh in combat sims. [2024/02/13 12:43] dantia Gothly: I can write up a canny request, but I just wanted to bounce around here, I can use this kind of raycast function for a lot of cool things, including cool things for weapons in the combat setting. [...] [2024/02/13 12:44] Qie Niangao: Vale, yeah, I get raycast returns from distant Kidd grasses all the time [2024/02/13 12:44] Rider Linden: Yes, please write something up so we can kick it around on this end. So maybe check-in with dantia Gothly (or, if I've just outed an alt, sorry 'bout that!). 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted March 7 Share Posted March 7 (edited) not directly, you have to do math, but assuming the object has a flat face (like a cube), with sane texture mapping, the math wouldn't be too bad. for your use-case (I'm envisioning something like a dartboard) just converting the region coordinates to object coordinates should be sufficient? (hit_pos-object_pos)/object_rotation; for a cube, could then divide that by half the object's scale, (component wise, <a.x/b.x, a.y/b.y, a.z/b.z> ) then the coordinate that is almost exactly +- 1.0 would tell you the face, and the other two coordinates the position on the face in coordinates ranging from -1 to +1 with 0,0 being the center. Edited March 7 by Quistess Alpha 1 Link to comment Share on other sites More sharing options...
animats Posted March 7 Share Posted March 7 For an example of a good target system, go to region "SSOC". Find the huge SSOC store, with some of the most realistic guns in SL. Outside the store there are stairs down. They lead to SSOC offices. Go through the offices to the target range. It's a realistic known-distance range. Hits appear on the target and on a display of the target. You can set the range. You can have the target return to zero range and look at your groups. 1 Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted March 8 Share Posted March 8 (edited) 15 hours ago, ItHadToComeToThis said: Is there a way to convert this to a surface position. Similar to how you can use llDetectedTouchST to determine click coords, can you do anything similar with raycast? It's not possible to get a surface position, because of what Animats said: 13 hours ago, animats said: Note that ray casting tests against the physics model, not the visible mesh. The physics shape of objects have no face numbers, and don't relate to the visible mesh at all. But since you're trying to create targets for a scoring system, you can fortunately do a bit of math to figure out how far away from the object's center the hit was. Edited March 8 by Wulfie Reanimator 1 1 Link to comment Share on other sites More sharing options...
ItHadToComeToThis Posted March 8 Author Share Posted March 8 5 hours ago, Wulfie Reanimator said: It's not possible to get a surface position, because of what Animats said: The physics shape of objects have no face numbers, and don't relate to the visible mesh at all. But since you're trying to create targets for a scoring system, you can fortunately do a bit of math to figure out how far away from the object's center the hit was. The moment you said that I was like ohhhh you can as well….not even difficult. I think I have a problem of over thinking sometimes. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now