Airfield
Got a problem with my airfield. Basically its a forcefield but instead of being vertical its horizontal and the centre of the platform is the centre of the emitter(but 8m above it).
The problem I am having is the location of the forcefield in comparison with the emitter is different depending on wether I look north, south, east or west. This is the code for that;
This is the standard forcefield orientation code I have which aligns it in the middle of the emitter when vertical;
Does anyone know the code so I can orientate the forcefield platform centred over the emitter whichever direction I look? If so could you also explain it.
The problem I am having is the location of the forcefield in comparison with the emitter is different depending on wether I look north, south, east or west. This is the code for that;
function SmallForceFieldDeployableImage::onDeploy(%item, %plyr, %slot) { $team = %plyr.client.team; $owner = %plyr.client; %xform = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm); %rot = %item.rotation; %fBase = 3.00; // this constant is 1/2 forcefield width on the x-coordinate (i.e. %fBase = 4.0, forcefield width = 8.0) %dis = 1.22; // this constant is distance from deployed to forcefield %deplTrf = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm); %plyrPos = (getWord(%deplTrf, 0)) @ " " @ (getWord(%deplTrf, 1)) @ " " @ (getWord(%deplTrf, 2)); // X(east), Y, Z -sb $deplRot = %plyr.rotation; if(getWord(%plyr.rotation,2) == -1) %angle = 3.1415 / (180.0 / (360.0 - (getWord(%plyr.rotation,3)))); else %angle = 3.1415 / (180.0 / getWord(%plyr.rotation,3)); %alpha = %dis / (180 / (3.1415 /mTan(%fBase))); // [(%dis) is deployed to forcefield distance] ; [(%fBase) is length of forcefield x-axis] %theta = 180.0 - (90.0 + %alpha); // [(%theta) is angle to forcefield origin (x,y) coordinates from players view angle] %rTheta = 3.1415 / (180.0 / %theta); // [convert (%theta) to radians] %vecA = %fBase / mCos(%alpha); // [vector length from deployed to forcefield origin (x,y) coordinates] %xAdd = -6.000; %yAdd = -6.000; %zAdd = 1.000; %vSum = (%xAdd @ " " @ %yAdd @ " " @ %zAdd); $deplPos = VectorAdd(%plyrPos, %vSum); %obj.shield = Parent::onDeploy(%item, %plyr, %slot); return %obj.shield; }
This is the standard forcefield orientation code I have which aligns it in the middle of the emitter when vertical;
function SmallForceFieldDeployableImage::onDeploy(%item, %plyr, %slot) { $team = %plyr.client.team; $owner = %plyr.client; %xform = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm); %rot = %item.rotation; %fBase = 3.00; // this constant is 1/2 forcefield width on the x-coordinate (i.e. %fBase = 4.0, forcefield width = 8.0) %dis = 1.22; // this constant is distance from deployed to forcefield %deplTrf = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm); %plyrPos = (getWord(%deplTrf, 0)) @ " " @ (getWord(%deplTrf, 1)) @ " " @ (getWord(%deplTrf, 2)); // X(east), Y, Z -sb $deplRot = %plyr.rotation; if(getWord(%plyr.rotation,2) == -1) %angle = 3.1415 / (180.0 / (360.0 - (getWord(%plyr.rotation,3)))); else %angle = 3.1415 / (180.0 / getWord(%plyr.rotation,3)); %alpha = %dis / (180 / (3.1415 /mTan(%fBase))); // [(%dis) is deployed to forcefield distance] ; [(%fBase) is length of forcefield x-axis] %theta = 180.0 - (90.0 + %alpha); // [(%theta) is angle to forcefield origin (x,y) coordinates from players view angle] %rTheta = 3.1415 / (180.0 / %theta); // [convert (%theta) to radians] %vecA = %fBase / mCos(%alpha); // [vector length from deployed to forcefield origin (x,y) coordinates] %xAdd = %vecA * mSin(%angle - %rTheta); %yAdd = (%vecA * mCos(%angle - %rTheta))-0.100; %zAdd = 1.000; %vSum = (%xAdd @ " " @ %yAdd @ " " @ %zAdd); $deplPos = VectorAdd(%plyrPos, %vSum); %obj.shield = Parent::onDeploy(%item, %plyr, %slot); return %obj.shield; }
Does anyone know the code so I can orientate the forcefield platform centred over the emitter whichever direction I look? If so could you also explain it.
Comments
Plus, I think I might need to fidget around with it myself to see what's wrong and how to fix it, but only if you're willing. Personally, I'm much more "liberal" when it comes to software and information, as I've seen open source projects develop much better and last MUCH longer than anything proprietary or hidden, but that's not up to me.
When I get back off hol (go in a few hours) I will see about making the source available. But the reason I am holding off is because it will mean we have unique items. Will think more when I am outta holiday mood :P
I'll try to improvise by temp adding it to Classic mod and editing it there.
Your positioning and rotation code is all wrong for 3D space, by the way. What you're doing might be sufficient for a 2D game, but you'll need to compute a proper 3D rotation here.
But I will give full code if I ever leave(also pass the buck of taking over the developement to someone else) and I will give full code to anyone who wants to help me with this. I will however limit the coders though too many will get too messy.