Locations for Xtrad Editor Files
The following diagram shows the location of files used by the Xtrad Editor.
All files are stored in the xtrad-library directory within uploads. Most file formats are obvious but a few need further explanation.
File Formats
Animation Macros
An example animation macro file is as follows (note the extension must be .ani):
duration = 10 start time = -1 position start: 0 0 -100 position time = 5: z = 0 position time = 10: z = 100
- duration is the time for the animation in seconds
- start time of -1 says ‘get the start time from the timeline current time marker‘
- position start: gives the starting x, y, z positions
- position time = sets the position at that time
duration = 8 start time = -1 position start: 0 0 -30 position time = 2: x = 30 z = 0 position time = 4: x = 0 z = 30 position time = 6: x = -30 z = 0 position time = 8: x = 0 z = -30 rotation start: 180 180 0 rotation time = 2: x = 270 y = 270 z = 0 rotation time = 4: x = 0 y = 0 rotation time = 6: x = 90 y = 90 rotation time = 8: x = 180 y = 180
This example shows both translation and rotation. The rotation angles are in degrees.
Animation Macro Syntax
The following shows the psuedo-bnf syntax for the animation macro:
<animation> ::= <statements> | statement
<statement> ::= <durationstatement> | <loopstatement> | <looprepstatement> | <loopppstatement> | <startstatement>
| <rotationstatement> | <positionstatement> | <scalestatement> | <visiblestatement>
<durationstatement> ::= “duration” | “DURATION” “=” <number>
<loopstatement> ::= “loop” | “LOOP” “=” “true” | “false” | “TRUE” | “FALSE”
<looprepstatement> ::= “looprepetitions” | “LOOPREPETITIONS” “=” <number>
<loopppstatement> ::= “loppingpong” | “LOOPPINGPONG” “=” “true” | “false” | “TRUE” | “FALSE”
<startstatement> ::= “start” | “START” “time” | “TIME” “=” <number>
<rotationstatement> ::= “rotation” | “ROTATION” | “rot” | “ROT” <args> “:” <parameters>
<positionstatement> ::= “position” | “position” | “pos” | “POS” <args> “:” <parameters>
<scalestatement> ::= “scale” | “SCALE” <args> “:” <parameters>
<visiblestatement> ::= “visible” | “Visible” <args> “:” “true” |”false” | “TRUE” | “FALSE”
<args> ::= <startop> | <timeop>
<startop> ::= “start” | “START”
<timeop> ::= “time” | “TIME” “=” <number>
<parameters> ::= ( <AXIS> “=” <number> )+
| <number> <number> <number>
<AXIS> ::= “x” | “y” | “z” | “X” | “Y” | “Z”
Material Format
Definitions for materials are held in directories under the materials directory. The name of the directory is the name of the material.Within the material directory can be four images and a data file. The start name of the file must match the name of the directory, see diagram above:
- dirname – Map.jpg – is the texture image for the material (Required)
- dirname – Bump.jpg – is the bump map (Optional)
- dirname – Displacement.jpg – is the displacement map (Optional)
- dirname – Specular.jpg – is the specular map (Optional)
- dirname – Data.json – is a data file setting the values for ‘bumpScale’ and ‘displacementScale’ (Optional)
The format for the Data file is:
{"bumpScale": "-0.08", "displacementScale": "0"}
Shader Format
An example shader file follows:
{ "fragment": "uniform float time;\nvarying vec2 vUv;\nvoid main( void ) {\nvec2 position = - 1.0 + 2.0 * vUv;\nfloat red = abs( sin( position.x * position.y + time / 5.0 ) );\nfloat green = abs( sin( position.x * position.y + time / 4.0 ) );\nfloat blue = abs( sin( position.x * position.y + time / 3.0 ) );\ngl_FragColor = vec4( red, green, blue, 1.0 );\n}", "vertex": "varying vec2 vUv;\nvoid main()\n{\nvUv = uv;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n}", "uniforms": "{\"time\":{\"value\":1}}", "uniformScript": "this.children[i].material.uniforms.time.value += delta;\n", "uniformScriptText": "this.children[0].material[0].uniforms.time.value += delta * 2.0;\nthis.children[0].material[1].uniforms.time.value += delta * 2.0;\n", "uniformScriptBackground": "this.background.backgroundObject.uniforms.time.value += delta;\n" }
The json file has the following fields:
- fragment – the fragment shader code
- vertex – the vertex shader code
- uniforms – the code for uniforms
- uniformScript – the code that is loaded into the object’s scripts (apart from 3D Text and backgrounds)
- uniformScriptText – the code that is loaded into a 3D Text object’s scripts
- uniformScriptBackground – the code that is loaded into a background’s scripts
SkyBox Format
Definitions for skyboxes are held in directories under the skyboxes directory. The name of the directory is the name of the skybox. Within the skybox directory must be 6 images. The start name of the file must match the name of the directory, see diagram above:
- dirname-nx.jpg
- dirname-ny.jpg
- dirname-nz.jpg
- dirname-px.jpg
- dirname-py.jpg
- dirname-pz.jpg