Tutorial and Mac OS X

Problems building or running the engine, queries about how to use features etc.
Post Reply
swissrudeboy
Gnoblar
Posts: 7
Joined: Sat Feb 26, 2005 5:39 pm

Tutorial and Mac OS X

Post by swissrudeboy »

Hello,
I tried to do the turorial on the wiki page and when I get before "Blinking Lights" everything compiles ok but when I run it I get a strange error:
Parsing script Example.particle
Parsing script smoke.particle
Parsing script DP3.overlay
Parsing script Example-CubeMapping.overlay
Parsing script Example-DynTex.overlay
Parsing script Example-Water.overlay
Parsing script Shadows.overlay
Finished parsing scripts for resource group General
Texture: flare.png: Loading 1 faces(PF_R8G8B8,256x256x1) with 5 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
Fatal signal: Bus Error (SDL Parachute Deployed)

Executable “Space” has exited with status 246.
The source code that I use is:
#include "ExampleApplication.h"
class LightFlasherControllerFunction: public WaveformControllerFunction
{
public:
LightFlasherControllerFunction(WaveformType wavetype, Real frequency, Real phase): WaveformControllerFunction(wavetype, 0, frequency, phase, 1, true)
{

}
};

class LightFlasher: public ControllerValue<Real>
{
protected:
Light* mLight;
Billboard* mBillboard;
ColourValue mMaxColour;
Real intensity;
public:
LightFlasher(Light* light, Billboard* billboard, ColourValue maxColour)
{
mLight = light;
mBillboard = billboard;
mMaxColour = maxColour;
}

virtual Real getValue (void) const
{
return intensity;
}

virtual void setValue (Real value)
{
intensity = value;

ColourValue newColour;

// Attenuate the brightness of the light
newColour.r = mMaxColour.r * intensity;
newColour.g = mMaxColour.g * intensity;
newColour.b = mMaxColour.b * intensity;

mLight->setDiffuseColour(newColour);
mBillboard->setColour(newColour);
}
};

class SpaceApplication: public ExampleApplication
{
protected:
// The set of all the billboards used for the avionic lights
BillboardSet* mLights;

// Billboards
Billboard* mRedLightBoard;
Billboard* mBlueLightBoard;
Billboard* mWhiteLightBoard;

// Lights
Light* mRedLight;
Light* mBlueLight;
Light* mWhiteLight;

// Light flashers
ControllerValueRealPtr mRedLightFlasher;
ControllerValueRealPtr mBlueLightFlasher;
ControllerValueRealPtr mWhiteLightFlasher;

// Light controller functions
ControllerFunctionRealPtr mRedLightControllerFunc;
ControllerFunctionRealPtr mBlueLightControllerFunc;
ControllerFunctionRealPtr mWhiteLightControllerFunc;

// Light controllers
Controller<Real>* mRedLightController;
Controller<Real>* mBlueLightController;
Controller<Real>* mWhiteLightController;

Entity* mShip;
SceneNode* mShipNode;
void createScene(void);
void createFrameListener(void);

};



void SpaceApplication::createScene(void)
{
// Light flashers
mRedLightFlasher = ControllerValueRealPtr(
new LightFlasher(mRedLight, mRedLightBoard, ColourValue::Red));
mBlueLightFlasher = ControllerValueRealPtr(
new LightFlasher(mBlueLight, mBlueLightBoard, ColourValue::Blue));
mWhiteLightFlasher = ControllerValueRealPtr(
new LightFlasher(mWhiteLight, mWhiteLightBoard, ColourValue::White));


// Light controller functions
mRedLightControllerFunc = ControllerFunctionRealPtr(
new LightFlasherControllerFunction(Ogre::WFT_SINE, 0.5, 0.0));
mBlueLightControllerFunc = ControllerFunctionRealPtr(
new LightFlasherControllerFunction(Ogre::WFT_SQUARE, 0.5, 0.5));
mWhiteLightControllerFunc = ControllerFunctionRealPtr(
new LightFlasherControllerFunction(Ogre::WFT_TRIANGLE, 4, 0.0));


// Light controllers
ControllerManager* mControllerManager = &ControllerManager::getSingleton();
mRedLightController = mControllerManager->createController(
mControllerManager->getFrameTimeSource(), ControllerValueRealPtr(mRedLightFlasher),
ControllerFunctionRealPtr(mRedLightControllerFunc));
mBlueLightController = mControllerManager->createController(
mControllerManager->getFrameTimeSource(), ControllerValueRealPtr(mBlueLightFlasher),
ControllerFunctionRealPtr(mBlueLightControllerFunc));
mWhiteLightController = mControllerManager->createController(
mControllerManager->getFrameTimeSource(), ControllerValueRealPtr(mWhiteLightFlasher),
ControllerFunctionRealPtr(mWhiteLightControllerFunc));

// First create the BillboardSet. This will define the materials for the billboards
// in its set to use
mLights = mSceneMgr->createBillboardSet("FlyingLights");
mLights->setMaterialName("Examples/FlyingLightMaterial");
mShipNode->attachObject(mLights);


// Create a skybox
mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
mShip = mSceneMgr->createEntity("razor", "razor.mesh");
mShipNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mShipNode->attachObject(mShip);
// Set a very low level of ambient lighting
mSceneMgr->setAmbientLight(ColourValue(0.2, 0.2, 0.2));
//High level
//mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

// Red light billboard, in "off" state
Vector3 redLightPosition(74, -8, -70);
mRedLightBoard = mLights->createBillboard(redLightPosition);
mRedLightBoard->setColour(ColourValue::Black);

// Blue light billboard, in "off" state
Vector3 blueLightPosition(-87, -8, -70);
mBlueLightBoard = mLights->createBillboard(blueLightPosition);
mBlueLightBoard->setColour(ColourValue::Black);

// White light billboard, in "off" state
Vector3 whiteLightPosition(-5.5, 30, -80);
mWhiteLightBoard = mLights->createBillboard(whiteLightPosition);
mWhiteLightBoard->setColour(ColourValue::Black);
// Red light, in "off" state
mRedLight = mSceneMgr->createLight("RedFlyingLight");
mRedLight->setType(Light::LT_POINT);
mRedLight->setPosition(redLightPosition);
mRedLight->setDiffuseColour(ColourValue::Black);
mShipNode->attachObject(mRedLight);

// Blue light, in "off" state
mBlueLight = mSceneMgr->createLight("BlueFlyingLight");
mBlueLight->setType(Light::LT_POINT);
mBlueLight->setPosition(blueLightPosition);
mBlueLight->setDiffuseColour(ColourValue::Black);
mShipNode->attachObject(mBlueLight);

// White light in "off" state
mWhiteLight = mSceneMgr->createLight("WhiteFlyingLight");
mWhiteLight->setType(Light::LT_POINT);
mWhiteLight->setPosition(whiteLightPosition);
mWhiteLight->setDiffuseColour(ColourValue::Black);
mShipNode->attachObject(mWhiteLight);

}


class SpaceFrameListener: public ExampleFrameListener
{
protected:
SceneNode* mShipNode;


public:
SpaceFrameListener(RenderWindow* win, Camera* cam, SceneNode* shipNode): ExampleFrameListener(win, cam)
{
mShipNode = shipNode;
};

bool frameStarted(const FrameEvent& evt);

};

void SpaceApplication::createFrameListener(void)
{
mFrameListener= new SpaceFrameListener(mWindow, mCamera, mShipNode);
mRoot->addFrameListener(mFrameListener);
}

// -----------------------
bool SpaceFrameListener::frameStarted(const FrameEvent& evt)
{
// Move upto 80 units/second
Real MoveFactor = 80.0 * evt.timeSinceLastFrame;

// Copy the current state of the input devices
mInputDevice->capture();

// Move the ship node!
if(mInputDevice->isKeyDown(Ogre::KC_UP))
mShipNode->translate(0.0, MoveFactor, 0.0);

if(mInputDevice->isKeyDown(Ogre::KC_DOWN))
mShipNode->translate(0.0, -MoveFactor, 0.0);

// Instead of moving the ship left and right, rotate it using yaw()
if(mInputDevice->isKeyDown(Ogre::KC_LEFT)) mShipNode->yaw(Angle(MoveFactor));
if(mInputDevice->isKeyDown(Ogre::KC_RIGHT)) mShipNode->yaw(Angle(-MoveFactor));


return true;
}
The error must be in the new lines added in "LightsCameraAction" because before it worked without problems.
Thanks for the help!
swissrudeboy
Gnoblar
Posts: 7
Joined: Sat Feb 26, 2005 5:39 pm

Post by swissrudeboy »

Damn now I understood were the problem is, the code was all messed up...
Post Reply