Salk

[KotOR] Direction/Facing: how to find the right values?

Recommended Posts

Hello!

I have been fiddling with modding the game for quite some time but I am still inexperienced and not nearly knowledgeable enough so I am going to ask something that I believe would be useful to many others as well. Namely, how to find the right values when it comes to choose direction for creatures, placeables, doors and cameras.

It seems to me that the game uses three different standards:

1) X Orientation and Y Orientation in some cases

2) X Quaternion and Y Quaternion in others

3) Bearing

Is this correct? And what is the best way to correctly calculate those values having an initial angle?

For 1 and 2, I have been using the invaluable Star Admiral's Utility Armband. 3 is not something I have read about anywhere.

If I remember correctly, I have also read somewhere that different modules use different compass so that North in one of them can be East in another, adding to the confusion. Is this true?

Cheers!

Share this post


Link to post
Share on other sites
14 minutes ago, Salk said:

Is this correct?

No. You are confounding 1 and 2. Both are quats, just stored differently. The game uses degrees, radians, and quats, depending on what specifically you are talking about.

Broadly speaking, "facing", as used in scripting, is a cardinal (i.e. compass) direction and is specified in degrees. "Bearing", as used for placeables in the GIT, is specified in radians. "Orientation", as used for a number of things like cameras and creatures in the GIT, is expressed as two components of a quaternion.

  • Like 1

Share this post


Link to post
Share on other sites

Doors and placeables in GIT files use the Bearing field, which is in radians except written as decimal. So the valid values are from 0 to 3.14159 or 0 to -3.14159. 0 is either north or east, depending on the module. Placeables spawned through scripts use rotation in degrees, with values from 0 to 180 or 0 to -180.

Creatures in GIT files use the XOrientation and YOrientation fields, which are quaternions. Converting from radians or degrees is pretty straightforward and here's a random online calculator that can do it. Creatures spawned through scripts use rotation in degrees. Same as the above for placeables.

Static cameras use the Orientation field, which is also a quaternion. I don't remember how these work because there are a lot of advantages to using animated camera models, one of which being that you don't have to mess around with quaternions.

  • Thanks 1

Share this post


Link to post
Share on other sites

It should be clarified that cameras actually use two values. A quat for the Z rotation (i.e. orientation) and degrees for "pitch", the X rotation (because in 3DS Max, cameras start off pointed straight down at the ground.

As far as origin goes, values in GITs should always be derived from North as 0, whereas values in scripts take East as 0. Although from memory there are a couple of modules that don't use East as the origin, which can screw things up.

  • Like 1

Share this post


Link to post
Share on other sites

Off the top of my head, end_m01aa, end_m01ab, danm14aa, and tat_m17ab are the odd ones out that I remember. And possibly 151HAR and 605DAN in KOTOR 2 since they were based on KOTOR 1 oddities.

But I haven't investigated this weirdness much because it was easier to get in the habit of checking where north is.

 

Edit: DarthParametric investigated it and apparently the direction of north is entirely based on the rotation system and not dependent on the area. The Endar Spire has some weirdness with the minimap, and maybe other areas do too, but that's all it is. I think I over the years got confused by the mismatch between the different rotation systems and chalked it up to the area on account of the weirdness with the Endar Spire.

  • Like 1

Share this post


Link to post
Share on other sites

I have found a new place for the footlockers in Uthar Wynn's room but I have encountered a strange graphical glitch for one of the two boxes and I have no idea where it comes from.

Perhaps looking at the image someone can take a guess?

1839369153_StarWars_KnightsoftheOldRepublic2020-09-0418_14_24.png.b434ca24d8e19b8532c41dfbfbdd1e06.png

Footlocker.jpg

Share this post


Link to post
Share on other sites

It's not the placeable. It's probably the crud overlay on the floor which floats a bit to eliminate Z-fighting. Make sure the height of the placeable is at least 0.15m and shuffle it to the right half a meter or so.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.