These forums are CLOSED. Please visit the new forums HERE
Same Offset, Different Size |
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-16-2009 11:35
So i'm scripting a cookie jar with a lid. i have the local positions saved for open/closed for the lid. but i'm not sure how to make the positions adjust for when the cookie jar changes size. i guess i could hard code several sizes and positions, but i'd rather the end customer be able to change the size manually and have the lid open/close positions adjust accordingly
_____________________
Dark Heart Emporium
http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020 want more layers for tattoos, specifically for the head? vote here http://jira.secondlife.com/browse/VWR-1449? llDetectedCollision* Functions similar to touch http://jira.secondlife.com/browse/SVC-3369 |
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
|
09-16-2009 11:43
mod the door/hinge script to use llSetLocalRot/llGetLocalRot instead of llSetRot/llGetRot, and link the door to the cookie jar.
The alternative method(s) are painful, requiring setting up communication between the two objects and detecting when the jar is resized, and you might have to have the lid delete itself in order for the cookie jar to rez a resized version. |
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-16-2009 11:50
mod the door/hinge script to use llSetLocalRot/llGetLocalRot instead of llSetRot/llGetRot, and link the door to the cookie jar. The alternative method(s) are painful, requiring setting up communication between the two objects and detecting when the jar is resized, and you might have to have the lid delete itself in order for the cookie jar to rez a resized version. but it's not a rotation, the lid would move to some spot next to the jar and i wanted it to be linked. i guess i could add another prim and have 2 lids linked to the jar, one closed and one open, and have them switch between alpha 0 alpha 1 _____________________
Dark Heart Emporium
http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020 want more layers for tattoos, specifically for the head? vote here http://jira.secondlife.com/browse/VWR-1449? llDetectedCollision* Functions similar to touch http://jira.secondlife.com/browse/SVC-3369 |
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
09-16-2009 12:20
Hardcode the default local *size* of the lid.
Then when you open or close the lid, multiply the position by (llGetScale() / original_size). If they make the jar 50% larger, the lid will be 50% larger, and (llGetScale / original_size) will be 1.5, and bob's your uncle. _____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/
"And now I'm going to show you something really cool." Skyhook Station - http://xrl.us/skyhook23 Coonspiracy Store - http://xrl.us/coonstore |
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-16-2009 12:39
Hardcode the default local *size* of the lid. Then when you open or close the lid, multiply the position by (llGetScale() / original_size). If they make the jar 50% larger, the lid will be 50% larger, and (llGetScale / original_size) will be 1.5, and bob's your uncle. yes, the size isn't a problem, i'm wanting to adjust the local position for open/closing. the lid(s) will be linked so resizing will be done with the edit window when they resize the object anyways _____________________
Dark Heart Emporium
http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020 want more layers for tattoos, specifically for the head? vote here http://jira.secondlife.com/browse/VWR-1449? llDetectedCollision* Functions similar to touch http://jira.secondlife.com/browse/SVC-3369 |
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
09-16-2009 12:42
yes, the size isn't a problem, i'm wanting to adjust the local position for open/closing. _____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/
"And now I'm going to show you something really cool." Skyhook Station - http://xrl.us/skyhook23 Coonspiracy Store - http://xrl.us/coonstore |
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-16-2009 14:32
is that supposed to be returning a float, vector what? i tried both and get a type missmatch
_____________________
Dark Heart Emporium
http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020 want more layers for tattoos, specifically for the head? vote here http://jira.secondlife.com/browse/VWR-1449? llDetectedCollision* Functions similar to touch http://jira.secondlife.com/browse/SVC-3369 |
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
09-16-2009 14:35
Oh, yeh, sorry, I'm getting ahead of myself. You really want to pull out one coordinate of the scale
// constant at the top level float ORIGINAL_X_SIZE = 0.34; // or whatever float rescalePosition(vector position) { vector current_scale = llGetScale(); return (current_scale.x / ORIGINAL_X_SIZE) * position; } // Now use rescalePosition(wheer_you_want_to_move_the_lid) _____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/
"And now I'm going to show you something really cool." Skyhook Station - http://xrl.us/skyhook23 Coonspiracy Store - http://xrl.us/coonstore |
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-16-2009 15:08
got it! probably looks sloppy, but it does what i needed.
this goes in the root CODE
this goes in the lid CODE
_____________________
Dark Heart Emporium
http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020 want more layers for tattoos, specifically for the head? vote here http://jira.secondlife.com/browse/VWR-1449? llDetectedCollision* Functions similar to touch http://jira.secondlife.com/browse/SVC-3369 |
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
09-16-2009 15:20
A rescale event might be lost (event delivery isn't guaranteed) and llGetScale is efficient, so I wouldn't bother tracking scale and just re-read the current scale every time. And you can do it all in the lid.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/
"And now I'm going to show you something really cool." Skyhook Station - http://xrl.us/skyhook23 Coonspiracy Store - http://xrl.us/coonstore |
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-16-2009 16:09
here we go, i was almost on the verge of pulling my hair out when i realized i was dividing backwards lol
CODE
_____________________
Dark Heart Emporium
http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020 want more layers for tattoos, specifically for the head? vote here http://jira.secondlife.com/browse/VWR-1449? llDetectedCollision* Functions similar to touch http://jira.secondlife.com/browse/SVC-3369 |