|
Domneth Dingson
Registered User
Join date: 20 Nov 2006
Posts: 126
|
04-27-2007 11:09
I've a project I'm working on that I'd like to be as simple as possible. On touch, objectONE rezzes objectTWO based on the rotation and position of objectONE. I tried the following command: llRezObject("objectTWO", llGetLocalPos() + <0,0,1.5>, ZERO_VECTOR,llGetRot(), 0);
The rotation meshes up fine, but the position of objectTWO isn't locally basing itself off of the position of objectONE - it seems to still be globally positioning itself. I thought that using llGetLocalPos() would make objectTWO rez accordingly but it didn't...apparently it's only for finding the position of child prims. Is there a simple solution to this, or shall I simply make objectTWO 'move' into position after rezzing? I'd much prefer to have objectTWO rez right in place.
|
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
04-27-2007 11:14
Try llGetPos instead. llRezObject is expeting region coords, llGetPos returns region coords.
|
|
Domneth Dingson
Registered User
Join date: 20 Nov 2006
Posts: 126
|
04-27-2007 11:19
From: Sys Slade Try llGetPos instead. llRezObject is expeting region coords, llGetPos returns region coords. It really had the same result, but yes, I have changed the code to that instead since it's what actually should be used. Edit: actually, the following was what I needed. llRezObject("test object", <0,0,1> * llGetRot() + llGetLocalPos(), ZERO_VECTOR,llGetRot(), 0);
I'm not exactly sure on how the math works, but it does what I needed it to do.
|
|
Kaishi Axon
Registered User
Join date: 1 Nov 2005
Posts: 1
|
04-28-2007 14:20
I'm working on something similar to this, but there is a pretty important extra step to what I'm trying to accomplish. I want to have the first object, the one that rezzes the second, rotate and change elevation after each time it rezzes the second object. This is becoming a huge problem for me. It might have to do with the construction of the second object, or of my method, but I'm really frustrated. // Spawn - Author: Kaishi Axon //------------------------------------------------------------------------- // This script Rezzes an object at a given rotation and Localized position. It it actiaved on Touch. It is intended for use in the spire. //------------------------------------------------------------------------- // Constants //Angular variables (Express in Degrees) float x = 90; float y = 0; float z = 0;
vector Central_Position; // Function - Conversion // This Function takes 3 floats, which should be angular measures expressed in Decimal Degrees. It converts Degrees to Radians, then converts the three floats into a single rotation. It then returns this rotation. rotation Conversion(float x_deg, float y_deg, float z_deg) { // Conversion float x_rad = x_deg * DEG_TO_RAD; float y_rad = y_deg * DEG_TO_RAD; float z_rad = z_deg * DEG_TO_RAD; rotation Rot_Angle = llEuler2Rot(<x_rad, y_rad, z_rad>); return(Rot_Angle); }
rotation getRotToPointAxisAt(vector axis, vector target) { return llGetRot() * llRotBetween(axis * llGetRot(), target - llGetPos()); }
default { state_entry() { Central_Position = llGetPos(); } touch_start(integer total_number) { // Constants vector H_Correction = <0,6,0>; // H_Correction - used to express the horizontal difference between the central point and the optimal location of a section of the spire. // Functions vector Corrected = llGetPos() + H_Correction; // rotation Angle = (llGetRot() * Conversion(x,y,z));
// Set this axis to be the LOCAL direction you want your prim to point towards the center. // So if you had a cone and wanted the top of the cone to point towards something, you would use <0,0,1>. vector AXIS = <0,1,0>; vector TARGET = <Central_Position.x, Central_Position.y, Corrected.z>; rotation Angle = getRotToPointAxisAt(AXIS,TARGET); llRezObject("Room",Corrected,ZERO_VECTOR,Angle,0); // Name, Location, Velocity, Rotation llSetPos(llGetPos()+<0,0,1>); llSetRot(llEuler2Rot(llRot2Euler(llGetRot()) + <0,0,PI/3>)); } }
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
<0,0,1> * llGetRot()
04-28-2007 23:13
This snippet says to take a vector that points one meter up (Z-axis) relative to the object, and then convert it to a vector in world coordinates.
|