// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Map a decal point between triangles // Not compiled or tested in-world // Setup: Use a spare owned prim. Set source A/B/C, target U/V/W and source point P. Touch for owner-only results. // Stop / restore: Disable/remove. No scene properties change. // Notes: Target need not share the source plane. Points outside the source triangle extrapolate outside the target. // License: see LICENSE in this distribution. // Original Incoprea. MIT. vector A=<0.0,0.0,0.0>; vector B=<1.0,0.0,0.0>; vector C=<0.0,1.0,0.0>; vector P=<0.25,0.5,0.0>; vector U=<3.0,4.0,2.0>; vector V=<7.0,4.0,2.0>; vector W=<3.0,8.0,5.0>; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; vector a=B-A; vector b=C-A; vector p=P-A; float aa=a*a; float ab=a*b; float bb=b*b; float pa=p*a; float pb=p*b; float d=aa*bb-ab*ab; if(llFabs(d)<0.000001) { llOwnerSay("Degenerate source triangle."); return; } float v=(bb*pa-ab*pb)/d; float w=(aa*pb-ab*pa)/d; llOwnerSay("Mapped point="+(string)((1.0-v-w)*U+v*V+w*W)); } }