Code: Select all
// cam is valid RF2Camera
RFGetGame().setControlObject(cam);
Code: Select all
RFGetGame().setControlObject(RFGetPlayer());
There will be different types of cameras:
1. Generic camera (free look)
2. First Person Camera (duh)
3. Third Person Camera (first person with a z offset)
4. Chase Camera (chases the object it is attached to)
5. Isometric Camera (Diablo/Dungeon Siege style)
6. Cinematic Camera (Resident Evil style fixed camera with frustum detection to switch cameras)
7. Orbital Camera (rotates around the object at a specified offset)
The code for the shell is now available in the Subversion repository at SourceForge. The URL is:
https://realityfactory2.svn.sourceforge ... unk/RFOgre
I will post the code to the test scripts. Save each section to the file named at the top of the section. Drop it in the bin folder after you compile.
Code: Select all
// main.nut
function onInitGame()
{
setWindowTitle("My Test Game");
showConfigDialog(false);
// Add bootstrap zip
addResourcePath("Bootstrap", "./packs/OgreCore.zip", "Zip", false);
// Add game specific paths here
addResourcePath("General", "./", "FileSystem", false);
addResourcePath("General", "./fonts", "FileSystem", false);
addResourcePath("General", "./materials/programs", "FileSystem", false);
addResourcePath("General", "./materials/scripts", "FileSystem", false);
addResourcePath("General", "./materials/textures", "FileSystem", false);
addResourcePath("General", "./models", "FileSystem", false);
addResourcePath("General", "./overlays", "FileSystem", false);
addResourcePath("General", "./particle", "FileSystem", false);
addResourcePath("General", "./gui", "FileSystem", false);
addResourcePath("General", "./DeferredShadingMedia", "FileSystem", false);
addResourcePath("General", "./PCZAppMedia", "FileSystem", false);
addResourcePath("General", "./packs/cubemap.zip", "Zip", false);
addResourcePath("General", "./packs/dragon.zip", "Zip", false);
addResourcePath("General", "./packs/fresneldemo.zip", "Zip", false);
addResourcePath("General", "./packs/ogretestmap.zip", "Zip", false);
addResourcePath("General", "./packs/skybox.zip", "Zip", false);
runScript("plane.nut");
runScript("light.nut");
runScript("player.nut");
print("onInitGame\n");
}
function onShutdown()
{
print("onShutdown\n");
}
function quitGame(v)
{
print("Quitting game\n");
quit();
}
function onInitGraphics()
{
print("onInitGraphics\n");
local input = RFGetInput();
input.bind(input.EVENT_TYPE_KEYPRESS, KEY_ESCAPE, "quitGame");
input.bind(input.EVENT_TYPE_KEYPRESS, KEY_W, "moveForward");
input.bind(input.EVENT_TYPE_KEYPRESS, KEY_S, "moveBackward");
input.bind(input.EVENT_TYPE_KEYPRESS, KEY_A, "moveLeft");
input.bind(input.EVENT_TYPE_KEYPRESS, KEY_D, "moveRight");
local wrl = RFGetWorld();
wrl.setAmbientLight(0.5, 0.5, 0.5);
wrl.setSkyBox(true, "Examples/SpaceSkyBox", 50.0);
cam <- RFBaseCamera("mainCamera");
local vecTmp = Vector3(0.0, 99.0, 0.0);
local tp = RFPlane("TestPlane01", "TestPlane");
tp.setPosition(vecTmp);
local l = RFLight("BlueLight01", "BlueSpotlight");
local gl = RFLight("GreenLight01", "GreenSpotlight");
}
function moveForward(val)
{
cam.moveForward(10.0);
}
function moveBackward(val)
{
cam.moveBackward(5.0);
}
function moveLeft(val)
{
cam.moveLeft(10.0);
}
function moveRight(val)
{
cam.moveRight(10.0);
}
Code: Select all
// Light.nut
BlueSpotlight <- {
DiffuseColor = "0.5 0.5 1.0 1.0",
//SpecularColor = "0.0 0.0 0.0 0.0",
//
Type = LIGHT_TYPE_SPOTLIGHT
}
function BlueSpotlight::onCreate(obj)
{
print("BlueSpotlight::onCreate\n");
local pos = Vector3(-200.0, 150.0, -100.0);
obj.setPosition(pos);
local dir = Vector3(200.0, -150.0, 100.0);
Vector3Normalize(dir);
obj.setDirection(dir);
}
GreenSpotlight <- {
DiffuseColor = "0.5 1.0 0.5 1.0",
Type = LIGHT_TYPE_SPOTLIGHT
}
function GreenSpotlight::onCreate(obj)
{
print("GreenSpotlight::onCreate\n");
local pos = Vector3(0.0, 150.0, -100.0);
obj.setPosition(pos);
local dir = Vector3(0.0, -150.0, 100.0);
Vector3Normalize(dir);
obj.setDirection(dir);
}
Code: Select all
// Plane.nut
TestPlane <- {
Normal = "0.0 1.0 0.0",
Distance = 100.0,
Width = 1500,
Height = 1500,
NumXSegments = 20,
NumYSegments = 20,
GenerateNormals = true,
NumTexCoordSets = 1,
TileU = 60.0,
TileV = 60.0
}
function TestPlane::onCreate(obj)
{
print("TestPlane::onCreate\n");
obj.setMaterial("Examples/Rockwall");
obj.setCastShadows(false);
}
Code: Select all
//player.nut
PlayerData <- {
hp = 100,
mp = 50
}
function PlayerData::onCreate(obj)
{
obj.setMesh("robot.mesh");
obj.setSkeleton("robot.skeleton");
obj.setMaterial("Examples/Robot");
obj.setPosition(Vector3(0.0, 0.0, 0.0));
obj.setScale(Vector3(0.5, 0.5, 0.5));
print("Player::onCreate\n");
}