Game Development Community

TGE Editor AddOn

by AndyGFX · in Torque Game Engine · 07/31/2004 (9:51 pm) · 6 replies

Here is little extension

1) Create file GFXAddOn.cs

2) copy this source inside:

// *************************************************************************** BEGIN
// AndyGFX AddOn 
// *************************************************************************** 
function GFX_AddOn_IncGrid(%this)
{
    %val = EWorldEditor.gridSize;
    %x1 = getword(%val,0); 
    %y1 = getword(%val,1);
    %z1 = getword(%val,2);
    
    %x1 = %x1 + 0.25;
    %y1 = %y1 + 0.25;
    %z1 = %z1 + 0.25;
        
    EWorldEditor.gridSize = %x1 SPC %y1 SPC %z1;
    echo("Grid Size: [" @ %x1 @","@ %y1@","@ %z1@"]");
}


function GFX_AddOn_DecGrid(%this)
{
    %val = EWorldEditor.gridSize;
    %x1 = getword(%val,0);
    %y1 = getword(%val,1);
    %z1 = getword(%val,2);
    
    %x1 = %x1 - 0.25;
    %y1 = %y1 - 0.25;
    %z1 = %z1 - 0.25;
    
    EWorldEditor.gridSize = %x1 SPC %y1 SPC %z1;
    echo("Grid Size: [" @ %x1 @","@ %y1@","@ %z1@"]");
    
}

function GFX_AddOn_SnapGrid(%this)
{
    %snap = EWorldEditor.SnapToGrid;
    
    if (%snap == 0) 
        EWorldEditor.SnapToGrid=1;
    else 
        EWorldEditor.SnapToGrid = 0;

    echo("GRID SNAP: "@EWorldEditor.SnapToGrid);
    
}

function GFX_AddOn_SnapRotation(%this)
{
    %snap = EWorldEditor.snapRotations;
    
    if (%snap == 0) 
        EWorldEditor.snapRotations=1;
    else 
        EWorldEditor.snapRotations = 0;

    echo("ROTATION SNAP: "@EWorldEditor.snapRotations);
    
}

EditorMap.bindCmd(keyboard, "[", "GFX_AddOn_DecGrid();", "");
EditorMap.bindCmd(keyboard, "]", "GFX_AddOn_IncGrid();", "");
EditorMap.bindCmd(keyboard, "g", "GFX_AddOn_SnapGrid();", "");
EditorMap.bindCmd(keyboard, "r", "GFX_AddOn_SnapRotation();", "");

// *************************************************************************** END


3) Open file editor.cs
4) add exec("./GFXAddOn.cs") here:

...

// Tools
exec("./editor.bind.cs");
exec("./ObjectBuilderGui.gui");

// AndyGFX Editor AddOn
exec("./GFXAddOn.cs");

// New World Editor
exec("./EditorGui.gui");
exec("./EditorGui.cs");

...

-----------------------------------------------
4) FEATURES:
key g = snap to grid ON/OFF
key r = snap rotation ON/OFF
key [ = decrease grid size
key ] = increase grid size
-----------------------------------------------
That's all.

#1
08/04/2004 (10:22 am)
Does this actually cause objects to snap to grid? It doesn't look like any of that code is implemented here. It just looks like you have a nice way to change grid size and toggle the grid on/off.
#2
08/04/2004 (12:54 pm)
The editor itself already has snap-to-grid and snap-rotation functionality (EWorldEditor.SnapToGrid = 1; enables this), these are cool shortcut keys to turn it on and off (instead of going to the 'World Preferences' menu and clicking the check-box.)

Also I don't know if it was ever fixed, but in a recent head version all the snap-to UI was buried behind the other UI elements in the World Preferences menu. You had to go into the GUI editor mode and re-arrange stuff to get them visible and useful again.
#3
08/04/2004 (1:06 pm)
Aha, that's why I never saw them !!!

Thanks Luke !!
#4
08/11/2004 (8:04 pm)
Useful discussion!
#5
08/12/2004 (6:01 pm)
Quote:Useful discussion!

No kidding. I had no idea there was a snap-to function!
#6
08/16/2004 (5:44 am)
Me neither. Torque just became a couple degrees cooler.