Peridot Nightingale Posted April 21, 2018 Share Posted April 21, 2018 I want to make a prim eyeball that consists of 2 prims.. the pupil, and the iris/sclera combined.. I want to make it so that based on the time of day, the pupil dilates/contracts, Being fully dilated at midnight in world. I'm going to be using two spheres. The pupil prim will be dimpled so that it looks like a cone, all I want to know is how to change the dimple based on time of day. :3 Thanks Link to comment Share on other sites More sharing options...
Xiija Posted April 21, 2018 Share Posted April 21, 2018 vector sun = llGetSunDirection(); if (sun.z < 0) {// night} Link to comment Share on other sites More sharing options...
Fluffy Sharkfin Posted April 21, 2018 Share Posted April 21, 2018 You could probably do it using llGetSunDirection and llSetLinkPrimitiveParamsFast. Of course if you want it to be really realistic, you could also take into account the direction the avatar is facing using llGetLocalRot so that the pupils dilate when the avatar is facing away from the sun and contract when facing towards it. 1 Link to comment Share on other sites More sharing options...
Peridot Nightingale Posted April 21, 2018 Author Share Posted April 21, 2018 1 hour ago, Fluffy Sharkfin said: You could probably do it using llGetSunDirection and llSetLinkPrimitiveParamsFast. Of course if you want it to be really realistic, you could also take into account the direction the avatar is facing using llGetLocalRot so that the pupils dilate when the avatar is facing away from the sun and contract when facing towards it. May I see an example? I can fill in the blanks from there... I'm not really that good at WRITING scripts from scratch.. to be honest. Link to comment Share on other sites More sharing options...
Xiija Posted April 22, 2018 Share Posted April 22, 2018 (edited) example snippet, rez a sphere and drop in, then touch? you can make a variable called "dimple" and do.... vector sun = llGetSunDirection(); if (sun.z < 0) {dimple = night_dimple;} and make the SLPPF call .... [PRIM_TYPE , PRIM_TYPE_SPHERE, PRIM_HOLE_CIRCLE, <0,1,0>, 0.0,<0,0,0>, dimple]); vector night_dimple = <0.88, 1.0, 0.0>; vector day_dimple = <0.98, 1.0, 0.0>; default { state_entry() { llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_TYPE , PRIM_TYPE_SPHERE, PRIM_HOLE_CIRCLE, <0,1,0>, 0.0,<0,0,0>, day_dimple]); } touch_start(integer total_number) { llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_TYPE , PRIM_TYPE_SPHERE, PRIM_HOLE_CIRCLE, <0,1,0>, 0.0,<0,0,0>, night_dimple]); } } Edited April 22, 2018 by Xiija 1 Link to comment Share on other sites More sharing options...
Berksey Posted April 22, 2018 Share Posted April 22, 2018 This is a neato thread. I'd probably cheap out and use one object and just have it change textures, but I like other people's solutions better.. Link to comment Share on other sites More sharing options...
Fionalein Posted April 22, 2018 Share Posted April 22, 2018 26 minutes ago, Berksey said: This is a neato thread. I'd probably cheap out and use one object and just have it change textures, but I like other people's solutions better.. Texture change will have slow greyed out phases... texture shifts would do the trick (combine multiple low rezolution eye textures to a big tileset and quickly switch what section of the combined texture you display...) Link to comment Share on other sites More sharing options...
Fluffy Sharkfin Posted April 22, 2018 Share Posted April 22, 2018 21 minutes ago, Fionalein said: Texture change will have slow greyed out phases... texture shifts would do the trick (combine multiple low rezolution eye textures to a big tileset and quickly switch what section of the combined texture you display...) Another approach would be to use two spheres, one slightly larger than the other, with a black 32-bit texture on the outer sphere (with a small strip at the top of the image being opaque and the rest being transparent), and the iris and sclera (the white part of the eye) on a separate texture on the inner sphere. Due to the way spheres are UV mapped adding the black texture with alpha channel to the outer sphere will create a black spherical cap, the size of which can be controlled by altering the vertical offset of the texture (or by using llSetLinkTextureAnim). Link to comment Share on other sites More sharing options...
Peridot Nightingale Posted April 22, 2018 Author Share Posted April 22, 2018 will the above methods allow for a smooth transition from the day state to the night state? I don't want the pupil of the eye to "snap" from daytime to nighttime states. that's not realistic Link to comment Share on other sites More sharing options...
Fionalein Posted April 23, 2018 Share Posted April 23, 2018 (edited) None of the methods above are smooth in the most simple implementation, you will have to add intermediate steps for them and animate through those to make it a smooth appearance Edited April 23, 2018 by Fionalein Link to comment Share on other sites More sharing options...
Peridot Nightingale Posted April 23, 2018 Author Share Posted April 23, 2018 Alright I am still kinda stuck... So I DO want to use the llGetSunDirection thing... but now I want to use texture offset to control the pupil size... but I have no idea how to make it so that there's multiple frames in my texture animation... (more than 2) I kinda wanna split the animation into 7 frames... where the last frame is fully contracted, the first one is fully dilated, and all the rest are in between. I want to be able to Ping pong the animation based on the SL time. so at dawn, the pupil will start to contract... going through all 7 frames until it hits noon, then going backwards, slowly dilating as it gets darker.... The thing is I cannot wrap my head around scripting very well... and a simple push in the right direction will help a lot. I need a script to combine texture animatons with llGetSunDirection in some way and I can modify it from there, adding all my frames and such... sorry If I am being bothersome. Link to comment Share on other sites More sharing options...
Fluffy Sharkfin Posted April 24, 2018 Share Posted April 24, 2018 4 minutes ago, Techwolf77 said: I want to be able to Ping pong the animation based on the SL time. so at dawn, the pupil will start to contract... going through all 7 frames until it hits noon, then going backwards, slowly dilating as it gets darker.... If you're thinking of using llSetTextureAnim then you may want to reconsider, since it's a client-side effect it's impossible to keep it synced with SL sun position. Each new avatar you meet will see the animation from the beginning, rather than at the stage it should be at based on current sun position (as well as the texture animation restarting at odd times, like when you enter a new sim). It would be useful for fast, smooth transitions between pupil states but really won't work for long, slow transitions. You're much better off using llSetPrimitiveParamsFast to change the texture offset. As for an example script there are plenty of them on the wiki pages I linked to earlier in this thread which should help you understand the usage for each function, but the general idea is to start a timer running in your state_entry event using llSetTimerEvent, then in the timer event check the sun position and update the pupil size accordingly. Personally I'd opt for using a very slow timer (since the effect you're trying to create is extremely subtle and most likely the only person that's going to be staring into your eyes long and hard enough to notice it is you it would be a poor use of sim resources to have a fast timer updating them constantly), and possibly detecting region/parcel change and updating the pupil size for those to accommodate custom windlight settings. 1 Link to comment Share on other sites More sharing options...
Xiija Posted April 24, 2018 Share Posted April 24, 2018 (edited) Here is an example of using sun direction to change a texture. This particular snippet will only work during the "day". just rez a box, and drop in the script, then touch the box. The number texture is from LL, you can see how using offsets changes it. the list - "nums" ... is a key / value list, ..."1" has an offset value of -0.45 , etc etc vector repeats = <0.05, 1.0, 0.0>; vector offsets = < -0.45, 0.0, 0.0>; integer face = 0; float set; string numbers_Texture = "a93f7b84-8edf-b465-b3c8-207986881d78"; string transparent_Texture = "5c50e129-0b07-3834-0748-f1df74234a65"; list nums = ["1",-0.45,"2",-0.35,"3",-0.25,"4",-0.15,"5",-0.05,"6",0.05,"7",0.15,"8",0.25,"9",0.35,"0",0.45 ]; default { state_entry() { set = llList2Float(nums,1); llSetLinkPrimitiveParams( LINK_THIS, [ PRIM_TEXTURE,face ,transparent_Texture, repeats, < set, 0.0, 0.0>, 0.0 ]); } touch_start(integer total_number) { vector sun = llGetSunDirection(); integer Z = (integer) llFloor( sun.z * 10); string sunZ = (string)Z; llOwnerSay("Sun z is... " + sunZ); integer index = llListFindList(nums, [sunZ]); integer indx = index + 1; set = llList2Float(nums,indx); llSetLinkPrimitiveParams( LINK_THIS, [ PRIM_TEXTURE, face ,numbers_Texture, repeats, < set, 0.0, 0.0>, 0.0 ]); } } Edited April 24, 2018 by Xiija 1 Link to comment Share on other sites More sharing options...
Peridot Nightingale Posted April 24, 2018 Author Share Posted April 24, 2018 Thanks you two. I'm going to try and combine Xiija's script with a slow timer and see if I can manage on my own.. I'll keep you posted if my script has errors I cannot fix.. I guess I will try to fill in the Night time portion by myself as well. 1 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