//*************************************************************** // Copyright 2008 Centre For Advanced Spatial Analysis, UCL // // Author: Joel Dearden, University College London // // Contact: j.dearden@ucl.ac.uk // // Joel Dearden, // Centre for Advanced Spatial Analysis, // University College London, // 1-19 Torrington Place, // London, // WC1E 7HB // // // This file is part of SLSegregationModel. // // SLSegregationModel is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // SLSegregationModel is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with SLSegregationModel. If not, see . // //*************************************************************** integer talkToLineSegments = -88821; integer positioned = FALSE; vector lineColour = <0,0,1>; fitLine(vector previousPosition) { llOwnerSay("fitline"); vector currentPosition = llGetPos(); //Put the matchstick centre at the midpoint of the line connecting the previous and current positions. vector midpoint = (currentPosition + previousPosition) / 2; llOwnerSay("midpoint=" + (string)midpoint); llSetPos(midpoint); //Rotate it so that the local z-axis matches the vector from the previous to the current position llLookAt(currentPosition, 1, 0); llStopLookAt(); //Set the z-scale to match the distance from the previous to the current position. float requiredLength = llVecDist(previousPosition, currentPosition); vector newScale = llGetScale(); newScale.z = requiredLength; llSetScale(newScale); llOwnerSay("newScale=" + (string)newScale); //set correct colour and glow llSetColor(lineColour, ALL_SIDES); llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, 1.0]); } default { state_entry() { //listen for clear messages llListen(talkToLineSegments, "", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { llOwnerSay("got message:" + message); if(channel == talkToLineSegments) { if(positioned == FALSE) { if(lineColour == <1,0,0>) { //red if(llGetSubString(message, 0, 3) == "prp:") { //previous position message vector previousPosition = (vector) llGetSubString(message, 4, -1); positioned = TRUE; fitLine(previousPosition); } } else { //blue if(llGetSubString(message, 0, 3) == "pbp:") { //previous position message vector previousPosition = (vector) llGetSubString(message, 4, -1); positioned = TRUE; fitLine(previousPosition); } } } if(message == "die") { llDie(); } } } }