Skip to content

TurboList Program

Ferdinand Calo edited this page Jan 25, 2021 · 15 revisions
# Feature Overview
Kind: TurboList Program
Extendable: true
JSON based: no
JSON config: no

As you may know from the Model Page, in FVTM we have TurboLists.
(TurboLists are a labeled compound holding an undefined amount of polygons)
Into those "TurboLists" you can include simple classes with methods/code
which get executed when a Turbolist is rendered.
This way you can do "animations" and similar nice things.

FVTM offers some pre-defined "Programs", take a look at DefaultPrograms!

The Class: (simplified)

public static interface Program {
		
    public String getId();
		
    public void preRender(TurboList list, @Nullable Entity ent, VehicleData data, @Nullable Colorable color, @Nullable String part);
		
    public void postRender(TurboList list, @Nullable Entity ent, VehicleData data, @Nullable Colorable color, @Nullable String part);
		
 }

Upon rendering a TurboList before it does get rendered, the preRender method
in every attached Program is executed, afterwards after the turbolist rendered
the postRender method is executed.

This way you can for example, in the pre-render, activate some GL code for e.g.
glowing, alpha stuff or whatever, and after it rendered on post-render disable it.
You can also translate the polygons or rotate in pre-render and reset them in post.
There are various ways and various things you can do.

NOTE:

  • the Entity parameter can be null, e.g. if rendering as item, or on a display block
  • the VehicleData parameter can be null, if the model is not for vehicles or parts
  • the Colorable parameter holds RGB data, e.g. for containers,
    which have no vehicledata (usually vehicledata stores RGB for vehicles)
  • the String (part) parameter is the currently rendered part in the vehicledata,
    in case of part models, otherwise it is null

Some good or semi-good examples are in DefaultPrograms! (you can take a look at the class also)

Adding into the Model

Here some information for each model kind:

  • java FVTM/Java Models that use TurboLists

    groups.get("group_id").addProgram(PROGRAM_INSTANCE);
    groups.get("other_id").addProgram(new SomeProgram("argument", 2, false));
    group_instance.addProgram(PROGRAM_INSTANCE);
    //or multiple at once!
    somegroup.addPrograms(PROGRAM_INSTANCE, ANOTHER_INSTANCE, new YetOther(true));

    Check also the examples in DefaultPrograms!

  • jtmt Fexcraft TMT JSON format parsed into FVTM TurboList Models

    //inside the group object create a new array called "fvtm:programs"
    "groups":{      
        "group_id": {
            "name": "group_name",
            "fvtm:programs":[
                "fvtm:rgb_primary", //primary rgb default program
                [ "mypack:customprogram", 23, "test", true] // extended program init
                "fvtm:wheel_auto",
                {
                    "id": "mypack:another_custom_program",
                    "run_backwards": true,
                    "speed": 2.5
                    "__comment": "obj type extended program init"
                }
            ],
            "polygons": [
                {}
            ]
        }
    }
    
  • obj WaveFront OBJ models parsed into FVTM TurboList Models
    Place this somewhere on the top, prefferably after the initial comment (credits)
    but before the Object declaration - the line starting with o and name (if present).
    Example based on a file exported from FMT Standalone (+ edits)

    # FMT-Marker OBJ-2
    #
    # Model exported via the Standard FMT OBJ Exporter
    # FMT (Fex's Modelling Toolbox) v.2.5.2 © 2020 - Fexcraft.net
    # All rights reserved. For this Model's License contact the Author/Creator.
    #
    # Creator: Ferdinand (FEX___96)
    
    # Program: chassis_primary fvtm:glow
    # Program: other_group mypack:customprogram "test" 23 false //string array
    # Program: another_group [ "mypack:anotherprogram", "test", 23, false ] //json array
    
    # Model Name
    o T3 Series
    

    Definitions are similar as in JTMT, you can just define the program by id
    or add a json array or json object as arguments, or in the case of OBJ models
    a simple "string array" where each value is separated by a space.