-
Notifications
You must be signed in to change notification settings - Fork 6
3) Modifying and extending the plugin
This page covers how to extend or modify the Blender plugin. It assumes that you already have Python knowledge, and only serves to further document the plugin.
Most of the plugin happens in 3 functions:
-
ObjectExport.execute
- Where all the objects in the scene are placed in eithermeshList
orskeletonList
, depending on whether a mesh or an armature was found. ThesettingsList
variable contains custom settings that can be selected on export (such as triangulation of the meshes, or only allowing selected models to be exported). This information is then passed intosetupData
, which returns the final mesh and animation list in a format which will be described shortly, and then calls thewriteFile
function. -
setupData
- Where each model+animation is disassembled and its information is stored in thefinalList
dictionary (which contains a collection ofS64Mesh
objects with each mesh (bone) name being the key) and theanimList
dictionary (which contains a collection ofS64Anim
objects, with the action name being the key). The mesh data is created with the assistance of theaddFace
function. The data is then sorted for efficiency (for instance, grouping all the faces that share materials together, and then correcting the vertex indices to start in order of apperance). These two dictionaries are returned and passed onto: -
writeFile
- Which then takes thefinalList
+animList
dictionaries and writes the .s64 format. If you want to change the plugin to export files in other formats (such as N64 display lists), this is the function you'll want to mess with.
The helper classes are as follows:
This class contains the information of a single vertex, being:
self.coor = Vector # Vertex coordinate
self.norm = Vector # Vertex normal vector
self.colr = Tuple # Vertex R G B Color
self.uv = Vector # Vertex U V coordinates
This class contains the information of a single face, being:
self.verts = [] # List of vertex indices that make up this face
self.mat = "" # Material name for this face
This class contains the information of a single mesh, being:
self.name = "" # Mesh (Bone) name
self.verts = {} # (Ordered) Dictionary of S64Vertex, with the key being the vertex index
self.faces = [] # List of S64Face
self.mats = [] # List of materials used by this mesh
self.props = [] # List of custom properties
self.root = Vector # Bone root location
self.parent = "" # Parent mesh name
This class contains the information of a single mesh's frame data, being:
self.bone = "" # Affected mesh name
self.pos = Vector # Bone displacement from its rest position
self.ang = Quaternion # Bone rotation from its rest angle
self.scale = Vector # Bone scale from its rest size
This class contains the information of a single animation, being:
self.name = "" # Animation name
self.frames = {} # (Ordered) Dictionary containing a dictionary of S64KeyFrame,
# with the key of the outer dictionary being the keyframe number,
# and the inner key being the mesh name.
All the classes are set up to let you convert them to strings via print()
or other methods.
By modifying the value of the DebugS64acterExport
global variable, you can get the contents of finalList
and animList
printed to your system console (IE by accessing Window > Toggle System Console
. This option is only available on Windows, for other OSes you must start Blender from a terminal. More information available here).