Jump to content

BrownBoxStudio

Resident
  • Posts

    81
  • Joined

  • Last visited

Everything posted by BrownBoxStudio

  1. I've been wondering if there is a good place to share scripts? I've been making some useful little odds and ends and have been wanting to share them incase anyone else might find them useful too. I know the marketplace is always viable but I don't really want to populate my store with random free scripts. I may do so but I'm first wondering if there are other places to share scripts. I may just have to create an alt and a new marketplace store.
  2. Oh, what I mean by mentioning the SL build system was that if you rotate the prim by build tools the resulting angle may not be what is expected in the script. For example I rotated on one axis and it changed the other axis instead. So you have to change it manually in the build tools or it may be best to set rotation manually in the script itself. Also thanks for the suggestion. I need messages a bit more than the bases info just at the start, incase you move the base while the script is running, but I could probably make it smoother by using less chat messages. I guess I just need the child script to save all the information which it does not right now. You can get it to rotate, I had that wrong that you need to change the script. You just have to rotate 90 degrees on X or Y.
  3. Oh, it really was that simple. I had thought I had already tried that, or the equivalant of applying X/Y angle from the base, before asking but tried again since you suggest it and found out my base was broken. Thanks so much. Due to all of the genorosity in helping accomplish the rotation for my scripts I've cleaned up the scripts and am sharing them below; sharing is the least I can do for now. Here is the parent (static axis) and child (object to rotate) script. Everything is controlled by the parent script. You would just need to change the listen channel in the child script. Parent (Axis): float radius = 5.0;float timerSpeed = .05;float rotStep = .25; float count;vector myPos;integer listenChan = -360;integer touched = FALSE;rotation turnRot;rotation myRot;seatPos(){ myPos = llGetPos(); myRot = llGetRot(); count += rotStep; //Set axis rotation angle. if (count > 360) { count -= 360; } vector euler = RAD_TO_DEG * llRot2Euler(myRot); vector rot = <euler.x,euler.y,count>; //Apply axis rotation angle. //llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION, llEuler2Rot(rot*DEG_TO_RAD)]); //Can set axis prim to rotate with child object. list temp = ["position", myPos, "rotation", rot, "radius", radius]; llShout(listenChan, llList2CSV(temp));}default{ state_entry() { llListen(0, "", llGetOwner(), "setup"); } touch_start(integer total_number) { if (touched == FALSE) { llSetTimerEvent(timerSpeed); touched = TRUE; } else if (touched == TRUE) { llSetTimerEvent(0); touched = FALSE; } } timer() { seatPos(); }} Child (Rotated Prim): Although this is still a bit bumpy. Hard to set the proper rotation angles based on the base prim. The SL build system rotations doesn't translate well for that application. You also have to change some things if you want it to rotate around a horizontal axis.
  4. Thanks for pointing out that is gives me the difference between X and Z and to Dora for the equation. I got it working and it works quiet amazing. Although I don't understand why does adding the baseRot onto the X,Z spin cause it to rotate around? Also would it be too much to ask you guys one more question involving rotations? Now instead of just up and down rotation, and side to side rotatation, what about diagonal rotation? So the seats will be effected by the at a diagonal angle, instead of X and Z spin it would X and Y spin with Z offset or it could be an X and Z spin, like now, with a Y offset. I've test with the equations and can get a diagonal spin by changing the Y to llSin(angle) or llCos(angle) but that always spins diagonally. Thanks again guys!
  5. I was using that example from the wiki but, if your is the same, it's not possible in the long run. It runs based on the seats position, if I change the position the offset axis is also changed, so I cannot change the seat positions as I have in some rides. I've been keeping the rotation seperate and it works just not when it comes to rotating the ride on a vertical axis with the seats rotating on a horizontal axis which is what I am trying to do..So it forces me to keep the seat at the same angle. But thanks for the suggestion.
  6. Thanks, I thought so but wasn't sure. I will try applying it again with that information. Edit: Tried applying it as such with no luck: seatPos(rotation baseRot, vector basePos){ if (radius == 0) { radius = llVecDist(myPos, basePos); } string name = llGetObjectName(); string substring = llGetSubString(name, -1, -1); //Get Seat Number float angleAdjust = ((360/(integer) seatCount) * (integer)substring); count = -baseRot.z + 90 + angleAdjust; float angle = (PI/180)*count; vector pos = radius*< llCos( angle), .0, llSin( angle)>*baseRot; list params = [PRIM_POSITION, pos]; llSetLinkPrimitiveParamsFast(LINK_THIS, params);} Am I doing something very wrong in the way I've applied it? Otherwise I guess I do not understand what was meant by the equation. I did realize that I wasn't use a rotation for baseRot instead a vector but I changed it to an actual rotation. Also isn't the base position needed somewhere in the equation? Even though I could be totally wrong I did try: (radius*< llCos( angle), .0, llSin( angle)>+basePos)*baseRot; which still led me to nowhere.
  7. llAxisAngle2Rot(); is interesting but I'm not sure how you might be implying I could use the function in my script. I'm not currently use any rotations except on the angle of the ferris wheel body. The seats are seperate objects and so I have been using position, not rotation to move them in space. Sorry, my title does imply I am trying to rotate around an axis. I guess I should have specified that I am trying to move an object in a circular motion around an axis as if it were rotating. Although your second suggestion seems very useful. I'll give it a try, thanks! Although, to be clear, is your equation also returning a rotation or is it a vector? Edit: I gave it a try but without luck. I used the equation to calculate the X and Z vector and it didn't succeed in going around the axis. I replaced my equation with your equation, was that what you had in mind?
  8. Whoops, was my description that bad? I meant a regular ferris wheel as you know it, rotating around a horizontal axis. Although you seem to have given a possible solution for what is called an enterprise. This is an enterprise if you don't know: That would be fun to make sometime but I would need to learn how to get the "extra vector component", as you call it, for the rotating arm.For now Im trying the ferris wheel which works but only if it is placed at 90 degs, 180 degs, etc. I am trying to get the seats to spin around the same axis even if the ferris wheel was placed at a 33 degree angle for example. I've gotten close but almsot something off with what I have tried.
  9. Thanks for the help. That was similar to what I had already tried, or at least it sounded like it. I gave it a try anyway but wasn't able to get it working. In the end I found I can set the spinRate to negative and the spin direction will change. I didn't expect it to be that simple. if (held & CONTROL_ROT_LEFT) { spinRate -= 2; //llOwnerSay((string)spinRate); spinLimit(); } else if (held & CONTROL_ROT_RIGHT) { spinRate += 2; //llOwnerSay((string)spinRate); spinLimit(); }llTargetOmega(<0,0,1>, PI/180*spinRate, spinRate); Thanks!
  10. Thanks to the help I received last time I was able to learn about rotating an object around an offset axis in 2D but now Im wondering how to rotate around a point with a 3rd axis. This time I'm working on a ferris wheel. I have the seats spinning around an offset axis on Z rotation but if you change the Y angle the seats do not follow. I've tried modifying the same equation I used before but I know there is something missing. I imagine what I need to do is something like below, figure out the x and y on the bottom triangle and then apply the z axis. I can get the Z pretty easily but I am not sure how to get the X and Y.  This is what I am currently using the apply the position of the seats when they are spinning on the Z axis. seatPos(vector baseRot, vector basePos) { //llOwnerSay((string)basePos); if (radius == 0) { radius = llVecDist(myPos, basePos); } string name = llGetObjectName(); string substring = llGetSubString(name, -1, -1); //Get Seat Number float angleAdjust = ((360/(integer) seatCount) * (integer)substring); count = -baseRot.z + 90 + angleAdjust; //Modify position by seat number. //llOwnerSay((string)angleAdjust); float angle = (PI/180)*count; float seatX = basePos.x + radius*llSin(angle); //calucate X position //float seatY = basePos.y + radius*llCos(angle); float seatZ = basePos.z + radius*llCos(angle); //calculate z position //llOwnerSay((string)radius + " " + (string)angle); //llOwnerSay ((string)seatX + " " + (string)seatZ); list params = [PRIM_POSITION, <seatX, basePos.y, seatZ>]; llSetLinkPrimitiveParamsFast(LINK_THIS, params); } If someone knows of any resources to where I could learn about the math involved in what I am trying to do I would highly appreciate it. I've tried to look into sin, cos, tan and that helped with understanding the equations of the flat position but I'm not grasping the addition of a 3rd point.
  11. No, I actually thought I removed all of rotStep from the script I posted here. In the end I do plan to flip between the values because Im using llTargetOmega and just want to change the direction once speed reaches 0. Right now I'm just trying to get the speed to go down to 0 when the opposite direction is pressed but the script won't even run properly. I'm applying everything as llTargetOmega(<0,0, rotStep>, PI/180*spinRate, spinRate); if that explains my intentions any better.
  12. My script is not running as expected. The script is supposed to let a user control the spin of an object upon sit. You hold left or right and speed is added in the appropriate direction. If you switch directions the spin slows down and then switches the direction upon hitting zero. Speed is then added again and the object spins in the opposite direction. Although right now my script seems to be jumping to the "if else" and "else" statements. The script will only spin right, even if left is pressed first. The script will also only add speed while never subtracting speed no matter what button is pressed. I'm not to worried about switching directions right now; I am just working on getting the spin to slow down properly. I couldn't find any good information on how to use if statements in a control, I thought I set it up properly but it's late and I might have missed something. Would anyone mind taking a look at the control section of my script and seeing if there is anything apparently missing to cause the script to act like parts are being skipped? I appreciate any help; Thanks! float spinRateAdjust = 1; float spinRate = 0; float rotStep = 1; integer left = FALSE; integer right = FALSE; control(key id, integer held, integer pressed) { if (held && (CONTROL_ROT_LEFT)) //Spin Left { if (spinRate > 0 && right == TRUE) // Slow down when switching directions. { //llOwnerSay("Spinning Left"); //spinRate -= spinRateAdjust; if (spinRate <= 0) { rotStep = 0 - rotStep; right = FALSE; left = TRUE; } } else //Apply Spin { left = TRUE; spin(); } } else if (held && (CONTROL_ROT_RIGHT)) //Spin Right { if (spinRate > 0 && left == TRUE) // Slow down when switching directions. { //llOwnerSay("Spinning Right"); //spinRate -= spinRateAdjust; if (spinRate <= 0) { rotStep = 0 + rotStep; left = FALSE; right = TRUE; } } else //Apply Spin { right = TRUE; spin(); } } }
  13. I want to say thanks to everyone who has helped me. I got the ride to work thanks to you guys, was way over my head but I now understand. Profaitchikenz and his equations for getting the center axis really helped. I changed things up a bit compared to his examples but these are my results. Everything runs off of the center beam, getting location and z.angle every tick. This way you can move the ride while it is spinning and the seating will snap to it's relative location, within 100 meters. The script in the seating grabs it's own location based off of it's name. Gif is too large to show here: https://i.gyazo.com/aa0abab4d51f1b939b91f7712a644fb1.gif I'd really show my scripts but I kind of want to keep my edits a secret for now since the project isn't even released yet. If someone really wants to see they can IM me inworld and I would be glad to show. Although a solution was already given and it works great. Thanks again everyone!
  14. @irihapeti This is because the avatar acts as a prim in itself so it will not inhernetly rotate with the child prim seats. I cannot figure out how to give it an offset rotation to follow the child prims axis. @ Profaitchikenz Haiku What do you mean by "lookup table"? I think I've been trying to do something similar except instead of a lookup table, if I understand at all, I've been trying to use an offset axis to have the seat rotate around the base and then have the seat object rotate itself. Although I haven't been able to get the object to rotate around it's own center and the center of the base. It does some odd things when I have two rotations. The offset axis is set by the seats rotation so if I have the seat rotating on it's own then the offset axis is constantly changing positions which is not intended. The script I was using for the offset axis is: default{ touch_start(integer num_detected) { llSetTimerEvent(.01); } timer() { vector vPosOffset = <1.0, 0.0, 0.0>; rotation vRotArc = llEuler2Rot( <0.0, 0.0, 5.0> * DEG_TO_RAD ); //vPosOffset = vPosOffset * vRotArc; llSetPrimitiveParams( [PRIM_POSITION, llGetPos() + (vPosOffset - vPosOffset * vRotArc) * llGetRot(), PRIM_ROTATION, vRotArc * llGetRot()] ); }} I would actually like to get the ride working with, the way you suggested and my original question, the seats being a different object. Doing so would make creation easier in the long run and allow me to use the knowledge in other rides. Except I don't know how to get a root axis rotation to work alongside an offset axis. Your suggestion seems different though using a lookup table I just do not know what a lookup table is.
  15. If I understand your question correctly then no. The yellow seats are attached to flat bars that you can see running towards the underside. Found a video where the image is from. You can see the rotation for yourself if you want.
  16. I did use local rotation in my tests. I just found a weird outcome, using local. The offset axis for a child prim works perfectly fine if the root prim is at a 90 degree interval. As soon as the root prim is at a different angle, even if the root prim is static, the child prim does not spin properly. Using the same code as I did above. default{ touch_start(integer num_detected) { llSetTimerEvent(.01); } timer() { vector vPosOffset = <1.0, 0.0, 0.0>; rotation vRotArc = llEuler2Rot( <0.0, 0.0, 5.0> * DEG_TO_RAD ); list params = llGetLinkPrimitiveParams(2, [PRIM_POS_LOCAL,PRIM_ROT_LOCAL ]); vector childPos = llList2Vector(params,0); rotation childRot = llList2Rot(params,1); vPosOffset = vPosOffset * vRotArc; llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, childPos + (vPosOffset - vPosOffset * vRotArc) * childRot * llGetRot() ,PRIM_ROTATION, vRotArc * childRot * llGetRot()]); }} I would think the child prim would still be able to calculate the same offset axis no matter what the root prim is at. Is this an issue with SL rotation or my program? I don't know anymore at this point.
  17. First, why does the avatar have to be offset from the centre of the seat? It's far simpler if they're not. Seems you got it from my image but to itterate the reason the sit has to be offset is because that is how the ride works. The ride has a base with 3 or 4 extended arms that hold a seat piece. The seat piece also has 3 or 4 arms each with seats on the end of those arms.Like my photo this is a real seat part of a scrambler which, as others have suggested I am making 1 mesh with the center being the pole:  I can't imagine it would be impossible to give a child prim an offset but so far none of my tests on child prims have worked. I don't know enough about rotations, even after reading the wiki, to know where to go next. The original plan I had, so that the avatar seating did not have to be moved, was to keep the seat part as a seperate object and rotate via an offset axis and then apply a second rotation on the original axis. Although the second rotation messes up the offset axis. I think that way might be a lot easier than figure out how to move all the sit positions. So basically an earth rotating around it's axis while also rotating around the sun, except in this case the earth is not a child prim. I could get the earth to rotate around the sun but I can not get the earth to rotate around it's own axis and the sun at the same time. May still run into the same problem since the sitting avatars will be child prims of the seperate object.
  18. This still comes back to the question, how can the avatar be rotated around the axis of the child prim instead of it's own axis? I've been reading the rotations page and trying to give an offset to a child prim, since the avatar acts like a prim, and it is not working very well. I've tried two methods so far on a two prim object. This method using llGetPos and llGetRot has no visible effect on the child prim. default{ touch_start(integer num_detected) { llSetTimerEvent(.01); } timer() { vector vPosOffset = <1.0, 0.0, 0.0>; rotation vRotArc = llEuler2Rot( <0.0, 0.0, 5.0> * DEG_TO_RAD ); list params = llGetLinkPrimitiveParams(2, [PRIM_POSITION,PRIM_ROTATION ]); vector childPos = llList2Vector(params,0); rotation childRot = llList2Rot(params,1); vPosOffset = vPosOffset * vRotArc; llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, llGetPos() + (vPosOffset - vPosOffset * vRotArc) * llGetRot() ,PRIM_ROTATION, vRotArc * llGetRot()]); }} Using the local position and rotation of the child prim has results but nothing at all useable. It's just glitchy movements around a non-offset axis. default{ touch_start(integer num_detected) { llSetTimerEvent(.01); } timer() { vector vPosOffset = <1.0, 0.0, 0.0>; rotation vRotArc = llEuler2Rot( <0.0, 0.0, 5.0> * DEG_TO_RAD ); list params = llGetLinkPrimitiveParams(2, [PRIM_POS_LOCAL,PRIM_ROT_LOCAL ]); vector childPos = llList2Vector(params,0); rotation childRot = llList2Rot(params,1); vPosOffset = vPosOffset * vRotArc; llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, childPos + (vPosOffset - vPosOffset * vRotArc) * childRot ,PRIM_ROTATION, vRotArc * childRot]); }} Basically what I was trying to do is to get the avatar, to stay in the same spot relative to the red arm. The red arm spins relative to the center arms but the avatar, it does spin thanks thanks to Inulla, only spins on it's own axis. It won't spin on any offsets I give it. 
  19. Your script is pretty awesome. There is still one thing I can't figure out, an issue I ran into with my own scripts. The sitting avatar only rotates around it's own axis while also facing inward. It needs an offset axis to rotate with the seats. Imagine the solar system with a sun, earth, and moon. The moon; the avatar, rotates around the earth; seats, which rotates around the sun; root prim. How do you get the moon to rotate around the earth when they both have the same root prim? I guess my main issue is not understanding what is going on with the rotation when you multiply position by rotation, or when you multiply a rotation by another rotation. I mean I can get the offset to work, and get a prim to spin freely with the offset but I don't know what is actually happening to make it work. Anyone care to explain? I realize I have not actually read through the whole page on rotations and am going to do so before asking anymore questions.
  20. Thanks for the link to Hairy Hippo Park, I took a look. I'll see about looking into that but I am still hoping I can figure out something with offset rotation. There are some other rides I can think of where I may not be able to use llTargetomega; maybe they would still work but I need to test more. Although what do I look into to get the sit target to spin with the child prim? The main reason I moved to another sollution is because I didn't know what next step to take. Edit: I found another post talking about how to move a sit position with a child prim and the only way to do so is with llSetLinkPrimitiveParams but it confuses me. https://community.secondlife.com/t5/LSL-Scripting/Move-a-sitting-avatar-with-a-child-prim/td-p/1700527
  21. I saw about llTargetOmega. I did get the rotation to work in the way you suggested but I ran into a problem with sit positions not rotating with the child prim. i thought using offset rotation might be easier. I saw something about linking the movement between the child prim and the avatar but wasn't sure where to go with that. I'll have to look into that more. If anyone has a suggestion I would be more than willing to listen. Although if possible I would still like to figure out the way I'm trying now. Is there no way to go about rotation with an offset axis and speed up the script?
  22. I'm trying to create an amusment park ride, a scrambler. The ride has outer seats that spin locally while also spinning around a central axis. I figured out how to have an object spin around an offset axis, from the wiki, but I cannot figure out how to have a non-offset spin with the offset spin. I am currently setting the rotation through a tier using llSetPrimitiveParams. default { state_entry() { llSetTimerEvent(.01); } timer() { integer num; num +=20; if (num > 360) { num = 0; } rotation vRotArc = llEuler2Rot( <0.0, 0.0, num> * DEG_TO_RAD ); vector vPosOffset = <5.0, 0.0, 0.0>; llSetPrimitiveParams( [PRIM_POSITION, llGetPos() + (vPosOffset - vPosOffset * vRotArc) * llGetRot(), PRIM_ROTATION, vRotArc * llGetRot()]); } }Is it possible to have a second non-offset rotation alongside the offset rotation? How can I do so? Also is there a faster way then using llSetPrimitiveParams and a timer? With smooth movement it is quiet slow.
  23. I wasn't sure so I tested. The physics shape stays the same oddly enough. Although there is the problem with mesh physics, no matter the size, have a .05 or .1 gap between the edge of the physics shape and anything else. You can see below the physics shape is the same but the gap is there. Edit: Disregard. The only reason the physics shape stayed the same is because the Z size is above .2. If all sides are below .2 then the physics shape changes too a cube no matter prim or convex hull. Also for anyone curious, you can render physics shape in the developer menu -> render metadata -> physics shapes.
  24. So I've been doing a lot of work with physics for some projects and ran across what I consider to be an issue. Has anyone else ever noticed that when you make any dimension of a prim smaller than .2 the physics shape gets ignored and becomes a cube? In the example below the regular prim is a cylinder with the diameter being less than .2. the physics shape becomes a cube. A slightly larger cylinder is beside with the proper physics shape. I've been adding more prims to work around but is this normal? No matter what I search I cannot find information on this subject. Keep in mind these are regular prims with the physics shape set to prim.
  25. Your script suggestion worked! Thanks so very much! I like to know what's going on with the script so I can learn. Would you mind explaining what llGetVel() and llGetPos() are doing when added?
×
×
  • Create New...