Skip to content
Garrett Guillotte edited this page Nov 1, 2024 · 6 revisions

EmptyEpsilon can use OBJ models. To make new OBJ models available for use:

  1. Place the OBJ files and any textures in the EmptyEpsilon/resources directory.

  2. Add a ModelData() entry to EmptyEpsilon/scripts/model_data.lua. For example, the following code:

    • adds a model named gentest from OBJ file gentest.obj
    • uses gentest.png for its texture
    • uses gentest_diffuse.png for its specular/reflective map
    • uses gentest_illumination.png for its illumination map
    • scales the model up 24x
    • sets its in-game radius to 120 meters
    • adds two engine effect emitters
    model = ModelData()
    model:setName("gentest")
    model:setMesh("gentest.obj")
    model:setTexture("gentest.png")
    model:setSpecular("gentest_diffuse.png")
    model:setIllumination("gentest_illumination.png")
    model:setScale(24)
    model:setRadius(120)
    
    model:addEngineEmitter(-13, -2.1500, 0.3,  0.2, 0.2, 1.0, 3.0)
    model:addEngineEmitter(-13,  2.1500, 0.3,  0.2, 0.2, 1.0, 3.0)
  3. Adjust the ModelData properties appropriately.

Tips

  • If you're exporting OBJ files from Blender, use the following settings:

    Blender settings

  • If you need to rotate a model, do so from a 3D modeling program. Some example programs include:

Since model_data.lua is a Lua script file, you can use scripting tools (such as loops) to easily add many similar models.

Model data function reference

3D coordinates (Vector3f) in these functions translate to -X, Y, Z values in Blender.

  • Positive X values in model_data.lua are forward of the center point.
  • Positive Y values are to the right of the center point.
  • Positive Z values are above the center point.

Functions

  • :setName(string name): The model's name, which is used to refer to the model in ship template scripts.
  • :setMesh(string mesh_name): The relative path to the mesh file within resources (or packs).
  • :setTexture(string texture_name): The relative path to a texture file...
  • :setSpecular(string specular_texture_name): ... specular map ...
  • :setIllumination(string illumination_texture_name): ... and illumination map.
  • :setRenderOffset(sf::Vector3f mesh_offset): Offset the mesh's position by this amount. Useful to recenter the model if its center point in the mesh file is not at 0, 0, 0.
  • :setScale(float scale): Scale the mesh by this multiplier.
  • :setRadius(float radius): Set the mesh's effective radius in in-game meters.
  • :setCollisionBox(sf::Vector2f collision_box):
  • :addBeamPosition(sf::Vector3f position): Add a visual beam emitter at this position on the model.
  • :addTubePosition(sf::Vector3f position): Add a visual weapons tube at this position on the model.
  • :addEngineEmitter(sf::Vector3f position, sf::Vector3f color, float scale): Add an engine emitter (visual effects trail) at this position on the model, with a RGB color (ie. 1.0, 0.0, 0.0 for full red), and scale.
Clone this wiki locally