// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Counter-rotating gear demonstration // Not compiled or tested in-world // Setup: Put in root with uniquely named gear_small and gear_large children, pivots at their centers and axes local Z. Owner-touch toggles. // Stop / restore: Owner-touch to stop and restore the captured starting pose before removing, resetting, or relinking. // Notes: Use a small nonphysical rezzed build with clear space. Actual prim transforms change. Original poses live only in script memory. Do not change physical status or link topology during use. This is geometric animation, not a gear simulation. Place compatible teeth manually; script cannot infer tooth count or mesh clearances. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer small; integer large; rotation a; rotation b; integer active; default { state_entry() { integer i; integer hits; for(i=2;i<=llGetObjectPrimCount(llGetKey());++i) { string name=llGetLinkName(i); if(name=="gear_small") { small=i; ++hits; } if(name=="gear_large") { large=i; ++hits; } } if(hits!=2||!small||!large) { small=0; large=0; return; } a=llList2Rot(llGetLinkPrimitiveParams(small,[PRIM_ROT_LOCAL]),0); b=llList2Rot(llGetLinkPrimitiveParams(large,[PRIM_ROT_LOCAL]),0); } touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner()||llGetStatus(STATUS_PHYSICS)||!small||!large)return; active=!active; if(active) { llResetTime(); llSetTimerEvent(0.2); } else { llSetTimerEvent(0.0); llSetLinkPrimitiveParamsFast(small,[PRIM_ROT_LOCAL,a]); llSetLinkPrimitiveParamsFast(large,[PRIM_ROT_LOCAL,b]); } } timer() { if(llGetLinkNumber()>1||llGetStatus(STATUS_PHYSICS)) { llSetTimerEvent(0.0); active=FALSE; return; } float t=llGetTime()*0.3; llSetLinkPrimitiveParamsFast(small,[PRIM_ROT_LOCAL,llEuler2Rot(<0.0,0.0,t>)*a]); llSetLinkPrimitiveParamsFast(large,[PRIM_ROT_LOCAL,llEuler2Rot(<0.0,0.0,-t*0.5>)*b]); } changed(integer change) { if(change&CHANGED_LINK) { llSetTimerEvent(0.0); active=FALSE; small=0; large=0; llOwnerSay("Links changed; reposition and reset before reuse."); } } }