Dimensions, and Other Quaturnian Headaches

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Dimensions, and Other Quaturnian Headaches

Post by mandoman »

I guess this is a plea for help. For one thing, I'm lousy with math, and never even came close to taking calculus. Heck, it's been over 30 years since I took any kind of math course at all, and most of what I do only needs very basic math skills. These Quaternion equations are making me dizzy. I MIGHT be able to plug the numbers for X, Y, and Z into either of the two quaternion calculators I downloaded, but I'm even having trouble determining how to find some of those numbers. For instance, my current ship (the SunBat) has three rear exhaust ports, two of which have five vertex' which, when marked as a group, I can't get the three dimensional cursor to center. So how do I figure the X, Y, and Z points in that situation? Next, external views. I don't have a clue how to get the numbers. I also would like to know how one goes about creating points on the model on which blinking lights may be put when in the game mode. I understand if I'm asking too much. Shoot, it ALL seems bigger to me the farther I get into the process. Once I got the hang of Blender, making ships is a breeze, and I have several ideas for future ships, some quite large. I figured maybe I had jumped the hardest hurdle, but it seems that all I have are several Blender models, but no actual Oolite ship oxps. Well, that's it, I guess. I'll keep studying what I can on the subject, but I feel myself coming to a screeching halt. :(
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2272
Joined: Tue Jan 02, 2007 12:38 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by Killer Wolf »

Not sure i fully understand what you're after. Regarding the exhaust ports, i take it you're meaning how to position the plumes? If so, you don't (can't) use quaternions. Plumes, and the points you want to put blinking lights (Flashers) are simply founds from your modelling program : load up the ship, then select the relevant vertex or point and note its XYZ. the tweaking bit comes from the fact that virtually every modeller uses its own scale for size, so you may find, your entities misplaced when you test them in Oolite - usually for me it6's just a case of multiple refinings of the values to shift them into the required position.
Quaternions are only used to revolve/rotate subents, so you don't need to bother w/ them on the Sun Bat.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by Thargoid »

As KW says, the first thing to get your head around is the difference between a vector and a [EliteWiki] quaternion.

Vectors are 3-component items (x, y and z) and represent position. Quaternions are 4-component items (w, x, y and z) and represent orientation (basically the direction an entity is facing including it's rotational orientation along that direction - that last point is the key difference between the two).

For modelling most of what you need are actually vectors, if you're trying to position things such as sub-entities (although here you'll need a quaternion too, see later), exhausts, flashers and external views (you'll also need a quaternion here, again see later). In those cases the position of whatever you're trying to position is worked out in the same way that you work out positions of vertices.

The mid-point of two vertices will just be the average value of the x/y/z components of the individual vertices. So the midpoint of V1 (position x1, y1, z1) and V2 (position x2, y2, z2) is just (x1+x2)/2 , (y1+y2)/2, (z1+z2)/2 . Same applies to the midpoint of any number of vertices by extension of the idea. But in cases like exhausts all of the vertices are normally in a plane (they lie along a common flat surface and will form a bounded area or face) so in Blender you should be able to select that face and it should then give you the mid-point of it automatically (Wings3D can do this, so I'd be surprised if Blender can't).

For quaternions (which you will need if you are adding sub-entities or external views to your ship model) things get a little more complex. There are details on the wiki page, the internet and there is also at least one good excel sheet calculator out there for working things out automatically (it's what I use).

But some basic quaternions are

(1, 0, 0, 0) - this is the "unit" quaternion, pointing "forward and level".
(0, 1, 0, 0) - a rotation of 180 degrees around the X-axis
(0, 0, 1, 0) - same around Y-axis
(0, 0, 0, 1) - same around Z-axis

(0.7071, 0.7071, 0, 0) - 90 degrees around X-axis
(0.7071, 0, 0.7071, 0) - same around Y-axis
(0.7071, 0, 0, 0.7071) - same around Z-axis

Lastly all quaternions should be normalised, meaning that (W*W + X*X + Y*Y + Z*Z) = 1

For more details on them, search the web. I'd also using one of the calculators to save time and brainache...
User avatar
Wyvern Mommy
Deadly
Deadly
Posts: 185
Joined: Sat Apr 02, 2011 7:14 pm
Location: Beyond the final Frontier

Re: Dimensions, and Other Quaturnian Headaches

Post by Wyvern Mommy »

quaternions are basicly another notation for angle/axis vector rotations.

x/y/z are the axis vector, scaled by sin(angle/2), w=cos(angle/2)

so for a 60 degrees rotation we need sinus and cosinus of 30 degrees, 0.5 and 0.8660254 respectively

scaling the unit vector is straightforward when the vector is on one of the main axes.

x axis ( 0.8660254 , 0.5 , 0 , 0 )
y axis ( 0.8660254 , 0 , 0.5 , 0 )
z axis ( 0.8660254 , 0 , 0 , 0.5 )

to scale any other unit vector, just multiplicate the axis parts with the sinus.

vector = 0.213212 , 0.786788 , 0.579228

so the quat of that rotation would be:

q=( 0.8660254 , 0.106606 , 0.393394 , 0.289614 )
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Dimensions, and Other Quaturnian Headaches

Post by Eric Walch »

Thargoid wrote:
(0.7071, 0.7071, 0, 0) - 90 degrees around X-axis
(0.7071, 0, 0.7071, 0) - same around Y-axis
(0.7071, 0, 0, 0.7071) - same around Z-axis

Lastly all quaternions should be normalised, meaning that (W*W + X*X + Y*Y + Z*Z) = 1

For more details on them, search the web. I'd also using one of the calculators to save time and brainache...
You probably can use calculators from the net, but with the console at hand, its just as easy to calculate themselves.

e.g. take the identity quaternion (1,0,0,0) and rotate it around a known axis at a known angle with the rotate command. Your three examples would give in the console:

Code: Select all

> new Quaternion(1,0,0,0).rotate(new Vector3D(1,0,0), Math.PI/2)
(0.707107 + 0.707107i + 0j + 0k)
> new Quaternion(1,0,0,0).rotate(new Vector3D(0,1,0), Math.PI/2)
(0.707107 + 0i + 0.707107j + 0k)
> new Quaternion(1,0,0,0).rotate(new Vector3D(0,0,1), Math.PI/2)
(0.707107 + 0i + 0j + 0.707107k)
The first parameter is the identity quaternion. The second the vector to rotate around (must be a normalised vector) and the third is the angle. Math.PI is a 180 degree rotation, Math.PI/2 is a 90 degree rotation
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by mandoman »

I see a glimmering. I used the cursor in Blender to find the X, Y, Z point for the Lasers, which was the central point of the face of three vertex'. Isn't that what you are saying, Killer Wolf? If it's the same for the exhaust plumes (sorry about the port stuff), I may have made an error. In modeling the ship, I thought I'd be tricky and extrude inward (into the ship model) the whole face, so it looks more realistic. That might be a problem, since I can't find a face on the exterior surface. If I can find the face, except where I moved it inside the ship, would it still work to produce the plume from the X, Y, Z median, or midpoint? So if I'm understanding this so far (and I don't know for sure that I am), to find the placement of lasers, missiles, and exhaust plumes, as Thargoid says, I just need the midpoint of the X, Y, Zs of each of the Vertex' that surround the face of each item in question? Such as , to find the correct point for a laser face, I need the midpoint of the X, Y, Z of the Vertex' around the laser face. That would be the Vector of the laser? I take it that I can't just use the X, Y, Z of the cursor centralized on the face of the laser?

I would really like to have exterior view options on the SunBat, and every other ship I attempt, so I'm going to need to understand this. Are you saying that when normalized, all the quaternions used equal the number one? Wyvern, to what does the number 0.8660254, and how did you get it? Is the .5 you use representing half of the normalized quaternion number 1?

I'm sorry if I'm being dense. This is probably easy for the rest of you. Thanks for any help you can give, and I'll do my best to understand. :? :)
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by Thargoid »

For both sub-ents and views, you will need both the vector part (for the position) and the quaternion part (for which way the sub-ent is oriented, or for which way the view looks).

The external views are generally simple, as they normally look forward (in which case it will be 1 0 0 0) or a fairly simple rotation from that such as the ones I listed before.

So to find the placement position (vector, X Y Z) for lasers, missiles, exhaust plumes or anything else related to the model you either need to find a suitable vertex and use that position (for example if you want a laser eminating from the tip of your ship's nose, use the position of the vertex at that position). But if you want it to be at the centre of a face then you need to calculate that position as I mentioned before. So in effect putting the cursor in the middle of the face and taking those co-ordinates and working out the average of all the points around the face and using those should come out (at least roughly) the same. It does of course presume that the face is symmetrical.

In the case of exhausts I normally find it simplest to design the exhaust outlet on the model to be symmetrical, and then just get its midpoint by "mentally" drawing a line across the middle of it and positioning the exhaust at the centre of that line (by averaging the X Y Z co-ords of the two vertex endpoints). Exhausts only need position and not orientation, as they always point backwards along the Z-axis of the model (the other three figures in the shipdata entry are the exhaust plumes width and height, with the length figure there but basically ignored as the game engine sets that).
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2272
Joined: Tue Jan 02, 2007 12:38 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by Killer Wolf »

yeah. using the pics of your Sun Bat as an example :
to place an exhaust plume, i'd select one of those flat faces at the back, the ones you coloured red. Depending on the modeller, you'll get some kind of XYZ value - it might be of the midpoint of the selection, or an actual vertex etc. Whatever it is, it'll be close enough to give you the position for the plume for an initial test, like i say you might have to go back and forth a few times tweaking the values in your shipdata files. once you have that XYZ you can put in the exhaust entry in shipdata, filling out the width and height values to kinda match the engine size.
for the lasers in the wingtips, i use sub-entities, because i believe you can't have multiple "front laser" entries on a ship by themselves. for the Dominatrix, i actually modelled a gun, but for the Diamondback, i just created a simple tiny tetrahedron and placed it out of sight inside the wing, since the guns didn't need to be seen. in the sun bat case, i'd place a tiny subent just inside each wing tip, then i'd select the vertex of the point of each wingtip and that would give you the XYZ position of each vertex - you'd then use that as the laser position in the shipdata for each respective subent laser. i hope that makes sense. you won't have a midpoint for a vertex by the way, they're a point in space so they don't have a midpoint as such ~ midpoints would however be useful for things like edges, if for example you selected the diagonal edge that runs from corner to corner across the rectangular face of your engine. As for using your cursor position, sure - do that if it's easier. I do that in Milkshape often - i'll look at a top view of the ship and put the cursor a little ways behind the engine, that gives me the X and Z values to use, then looking at a side view i can use the cursor to give me the Y value too. whatever's easiest for the tool you're using.

Quaternions come into the external views, as you need to define the XYZ position of the view, and then a rotation to define which way the "camera" that represents that view is looking. Quats can be a tw@, i find, and i try not to get too creative w/ my external views. the easiest thing i can suggest is find a good OXP ship that has a bunch of defined external views (Griff's Cobra III has a load) and respectfully borrow them! (A simple thankyou in the Read Me or launch announcement post here is considered good form).
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by mandoman »

OK, I think I have the laser placement down. Blender will actually snap the cursor to the center vertex point of any chosen face on the model, so I think that should define the lasers (I hope). The exhaust is still confusing, though. While checking out three different ships shipdata.plists, it looks like there are six figures in any one string. So I only have to know the first figure in the string, for certain, in order to get the exhaust in the correct position? I guess with some trial, and adjustment, though, according to you, Killer Wolf. An example of what I get when I choose the vertex points around the center exhaust source, it gives me the X, Y, Z of the median, which were -1.706, 0.001805, and -0.864. Why is it that one ship's exhaust have ten strings (Merlin), while another has only two (Werewolf)?

For the main axis, are you referring to the absolute center of a ship model? So that the number representing the absolute center (axis) of the SunBat could be plugged into the console the way you showed (Erich), and the console would calculate the numbers I need for the shipdata.plist?

The viewpoints still throw me. If the Vector is the position of the model, would that be the same as the axis point?

Sorry I keep editing my responses. It just now registered in my head what you were saying in your last paragraph, Killer Wolf. The SunBat is approximately the same size as the Merlin, maybe slightly bigger. So could I just borrow the external views from the Merlin's shipdata.plist?
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by mandoman »

OK, I have noticed a few other things that confuse me. Why do the Flashers in the ship.data plists show seven different numbers? Killer Wolf, you said that the Flashers were represented by any X, Y, Z vertex point on the ship model, in what ever modeler I'm using (Blender), so why seven numbers in one string? Once again, this is obvious to you, I'm sure, but I can't figure it.

Aft Eject Position. Would that be a vertex point at the bottom rear of the ship? What if I just don't give it the option of having an Eject Position? The SunBat doesn't have a cargo hold from which to eject anything. That won't save me from figuring it out for my next ship, which definitely does have a cargo hold.
Last edited by mandoman on Sat Oct 01, 2011 5:14 pm, edited 1 time in total.
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by Thargoid »

I'd suggest to read the shipdata.plist in tandem with [EliteWiki] wiki page on the same subject. That explains in detail how each of the entries is put together.

For example for the exhaust one, the first three numbers are the co-ordinates that the exhaust appears from. The 4th and 5th are the width and height of the plume, and the 6th should be how long the plume is (along the Z-axis), but as i said earlier at the moment the game engine ignores this and does its own thing.

You can find details of flashers under sub-entities in the list (they are a special kind of sub-ent). There are two ways of doing them (an old method and a new one) just to further confuse matters, but the wiki entry is quite clear about what does what.

And no - aft eject position is where the ship dumps cargo and mines. So it should be somewhere towards the back of the model, and either behind, above or below it so whatever you dump doesn't immediately crash into the ship itself.
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2272
Joined: Tue Jan 02, 2007 12:38 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by Killer Wolf »

Thargoid's got most of the answers you need, as for some others :
Why is it that one ship's exhaust have ten strings (Merlin), while another has only two (Werewolf)?
Not having looked at the Merlin, but i'll assume that this is simply the number of plumes to give an effect for the ship. the Werewolf has two separate engines, therefore you need to define a plume for each : find your XYZ etc etc and then work out a width/height value that will look good on the model and fit the engine's modelled size. i think some other ships have used overlapping plumes to give a unique look, so i'll assume that's why the Merlin has ten entries.
So could I just borrow the external views from the Merlin's shipdata.plist?
Probably, it would be a good starting point. What i do is generally is copy over my views from one of my other ships ~ since they're all roughly the same size, it gives me a starting point. what i tend to do is have the XYZ positions set to be a couple of hundred units away from the ship (ie, the top view is 200 above the ship, the left and right views are 200 to the sides etc), that usually gives me a good view and can take in the entire craft. when i get in the game i check the views and typically have to maybe move the Z positions a bit to centralise the ship in the view. I find quaternions pretty annoying at times so i don't get overly creative w/ them. i tried to do an external view that was in front of the ship looking back at it, fairly high up and angled down to give a cool view - it didn't work. at all :-(
Aft Eject Position. Would that be a vertex point at the bottom rear of the ship? What if I just don't give it the option of having an Eject Position?
The eject position is the place YOU eject from when you use your escape capsule. on an NPC i believe an escape capsule model will appear in roughly this spot, for the player, it's where you see that quick view of your ship before it explodes when you hit the eject button in combat. i honestly don't know what happens if you miss it out, maybe the code just uses the origin or something? i doubt it would break your OXP, the camera view might just give you a weird look as you eject.
Self-edit : just scanned Thargoid's reply and realised i'm wrong! I typed it all up so i'm not deleting it, i'll leave it to show that OXPing is a constant learning game! Get in, eh, every day's an education.

Like Thargoid says, check out the Wiki for some of the entries. Flashers include all sorts of numbers relating to flash rates and colours etc but they're fairly easy to play w/ once you start.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Dimensions, and Other Quaturnian Headaches

Post by Smivs »

Killer Wolf wrote:
i tried to do an external view that was in front of the ship looking back at it, fairly high up and angled down to give a cool view - it didn't work. at all :-(
You too, huh? :(
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
mandoman
---- E L I T E ----
---- E L I T E ----
Posts: 1375
Joined: Thu Apr 28, 2011 3:17 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by mandoman »

Thargoid wrote:
I'd suggest to read the shipdata.plist in tandem with [EliteWiki] wiki page on the same subject. That explains in detail how each of the entries is put together.

For example for the exhaust one, the first three numbers are the co-ordinates that the exhaust appears from. The 4th and 5th are the width and height of the plume, and the 6th should be how long the plume is (along the Z-axis), but as i said earlier at the moment the game engine ignores this and does its own thing.

You can find details of flashers under sub-entities in the list (they are a special kind of sub-ent). There are two ways of doing them (an old method and a new one) just to further confuse matters, but the wiki entry is quite clear about what does what.

And no - aft eject position is where the ship dumps cargo and mines. So it should be somewhere towards the back of the model, and either behind, above or below it so whatever you dump doesn't immediately crash into the ship itself.
That's kind of what I've been doing. I don't have a problem with most of the ship data, just the externals (which I think I have covered, but I'll have to check that with a test flight), and things that are on the ship that need to be specified, which are evidently sub-ent. I also think I have the lasers. My head is spinning a bit, but I'm starting to get it a little at a time. I have a whole lot more appreciation for you guys that have already made successful oxps.
Not having looked at the Merlin, but i'll assume that this is simply the number of plumes to give an effect for the ship. the Werewolf has two separate engines, therefore you need to define a plume for each : find your XYZ etc etc and then work out a width/height value that will look good on the model and fit the engine's modelled size. i think some other ships have used overlapping plumes to give a unique look, so i'll assume that's why the Merlin has ten entries.
Killer Wolf, I was only referring to the external views because the SunBat is approximately the same size as the Merlin. No, the exhaust for the Merlin probably wouldn't work with the SunBat, as the SunBat has three separate engines. As for the rear ejection point, the "How To" Wiki for oxps defines that as the point where cargo is ejected from the ship. I never use an escape pod in any case, so I don't really need to mention it, do I? Either that, or just indicate in the plist that it is not there?

I'll definitely keep studying the Wiki How Tos, but it sure is great to get solid answers to questions I develop that they don't explain very clearly. Thanks, and I hope you won't mind if I come back with a few more questions? :?: :)
Mandotech Industries Wiki Page.

http://wiki.alioth.net/index.php/User:Mandoman
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2272
Joined: Tue Jan 02, 2007 12:38 pm

Re: Dimensions, and Other Quaturnian Headaches

Post by Killer Wolf »

I never use an escape pod in any case, so I don't really need to mention it, do I? Either that, or just indicate in the plist that it is not there?
Just don't mention it. as per my last posting, it seems there's no entry for the ejection of a capsule, so the game code must work something out itself
Thanks, and I hope you won't mind if I come back with a few more questions?
course not, that's what this board's all about, helping each other out :-)
Post Reply