Code Monkey home page Code Monkey logo

kotor_git_data_output_for_max's Introduction

KOTOR GIT Data Output for Max

This is a simple script that will derive the relevant data from an object (or objects) in 3DS Max/GMax needed to be added to a KOTOR GIT when creating new static camera, placeable, or creature entries and output it to the Listener window. Now expanded with some additional supplementary scripts.

Instructions

Download the script and put it in your Scripts folder, or some other convenient location. In Max, select the object/s of interest, hit F11 to open the Listener window, then hit CTRL+R or go to File -> Run Script and select KOTOR_GIT_Data_Output_for_Max.ms and hit enter. You should get an output something like the following:

===================================================
Object data formatted for KOTOR GIT injection
--------------------- GENERIC ---------------------
SELECTED OBJECT: PMBIM
POSITION (in metres): 106.526, 33.619, 4.21
ROTATION (in degrees): 0.0, 0.0, 112.5
------------------ STATIC CAMERA ------------------
PITCH (X rotation in degrees): 0.0
ORIENTATION (Z rotation as a WXYZ quaternion):
0.55557, 0.0, 0.0, 0.83147
-------------------- PLACEABLE --------------------
BEARING (Z rotation in radians): 1.9635
-------------------- SCRIPTING --------------------
FACING: (Z rotation + 90°): 202.5
-------------------- CREATURE ---------------------
X ORIENTATION ( COS(Z + 90°) ): -0.92388
Y ORIENTATION ( SIN(Z + 90°) ): -0.382683
===================================================

If you also need to derive the geometry struct values to create a new GIT trigger entry, download the second script, KOTOR_GIT_Trigger_Output_for_Max.ms and use in the same manner as above. This will output the vertex offsets from the parent pivot for the selected object. It will skip any object with more than 10 verts (triggers typically only need 4-6 verts), but this can be adjusted by editing the vertLimit variable in the script. In order to reorder the vertices sequentially, it will create a temporary duplicate of the object, so make sure the object is a 2D plane. Note that correct vertex order only seems possible to derive with convex shapes. Concave shapes (for example, a U shape) will return an incorrect vert order. You should get an output something like the following:

If you would like to recreate creature or waypoint positioning inside Max using data from a module's GIT, a third script now converts from X/Y Orientation to a Z rotation in degrees. Download and run the KOTOR_GIT_Orientation_Converter.ms script, as above. A pop-window will allow you to enter the values:

Note that in Max the text fields are filtered to prevent the entry of extraneous characters, but this feature is disabled for GMax. Hit the Convert button and the conversion results will be output to the Listener window. You should get an output something like the following:

===================================================
KOTOR Creature X\Y Orientation Converter for Max
---------------------------------------------------
X ORIENTATION: -0.92388
Y ORIENTATION: -0.382683
------------------- CONVERSION --------------------
IN-GAME FACING (in °): 202.5
MAX Z ORIENTATION (in °): 112.5
===================================================

Additionally, this script now also converts the orientation field for static cameras, which defines the camera's Z rotation (X rotation is defined in the camera struct's Pitch field, already in degrees):

Note that in Max the text fields are filtered to prevent the entry of extraneous characters, but this feature is disabled for GMax. Hit the Convert button and the conversion results will be output to the Listener window. You should get an output something like the following:

===================================================
KOTOR Static Camera Orientation Converter for Max
---------------------------------------------------
W: 0.743146
X: 0
Y: 0
Z: 0.66913
------------------- CONVERSION --------------------
MAX Z ORIENTATION (in °): 83.9999
===================================================

This script now also has provision to convert placeable bearing (in radians) to degrees:

Note that in Max the text field is filtered to prevent the entry of extraneous characters, but this feature is disabled for GMax. Hit the Convert button and the conversion result will be output to the Listener window. You should get an output something like the following:

===================================================
KOTOR Bearing Converter for Max
---------------------------------------------------
BEARING: -0.945096
------------------- CONVERSION --------------------
MAX Z ORIENTATION (in °): -54.15
===================================================

There is now also a streamlined location output script, KOTOR_Location_Output.ms, that strips out all extraneous formatting, intended for direct copying and pasting into NSS scripts.

Acknowledgements

  • Unit conversion function taken from a CG Society forum post by martinB.
  • Float rounding function taken from a Scriptspot post by Guessmyname.
  • Bad characters filter function taken from a CG Society forum post by thatoneguy.
  • Max version check idea taken from KOTORMax by bead-v.
  • Thanks to ndix UR for various discussions regarding the arcane mysteries of quaternions and the Byzantine inner workings of the Odyssey engine. Also for providing a much simpler method of converting X/Y orientations to Euler angles.
  • Origin of the script idea thanks to conversations with Kexikus and JCarter426 on the Deadly Stream Discord.
  • Extension of the script from static camera values to also include placeable and creature data thanks to conversations with ebmar/Seth on the Deadly Stream Discord.
  • Useful information regarding using trig functions to reverse-engineer Odyssey's X/Y Orientation values derived from several posts by Vriff on Deadly Stream.
  • A revised approach to determining trigger object vertex order supplied by JCarter426 on the Deadly Stream Discord.

kotor_git_data_output_for_max's People

Contributors

darthparametric avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

89096000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.