Ok, quaternions...
In the documentation on the wiki there is the example for a rotation with two subentities at 120° +/-. I work on a three point system of leading a ship slowly unto the position of another entity with a very slow pace (to avoid collision warning before the very near point is reached). This is what I have, with rotationBy as the example rotations, because it is three sided, for the vector that is the vector on wich the ship closes in:
How do I scan an array and delete each element that has a particular value? I was thinking I could just use a for loop, but that's nonsense because as soon as an element gets deleted the array changes length.
Here the fifth element of each sub-array is its category:-
Games use quaternions because this is the fastest way to calculate 3D movements. When you want to do movements, you start with calculating the movement quaternion: That do you by taking the identity quaternion [1,0,0,0] and rotate is according to the axes you need. Than you have the quaternion with the rotation and multiply that with the old ships quaternion.
e.g.
q = new Quaternion(1,0,0,0)
q = q.rotateZ(rol*Δt);
q = q.rotateX(pitch*Δt);
ship.orientation = ship.orientation.multiply(q);
(I am not sure about the multiplying order in the last line. It could be the other way round. It is a long time ago I wrote a test script doing it this way and I can't find it anymore)
In here Δt is the time parameter, assuming you do it in frameCallbacks.
Last edited by Eric Walch on Wed Mar 06, 2013 4:10 pm, edited 1 time in total.
How do I scan an array and delete each element that has a particular value? I was thinking I could just use a for loop, but that's nonsense because as soon as an element gets deleted the array changes length.
Games use quaternions because this is the fastest way to calculate 3D movements. When you want to do movements, you start with calculating the movement quaternion: That do you by taking the identity quaternion [1,0,0,0] and rotate is according to the axes you need. Than you have the quaternion with the rotation and multiply that with the old ships quaternion.
e.g.
q = new Quaternion(1,0,0,0)
q = q.rotateZ(rol*Δt);
q = q.rotateX(pitch*Δt);
ship.orientation = ship.orientation.multiply(q);
(I am not sure about the multiplying order in the last line. It could be the other way round. It is a long time ago I wrote a test script doing it this way and I can't find it anymore)
In here Δt is the time parameter, assuming you do it in frameCallbacks.
Ok... this sounds like I can understand it, eventually. Oh, and I probably have to because visualEffects can't be AIed.
But the actual problem is really more a Vector3D question, in wich rotateBy uses a Quaternion to specify the rotation.
I need the vectorUp rotated by 120° (and 240° or -120°) around the z-axis of the ship that it's originates from, but it's in another ship's script.
The chosenWagon is the origin of the vectorUp. So, it has to be turned around the vectorForward (or heading) of that ship, and I thought this would be done by the same quaternion as in the subentities example on the wiki. Obviously this doesn't work. Maybe because I have to work that z-axis to be turned around somehow in? I really don't know, how...
The wiki tells all. The value is a bitmask of the four facings and whether they are available or not.
The other bits in shipdata are the weapon positions on the model-is where the beam comes from when that weapon fires. But yes the weapon_facings setting in the shipdata does seem a bit odd and is being ignored for some reason, maybe being overridden by having the position entire in there.
I'm getting a reading 15 from Orbital Shuttle and Buoy (amongst others). Is this property in use yet and what does it actually tell?
I'm am a bit confused as Orbital Shuttle's shipdata says:
Do you have any replacement shipsets installed? If so, I don't believe any of those have yet been updated to include the weapon_facings parameter, so they'll be overriding the core shipdata, not specifying it, and it'll default back to 15.
This probably means, that before the most popular shipsets are updated, it's not advisable to rely on this property.
Well, that and we're never going to be in a position where every miscellaneous ship OXP has it set even if they should. Before 1.77 every NPC ship had a value of 15 (and the property was implicit). Now almost every ship still has a value of 15, but some of them don't. It's one of those things that will gradually get better over time, but it's still at least slightly useful now.
Quick AI script question:
Does "setTargetToRandomStation" choose the main station as well?
Because I never encountered it in my tests, and that were many tests...
EDIT: ...and, connected to the first question can I use "rollD: 10" and then only let something happen if a 1 is rolled and ignore other results? I would think so...
Does "setTargetToRandomStation" choose the main station as well?
Only if there are no other non-carrier dockables in the system, which is generally rare.
Rorschachhamster wrote:
EDIT: ...and, connected to the first question can I use "rollD: 10" and then only let something happen if a 1 is rolled and ignore other results? I would think so...
Yes, certainly. The rollD command just generates a particular AI event, and as with other AI events you're under no obligation to respond.