Wandering Soulstar Posted June 3, 2013 Share Posted June 3, 2013 Hi All, I have been writing LSL for a few years now and feel that I am pretty comforatble in it, but recently have come across an area that I am a bit lost in. I know how to deal with normal prims in LSL but have recently begun using mesh and there are a few things I would like to understand how to to in LSL. Specifically I'd like to: 1) Understand what face of a Mesh was touched by an Avatar .. to be able to know what side of a door was touched.2) Change the textures on the different mesh faces Thanks in advance! Link to comment Share on other sites More sharing options...
Rolig Loon Posted June 3, 2013 Share Posted June 3, 2013 As far as LSL is concerned, a face is a face. It doesn't know whether your object is mesh or not (actually, ALL objects are mesh anyway). If you identify faces when you are creating the mesh object in Blender, your LSL script will recognize them. Link to comment Share on other sites More sharing options...
arton Rotaru Posted June 3, 2013 Share Posted June 3, 2013 Mesh is the same as a prim in this regard. llDetectedTouchFace(0) will return the face number as usual. Though, how many faces a mesh will have (maximum 8 faces) depends on how many materials/faces the creator has assigned to the mesh. So a mesh door can have only 1 face, or a mesh door can have up to 8 faces. Changing textures works the same as with any other prim as well. Link to comment Share on other sites More sharing options...
Dora Gustafson Posted June 3, 2013 Share Posted June 3, 2013 A mesh can have up to 8 materials Each material is equivalent to a face on a standard prim How the material layout is made, is determined when the mesh is created (in blender or whatever) To find out where the faces/materials are you can use this example script in the wiki :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
Wandering Soulstar Posted June 3, 2013 Author Share Posted June 3, 2013 Thanks for the answers .. guess I should have checked in code first. Sadly though this means that the functionality that I had before in the code, before I turned the door to Mesh will not longer work. Before, depending on the side if the door you touched it would swing one way or the other. Now though since the the Mesh was made with Mesh Studio, and the textures are the same, the face is the same as well <sigh>. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted June 3, 2013 Share Posted June 3, 2013 Don't give up hope yet. Assuming the mesh door is so constructed that, when I am standing on its own local positive x axis I'm in front of it, and when I'm standing on its own local negative x axis I'm behind it, and assuming you've offset the pivot point, then something like this should do it rotation z90;rotation whichRot;default{ state_entry() { z90 = llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD); } touch_end(integer total_number) { rotation myRot = llGetLocalRot(); vector myPos = llGetPos(); vector avPos = llDetectedPos(0); vector v = (avPos-myPos)/myRot; // llOwnerSay((string)v); if (v.x>0.0){ // in front of me llOwnerSay("in front"); whichRot = z90; } else{ //behind me llOwnerSay("behind"); whichRot = ZERO_ROTATION/z90; } llSetLocalRot(whichRot*myRot); state open; }}state open{ state_entry(){ llSetTimerEvent(5.0); } timer(){ whichRot=ZERO_ROTATION/whichRot; llSetLocalRot(whichRot*llGetLocalRot()); llSetTimerEvent(0.0); state default; } } If either of my assumptions are wrong, it will need a bit of tweaking -- feel free to pass me a mod version in world if that's the case, and I will see what I can do. Link to comment Share on other sites More sharing options...
LepreKhaun Posted June 4, 2013 Share Posted June 4, 2013 Wandering Soulstar wrote: Thanks for the answers .. guess I should have checked in code first. Sadly though this means that the functionality that I had before in the code, before I turned the door to Mesh will not longer work. Before, depending on the side if the door you touched it would swing one way or the other. Now though since the the Mesh was made with Mesh Studio, and the textures are the same, the face is the same as well <sigh>. For Mesh Studio, the answer is simple: Color each side of your prim prototype differently. This will give you two different material faces in your collada file, which are logically the same (in LSL) as different prim faces. Then, your only work is to find which face is which and adjust your code accordingly. One way to look at this is when you "Mesh it!" a simple plywood cube, you will not get the equivalent in the resulting mesh object- you end up with a cube having only one face. To get a cube with six faces, you must color (or texture) each face differently beforehand. Link to comment Share on other sites More sharing options...
Wandering Soulstar Posted June 4, 2013 Author Share Posted June 4, 2013 Innula - Thanks for the suggestion on coding, I'll give it a shot tonight LepreKhaun - Question, does doing your suggestion increase the LI? Link to comment Share on other sites More sharing options...
LepreKhaun Posted June 4, 2013 Share Posted June 4, 2013 Wandering Soulstar wrote: ... LepreKhaun - Question, does doing your suggestion increase the LI? Though adding material faces to your model does may* have a small impact on Download weight, I doubt it would be enough to affect your final Land Impact. One would have a model whose LI was not only being driven by Download weight (as opposed to Physics or Server weights) but as well as be on a cusp with the other Download factors (size and geometric complexity) for material faces to tip the scale. And, unless your door is extremely complex or overly large in its construction, it should be having its Land Impact set by the Server weight and should show as 0.5. *ETA there are some models (composed of disjoint planes) that adding material faces will not affect download weight whatsoever since the vertex count would remain the same. Link to comment Share on other sites More sharing options...
Wandering Soulstar Posted June 5, 2013 Author Share Posted June 5, 2013 Innula - The code worked great! Thanks! LepreKhaun - Thanks for the explination :-) Link to comment Share on other sites More sharing options...
Recommended Posts
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