Skip to content

Instantly share code, notes, and snippets.

@lukaspj
Created March 28, 2015 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaspj/63f59cea3b7212e8e256 to your computer and use it in GitHub Desktop.
Save lukaspj/63f59cea3b7212e8e256 to your computer and use it in GitHub Desktop.
IJWLayer example Torque6
using HorribleHackz.CustomAttributes;
using IJWLayer;
using Con = IJWLayer.Con;
using Scene = IJWLayer.Scene;
namespace HorribleHackz
{
[ConsoleClass]
class AnimatedMeshExample
{
public static void create()
{
// Create some dwarfs!
SceneEntityWrapper entity1 = new SceneEntityWrapper()
{
Template = "^AnimatedMeshExample/entities/bigDwarfRedDwarf.taml",
Position = Point3F.Zero(),
Rotation = Point3F.Zero()
};
// Register the object! (Similar to how you do it in C++)
entity1.registerObject();
// Add it to the scene!
Scene.addEntity(entity1, "Dwarf Meshes");
// Let there be lights!
SceneEntityWrapper light1 = new SceneEntityWrapper()
{
Template = "^AnimatedMeshExample/entities/lightTest2.taml",
Position = Point3F.Zero()
};
light1.registerObject();
Scene.addEntity(light1, "Lights");
// More lights I guess
Scene.setDirectionalLight(new Point3F(1, 1, -1), "0.8 0.8 0.8", "0.1 0.1 0.1");
}
public static void destroy()
{
Con.print("DESTROYED AnimatedMeshExample MODULE");
}
}
}
using HorribleHackz.CustomAttributes;
using IJWLayer;
using Con = IJWLayer.Con;
using Scene = IJWLayer.Scene;
namespace HorribleHackz
{
[ConsoleClass]
internal class ExampleRoom
{
public static void create()
{
// Dwarfs like something to stand on. Free fall is bad for the health!
var example_room = new SceneEntityWrapper
{
Template = "^ExampleRoom/entities/ExampleRoom.taml",
Position = new Point3F {x = 0, y = -100, z = 0}
};
Scene.addEntity(example_room, "Floor");
}
public static void destroy()
{
Con.print("DESTROYED ExampleRoom MODULE");
}
}
}
using System;
using System.IO;
using System.Reflection;
using HorribleHackz.CustomAttributes;
using IJWLayer;
using Con = IJWLayer.Con;
namespace HorribleHackz
{
internal class MainClass
{
public static ModuleManagerWrapper ModuleDatabase;
public static AssetManagerWrapper AssetDatabase;
[ScriptEntryPoint]
public static void EntryPoint()
{
// Mandatory initialization, since these can't be set based on the non-existant main.cs
var CSDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
Platform.setMainDotCsDir(CSDir);
Platform.setCurrentDirectory(CSDir);
// Logging settings
Con.setLogMode(2);
Script.setScriptExecEcho(false);
Script.trace(false);
// Not really necessary, but shows how globals work
Global.SetBool("Scripts::ignoreDSOs", true);
// This is my realm!
EngineVersion.setCompanyAndProduct("LukasPJ", "Torque6");
// Find the Databases by name
ModuleDatabase = ModuleManagerWrapper.Wrap("ModuleDatabase");
AssetDatabase = AssetManagerWrapper.Wrap("AssetDatabase");
// Make sure they have been created
if (!ModuleDatabase.IsAlive())
throw new Exception("ModuleDatabase not found");
if (!AssetDatabase.IsAlive())
throw new Exception("AssetDatabase not found");
// Didn't implement this property yet.
ModuleDatabase.setFieldValue("EchoInfo", "false");
AssetDatabase.EchoInfo = false;
AssetDatabase.IgnoreAutoUnload = true;
// Scan modules.
ModuleDatabase.scanModules("modules");
ModuleDatabase.scanModules("../shared-modules");
// Load AppCore module.
ModuleDatabase.loadExplicit("AppCore");
// Load the modules needed for this example
ModuleDatabase.loadExplicit("Console");
ModuleDatabase.loadExplicit("FreeViewCamera");
}
[ConsoleFunction]
public static void onExit()
{
// Unload the AppCore module.
ModuleDatabase.unloadExplicit("AppCore");
}
[ConsoleFunction]
public static void androidBackButton(string val)
{
// Quit on button down
if (val == "1")
Con.quit();
}
}
}
using HorribleHackz.Framework;
namespace HorribleHackz
{
class Program
{
static void Main(string[] args)
{
Torque6Main.Libraries libraries = new Torque6Main.Libraries()
{
Windows32bit = "Torque6_DEBUG.dll",
Windows64bit = "Torque6_DEBUG.dll",
Linux32bit = "Torque6_DEBUG.so",
Linux64bit = "Torque6_DEBUG.so",
};
Torque6Main.InitializeTorque6(args, libraries);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment