Jump to content

Adjusting the Rotation Behavior of a Child Prim


Guest
 Share

You are about to reply to a thread that has been inactive for 4060 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

If I link a cone to a sphere and make the sphere the root prim and use this script (see script below) in that root prim, it makes the top part of the cone stay in one place (inside the small sphere) while the bottom part points at a nearby avatar.

default
{
    state_entry()
    {
        llSensorRepeat("", "", AGENT, 20.0, PI, 0.2);
    }
 
    sensor(integer total_number)
    {
        llLookAt( llDetectedPos(0) + <0.0, 0.0, 1.0>, 3.0, 1.0 );
    }
}

However, I want to get rid of the sphere.  I want to make the cone a child prim and link the cone to some other prims, and have all those prims stay in place while the bottom part of the cone points at some nearby avatar.  So I tried using this script (see script below).  However there is ONE problem with this new script.  Both ends of the cone (top and bottom) now move, because the cone is now rotating around the center of the cone, which is halfway between the top and bottom of the cone.  One way to fix this is to slice the cone in half.  However, using slice causes the top skinny part of the cone to become too wide.  I need the top part of the cone to be as narrow as possible.

default
{
    state_entry()
    {
        llSensorRepeat("", "", AGENT<, 20.0, PI, 0.2);
    }
 
    sensor(integer total_number)
    {
        vector p = llGetPos();
        llLookAt(p + (llDetectedPos(0) + <0.0, 0.0, 1.0> - p) / llGetRootRotation(), 3.0, 1.0);
    }
}

So looking at this script (see below script), I feel that I should be able to change something to cause the cone, which is the child prim, to point at a nearby avatar, but have the top part of the cone stay in one place while the bottom part moves.  I don't think I need to change this part "llLookAt(P + (llDetectedPos(0) + <0.0, 0.0, 1.0> - p)" (highlighted in blue) at all, because the vector p has something to do with the cone's position rather than it's rotation.  I think the part that I need to change is the "/ llGetRootRotation()" (highlighted in red).  What can I replace llGetRootRotation () with to get the top part of the cone to stay in one place while the bottom part of the cone moves around and points at a nearby avatar, with the cone as a child prim, and all other prims remaining in one place and not moving at all?

default
{
    state_entry()
    {
        llSensorRepeat("", "", AGENT, 20.0, PI, 0.2);
    }
 
    sensor(integer total_number)
    {
        vector p = llGetPos();
        llLookAt(p + (llDetectedPos(0) + <0.0, 0.0, 1.0> - p) / llGetRootRotation(), 3.0, 1.0); } }
Link to comment
Share on other sites


Scars Steerpike wrote:   [...] One way to fix this is to slice the cone in half.  However, using slice causes the top skinny part of the cone to become too wide.  I need the top part of the cone to be as narrow as possible.
[...]


So, why not decrease the diameter of the cone after you slice it, then?  If X = Y = 0.1; Z = 0.5; and Slice End = 0.5, you get a nice skinny pencil of a cone, and your script pivots it around the center of its base.

Link to comment
Share on other sites

Because I need the bottom part of the cone to be around > 2m (x and y) and for the height of the cone after it is sliced to be around 5-10m.  Using your dimensions completely changes the size of the spotlight.  I need the dimensions to remain the same.  The problem is after slicing, the new top part becomes the width of the former middle part of the cone, which is why I can't use slice.  Changing the width of the bottom part just to narrow the width of the middle and top parts is not the fix that I'm looking for.

Link to comment
Share on other sites

BTW, your script aims the pointy end of the cone at the av's head.  If you should want to keep the cone rotating in the horizontal plane for some reason, try this instead:

default{    state_entry()    {        llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, 20.0, PI, 0.2);    }     sensor(integer total_number)    {        vector p = llVecNorm(llGetPos() - llDetectedPos(0));        llSetLocalRot (llEuler2Rot(<0.0,-PI/2,0.0>)*llEuler2Rot(<0.0, 0.0, llAtan2(p.y, p.x)>));    }}

 

Link to comment
Share on other sites

I don't have any problems with the wide part of the spotlight pointing at the av's head.  In the first script that I posted, I used rotation x=180, y=0, and z=180 on the sphere (root prim) to get the desired result.  In the second (and third) scripts that I posted, I used negative taper on the cone to get the wide part facing the avatar at all times.  That's why I'm not sure what you are trying to say....

Link to comment
Share on other sites

Right now, I just want a prim that looks like a cone and behaves like a sliced cone, but I want the top part of the cone to be as narrow as possible.  So that means changing either the prim itself, or the script.  And that's why I highlighted part of the script in red, because I think that is what I need to change.

Link to comment
Share on other sites

No.  No.  That won't work.  Let me explain.  Lets say the unsliced cone is size x=2.0, y=2.0, z=10.  Since the top part of the unsliced cone is tapered at x=1.0 and y=1.0, the top part of the cone is equivalent of size x=0.0 and y=0.0, whereas the BOTTOM part of the unsliced cone is size x=2.0 and y=2.0.  Now let's take a sliced cone of size=2.0, y=2.0, and z=20.  The BOTTOM part of the sliced cone is STILL size x=2.0 and y=2.0.  The top part is what changed.  The top part of the sliced cone is now size x=1.0 and y=1.0 (basically the width of the halfway point of the unsliced cone).  You are suggesting that I change the sliced cone to size x=4.0 and y=4.0.  That would make the BOTTOM of the sliced cone twice as wide as I want, and also make the top of the sliced cone twice as wide as I want (half way between 4.0 and 0.0 is 2.0, whereas it was previously 1.0).  The only advice you gave that helped was making the size of z twice as long, but I had already done that.

Link to comment
Share on other sites

What would be nice would be a single prim that looks sorta like a non-hollow hourglass or rather an upside down cone on top of a rightside up cone... and being able to use slice so that the upside down cone part of the prim is gone leaving only the rightside up part of the prim.  That way, the narrow part of the hourglass would have the narrow width that I'm looking for and the center of rotation would be in the middle of the "hourglass".  I tried playing around with toruses, but I haven't had any luck yet.  That's why I'm hoping that this problem can also be solved by scripting.  I don't think using a torus is going to help since it doesn't have slice, only profile cut.

Link to comment
Share on other sites

Sorry.   We got caught in a flurry of asynchronous posts, with you responding to one of my older posts while I was posting a new one. 

I didn't understand the geometry of your project from your first post, so I was envisioning a pointer -- a cone with the pointy end to aim at the detected av.  If that had been the situation, then slicing the cone as I suggested would have solved your problem.  It never occurred to me that you are making a spotlight, so the whole thing needs to rotate around its pointy end and aim its wide end at the av.  Since that's the case, clearly slicing won't work.  You have two options: (1) create a mesh spotlight cone with its rotation center at its point or (2) modify your script to rotate a prim cone around its point -- which is what you have been asking, I now understand. <whew>

I will go sit in a corner and see if I can figure out how to do that, at least until Dora comes around with the answer.

Link to comment
Share on other sites

Yeah, I don't think this can be done with tortured prims (I already tried).  It has to be done by scripting, or as you said, mesh.  I really don't know the difference between sculpties and mesh.  Could I use a sculptie made in Blender?  I never sculpted before but I don't think it would be very difficult.  Why did you say mesh and not sculpties - does it make a difference which one I use?  Thank you for trying to help.  I really wish I could figure out the script solution, but I can't make any sense of anything on the http://wiki.secondlife.com/wiki/Rotation page.  (sighs)  Also, which script should I try modifying?  The second (and third) one that I posted which works in a child prim, or the one you tried to get me to use?  I think mine is better because it works just fine except that it rotates on the cone center instead of the cone tip (skinny part), but everthing else works wonderfully.

Link to comment
Share on other sites

There's little point in making sculpties these days.  They were a convenient hack until LL introduced mesh, but they are clumsy and harder to make than mesh, and they generally end up with a higher Land Impact.  If you're going the route of changing the object, make it mesh.  I'm sure that you can solve this as a scripting problem too.  I'm not sure that I would start with either of our scripts.  Basically, what you want to do is calculate the new rotation that points the cone at your target av and then offset the point of the cone to keep it at a fixed spot relative to llGetRootPosition().  If I can stay awake for a while longer, I'll see if I can do it.

Link to comment
Share on other sites

I am so freaking annoyed.  I tried creating a sculpt mesh in Blender for the first time.  I used a cylinder shape with 3 (Y) faces and 16 (X) faces.  I then closed all the vertices on both ends, because I didn't want to see the invisible inside of the sculpty.  I made the bottom the flat part of the cone, and I left the top part pointed.  It basically looked EXACTLY like a cone.  Then I followed the instructions on this video


to move the pivot point from the center of the cone to the top skinny pointed part of the cone.  I feel like I did everything correctly.  I then baked the mesh, saved it as a .tga, and uploaded it for free on the SL beta grid.  I created a sculpty prim, dragged this texture map in, and guess what?  The pivot point is still the center of the freaking cone instead of the pointed part.  I did all this for nothing!  I spent over 12 hours a day for the last three days and I can't freaking figure this out.

And Rolig, I received your mesh cone but I haven't rezzed it yet because I'm experiencing computer lag horrors and I'm working on this on an alt account and just don't feel like switching back and forth between my different accounts.  But I have a feeling that what you sent me isn't going to be of any help.  You know why?  You mentioned in an IM that the mesh cone you sent me was linked to a small cube at the tip of the cone.  I don't think it really matters if that cone is mesh or not, or whether the cube is a cube, sphere, or some other small shaped object.  Linking the cone point to any tiny root prim will cause the cone tip to stay in place while the cone bottom moves.  This is something that I already know and which I wrote about in my first paragraph of the first post.  ?????????????????????  Then in my second paragraph, I explained that I wanted do things differently (Please don't make me re-write that part.  I thought that I made it easy to understand what I was trying to do.).  :-(
Link to comment
Share on other sites

Nevermind, my bad.  I guess the mesh cone wasn't linked to a separate prim after all.  I can see that the pivot point looks right.  You definitely gave me something to work with.  The only problem is that while the pointed part of the cone stays in place, the flat bottom part of the cone points the opposite direction of the avatar.  It's like a gag.  Like the avatar is so ugly the spotlight has to point as far away as possible.  LOL.  Maybe if I change some values, it will work right.  Anyway thank you, this is definitely a huge step in the right direction.

Link to comment
Share on other sites

Yeah I didn't see the mesh cube you were talking about until just now, because it is so far from the cone tip.  The mesh cube is what is pointing at the avatar now when I use the llLookAt function.  The pivot point is right, but I wanted the cone bottom to point at the avatar, not the mesh cube part.  I need to get some sleep soon.  I'm tired.  Hopefully I can figure this out later today.  Thanks for your help so far.

Link to comment
Share on other sites

Okay Rolig, I'll try that.  It's funny cuz I tried

llLookAt( p - (llDetectedPos(0) - <0.0, 0.0, 1.0> + p) / llGetRootRotation(), 3.0, 1.0 );

and

llLookAt( p - (llDetectedPos(0) + <0.0, 0.0, -1.0> + p) / llGetRootRotation(), 3.0, 1.0 );

but I didn't think to try

llLookAt( p - (llDetectedPos(0) + <0.0, 0.0, 1.0> - p) / llGetRootRotation(), 3.0, 1.0 );

LOL.  My power has been off and on (mostly off) since 11pm CST yesterday.  So hopefully it will stay on this time.  Thanks for your help.

Link to comment
Share on other sites

Rolig, btw can you tell me what program and what method you used to create your mesh cone (with the mesh box on one end)?  I might know how to do it in Blender now (was thinking about it while laying in bed a few hours ago, might just need to hide some faces and/or vertices in between the mesh cube part and the cone part), but my cone doesn't come out looking nearly as smooth as yours did, and I'm not sure if the way I'm doing it is the best way.  Thanks.

Link to comment
Share on other sites

This is really a mesh question, not a scripting one, but since we're wrapping up this thread ..... Use Blender.

1. Add a mesh cone with 32 faces.  Set radius to 1.0 and depth (height) to 10.0.

2. Add a Solidify modifier, give it some arbitrary width, then change to Object mode and apply it

3. Still in Object mode, set your focus at the tip of the cone and add a mesh cube.

4. Shrink the cube to an appropriately small size and then move it 10 units along Z (GZ10).

5,.Join the cube to the cone.

6. Still in Object mode, Smooth the model.

7. Select only the cone.  Then create and apply a Material to that face.

8. Do the same with the cube.

9. Unwrap the model.  The Smart Unwrap option works well for this one.

10. Rearrange the islands on the UV map so that the pointy ends of the cone segments all point the same way (to make it easier to texture later).

11. Save and export as Collada.dae.

12. With the mesh importer in SL, set the number of vertices for the Low and Lowest LOD to zero.  Then use the Lowest LOD model as your physics model.  That will get you the lowest L.I. when it's uploaded.

13. Rez the imported model. Set its Physics Type (in Features) to Prim, so that it is phantom.

14. Apply a transparent texture to the cube and a graded alpha texture to the cone.

15. Applaud.

  • Like 1
Link to comment
Share on other sites

While you are in Object mode, select both objects (the cube and the cone) and click the Join button, which should be visible on your T display.

Oh,  I just realized that I left out one non-vital but aesthetically important step (2a, maybe?),  In Edit mode, select the bottom edge loop on both the inner and outer cone that you created with the Solidify modifier.  Then mesh >> edges >> Bridge Edge Loops. That will create the faces along the thin edge between the inner and outer cones.

If you have done everything correctly, the face normals should all point the right way.  I didn't bother to say, but I'm obsessive enough that I always check those before exporting a model anyway.

  • Like 1
Link to comment
Share on other sites

I'm going to wait a while before I try to reproduce all of your steps, and hopefully I will succeed.  If I have any more questions about this, I'll direct my questions to you on the Mesh forum .  Is there any chance that I can add you as a friend?  If you don't have time for friends, I'll understand.  I'm pretty much the same way... Let me know, or if you want to be my friend just go ahead and send a friend request.  Thanks.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4060 days.

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
 Share

×
×
  • Create New...