Wireframe mode and reloadable map scripts

Get help with installing and running the Cafu Engine here. This forum is also for general questions and discussion of all aspects regarding the Cafu Engine.
Post Reply
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:
Wireframe mode and reloadable map scripts

Post by Carsten » 2007-11-07, 16:53

Hi all!
I'm currently preparing the first release candidate (RC1) of the upcoming release when I noticed two nice features that I'd like to share with you:
  1. I've just (re-)added support for wireframe-rendering and other rendermodes again. Wireframe mode etc. has been missing since the introduction of the MatSys, and it took until now (MatSys complete, ConsoleInterpreter complete) to add this nice feature again:
    :right1: http://images.ca3de-community.de/main.p ... temId=2025

    This is achieved with the new console function forceRM(matname), where matname is the name of a material that should be enforced for all rendering. For example, the upcoming release includes a material definition named "wireframe", and thus the above example screenshot was taken after this console command:

    Code: Select all

    forceRM("wireframe");
    In order to turn off the material force mode again, just use forceRM() without any parameters.
    The same technique works of course also with other materials, e.g. the following examples shows the pure lightmaps:

    Code: Select all

    forceRM("Textures/generic/_white");
  2. It is possible to re-load map/entity scripts while the map (and of course the engine) is running, no interruption or reloading required!
    This is easily achieved with the runMapCmd() console function, that runs any Lua statement in the context of the map/entity script. Therefore,

    Code: Select all

    runMapCmd("   dofile('Games/DeathMatch/Worlds/TechDemo.lua')   ")
    loads and runs the TechDemo.lua script once more in the context of the currently loaded map script.

    This of course makes the most sense when Ca3DE is running not in full-screen, but in windowed mode (use the -nofs command-line paramater to achieve this), and you have a text editor with the TechDemo.lua script opened in parallel.
    After saving your changes in the text editor, simply ALT+TAB to Ca3DE again, type the above command (or just press arrow up to repeat it from the command history), and all statements are run again as during map initialization, so that your changes become immediately effective.

    This technique preserves most of the current script state, btw., it does not do a full map re-init from scratch. Sometimes the situation is hopeless though (e.g. barrels already exploded, enemies already dead), in case of which a full map restart is preferrable.

    Oh, and if you think that the above is too much to type over and over again, and TAB completion and command history is still too much work involved, there are several solutions for this problem. For example, you might write something like

    Code: Select all

    function r()
        runMapCmd("   dofile('Games/DeathMatch/Worlds/TechDemo.lua')   ")
    end
    into the config.lua file that is introduced with the new release. Then you can just enter r() into the console as a shortcut. Much better, isn't it? :-)

    Another alternative is to put a shortcut function into the TechDemo.lua file itself. for example my TechDemo.lua file has this piece of code near its top:

    Code: Select all

    -- This function reloads and runs this very script again.
    -- Useful for working with and testing scripts "online",
    -- i.e. while the engine is running and without reloading the map!
    function reloadscript()
        dofile("Games/DeathMatch/Worlds/TechDemo.lua");
    end
    so I type runMapCmd("reloadscript()") for reloading the script. Not as convenient as the above variant, but easier to remember and type than no abbreviation at all.
    Finally, here is an example screenshot:
    :right1: http://images.ca3de-community.de/main.p ... temId=2027
Best regards,
Carsten
User avatar
Thrawn
Posts:302
Joined:2004-08-30, 10:38
Location:NRW, Germany
Contact:

Post by Thrawn » 2007-11-07, 17:44

Good news :) Well done, both additions are very, very useful!
Image
User avatar
Stephen
Posts:75
Joined:2006-05-01, 06:34
Location:Australia
Contact:

Re: Wireframe mode and reloadable map scripts

Post by Stephen » 2008-01-03, 15:30

Sounds cool - it was a lot of fun running around maps in the different render styles...
Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests