I get the error "undeclared (first use this function)" after altering some code..
I changed the Terrain example into using a .3ds -file..
But I have no clue on whats wrong.. I'm not a C++ guru.. :p
Here is the whole code (Plese give eny advices and optimizations)..
undeclared (first use this function)
undeclared (first use this function)
Last edited by Bluelight on Thu Sep 22, 2005 12:11 am, edited 4 times in total.
BlueLight
Update.. :p
Ok I have tried some diffrent stuff here, but I can't make it compile with no errors.. :p
The Collision is the problem, so I made it into a comment, lol
I'm realy a n00b when it comes to C++ and I'm in need of some serious help!
Here is a screenshot of my project as it is now:
infernusweb.net/level-view.jpg (1.13 MB)
Code:
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
class MyEventReceiver : public IEventReceiver { public:
MyEventReceiver(scene::ISceneNode* terrain);
private:
scene::ISceneNode* terrain;
};
int main()
{
// use OpenGL driver type
video::E_DRIVER_TYPE driverType = video::EDT_DIRECTX9;
printf("Loading...");
driverType = video::EDT_OPENGL;
// create device
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(1280, 1024),32,true,false,false);
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
// add a logo
env->addImage(driver->getTexture("media/inf.tga"),
core::position2d<s32>(10,10));
// add some text
gui::IGUIStaticText* text = env->addStaticText(
L"Visit http://www.infernusweb.net",
core::rect<s32>(10,1005,134,1014), true, true, 0, -1, true);
// add camera
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0,100.0f,1200.0f);
camera->setPosition(core::vector3df(1,800,1));
camera->setTarget(core::vector3df(1,10,1));
camera->setFarValue(20000.0f);
// disable mouse cursor
device->getCursorControl()->setVisible(false);
// add terrain scene node
driver->setFog(video::SColor(0,138,125,81), true, 250, 1000, 0, true);
scene::IAnimatedMesh* Terrain = smgr->getMesh("3ds/ground.3ds");
if (Terrain)
{
// create mesh copy with tangent informations from original mesh
scene::IMesh* tangentSphereMesh2 =
smgr->getMeshManipulator()->createMeshWithTangents(Terrain->getMesh(0));
// set the alpha value of all vertices to 200
smgr->getMeshManipulator()->setVertexColorAlpha(tangentSphereMesh2, 200);
// scale the mesh by factor 50
smgr->getMeshManipulator()->scaleMesh(
tangentSphereMesh2, core::vector3df(10,10,10));
// create mesh scene node
scene::ISceneNode* sphere2 = smgr->addMeshSceneNode(tangentSphereMesh2);
sphere2->setPosition(core::vector3df(-70,130,45));
// drop mesh because we created it with a create.. call.
tangentSphereMesh2->drop();
}
// add earth sphere
scene::IAnimatedMesh* earthMesh = smgr->getMesh("media/earth.x");
if (earthMesh)
{
// create mesh copy with tangent informations from original earth.x mesh
scene::IMesh* tangentSphereMesh =
smgr->getMeshManipulator()->createMeshWithTangents(earthMesh->getMesh(0));
// set the alpha value of all vertices to 200
smgr->getMeshManipulator()->setVertexColorAlpha(tangentSphereMesh, 200);
// scale the mesh by factor 50
smgr->getMeshManipulator()->scaleMesh(
tangentSphereMesh, core::vector3df(50,50,50));
// create mesh scene node
scene::ISceneNode* sphere = smgr->addMeshSceneNode(tangentSphereMesh);
sphere->setPosition(core::vector3df(-70,130,45));
// load heightmap, create normal map from it and set it
video::ITexture* earthNormalMap = driver->getTexture("media/earthbump.bmp");
driver->makeNormalMapTexture(earthNormalMap, 20.0f);
sphere->setMaterialTexture(1, earthNormalMap);
// adjust material settings
sphere->setMaterialFlag(video::EMF_FOG_ENABLE, true);
sphere->setMaterialType(video::EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA);
// add rotation animator
scene::ISceneNodeAnimator* anim =
smgr->createRotationAnimator(core::vector3df(0,0.1f,0));
sphere->addAnimator(anim);
anim->drop();
// drop mesh because we created it with a create.. call.
tangentSphereMesh->drop();
}
// add light 1 (nearly red)
scene::ILightSceneNode* light1 =
smgr->addLightSceneNode(0, core::vector3df(0,0,0),
video::SColorf(0.5f, 1.0f, 0.5f, 0.0f), 200.0f);
// add fly circle animator to light 1
scene::ISceneNodeAnimator* anim2 =
smgr->createFlyCircleAnimator (core::vector3df(50,300,0),190.0f, -0.003f);
light1->addAnimator(anim2);
anim2->drop();
// attach billboard to the light
scene::ISceneNode* bill =
smgr->addBillboardSceneNode(light1, core::dimension2d<f32>(60, 60));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->setMaterialTexture(0, driver->getTexture("media/particlered.bmp"));
// add light 2 (gray)
scene::ISceneNode* light2 =
smgr->addLightSceneNode(0, core::vector3df(0,0,0),
video::SColorf(1.0f, 0.2f, 0.2f, 0.0f), 200.0f);
// add fly circle animator to light 2
anim2 = smgr->createFlyCircleAnimator (core::vector3df(0,150,0),200.0f);
light2->addAnimator(anim2);
anim2->drop();
// attach billboard to light
bill = smgr->addBillboardSceneNode(light2, core::dimension2d<f32>(120, 120));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->setMaterialTexture(0, driver->getTexture("media/particlewhite.bmp"));
// add particle system
scene::IParticleSystemSceneNode* ps =
smgr->addParticleSystemSceneNode(false, light2);
ps->setParticleSize(core::dimension2d<f32>(30.0f, 40.0f));
// create and set emitter
scene::IParticleEmitter* em = ps->createBoxEmitter(
core::aabbox3d<f32>(-3,0,-3,3,1,3),
core::vector3df(0.0f,0.03f,0.0f),
80,100,
video::SColor(0,255,255,255), video::SColor(0,255,255,255),
400,1100);
ps->setEmitter(em);
em->drop();
// create and set affector
scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
ps->addAffector(paf);
paf->drop();
// adjust some material settings
ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialTexture(0, driver->getTexture("media/fireball.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
/*
// create triangle selector for the terrain
scene::ITriangleSelector* selector
= smgr->CTriangleSelector(terrain, 0);
Terrain->setTriangleSelector(selector);
selector->drop();
// create collision response animator and attach it to the camera
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(60,100,60),
core::vector3df(0,0,0),
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
// create event receiver
MyEventReceiver receiver(terrain);
device->setEventReceiver(&receiver);
*/
// create skybox
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
smgr->addSkyBoxSceneNode(
driver->getTexture("media/irrlicht2_up.jpg"),
driver->getTexture("media/irrlicht2_dn.jpg"),
driver->getTexture("media/irrlicht2_lf.jpg"),
driver->getTexture("media/irrlicht2_rt.jpg"),
driver->getTexture("media/irrlicht2_ft.jpg"),
driver->getTexture("media/irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
// display frames per second in window title
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"A game by infernus - Driver type: [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
The Collision is the problem, so I made it into a comment, lol
I'm realy a n00b when it comes to C++ and I'm in need of some serious help!
Here is a screenshot of my project as it is now:
infernusweb.net/level-view.jpg (1.13 MB)
Code:
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
class MyEventReceiver : public IEventReceiver { public:
MyEventReceiver(scene::ISceneNode* terrain);
private:
scene::ISceneNode* terrain;
};
int main()
{
// use OpenGL driver type
video::E_DRIVER_TYPE driverType = video::EDT_DIRECTX9;
printf("Loading...");
driverType = video::EDT_OPENGL;
// create device
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(1280, 1024),32,true,false,false);
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
// add a logo
env->addImage(driver->getTexture("media/inf.tga"),
core::position2d<s32>(10,10));
// add some text
gui::IGUIStaticText* text = env->addStaticText(
L"Visit http://www.infernusweb.net",
core::rect<s32>(10,1005,134,1014), true, true, 0, -1, true);
// add camera
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0,100.0f,1200.0f);
camera->setPosition(core::vector3df(1,800,1));
camera->setTarget(core::vector3df(1,10,1));
camera->setFarValue(20000.0f);
// disable mouse cursor
device->getCursorControl()->setVisible(false);
// add terrain scene node
driver->setFog(video::SColor(0,138,125,81), true, 250, 1000, 0, true);
scene::IAnimatedMesh* Terrain = smgr->getMesh("3ds/ground.3ds");
if (Terrain)
{
// create mesh copy with tangent informations from original mesh
scene::IMesh* tangentSphereMesh2 =
smgr->getMeshManipulator()->createMeshWithTangents(Terrain->getMesh(0));
// set the alpha value of all vertices to 200
smgr->getMeshManipulator()->setVertexColorAlpha(tangentSphereMesh2, 200);
// scale the mesh by factor 50
smgr->getMeshManipulator()->scaleMesh(
tangentSphereMesh2, core::vector3df(10,10,10));
// create mesh scene node
scene::ISceneNode* sphere2 = smgr->addMeshSceneNode(tangentSphereMesh2);
sphere2->setPosition(core::vector3df(-70,130,45));
// drop mesh because we created it with a create.. call.
tangentSphereMesh2->drop();
}
// add earth sphere
scene::IAnimatedMesh* earthMesh = smgr->getMesh("media/earth.x");
if (earthMesh)
{
// create mesh copy with tangent informations from original earth.x mesh
scene::IMesh* tangentSphereMesh =
smgr->getMeshManipulator()->createMeshWithTangents(earthMesh->getMesh(0));
// set the alpha value of all vertices to 200
smgr->getMeshManipulator()->setVertexColorAlpha(tangentSphereMesh, 200);
// scale the mesh by factor 50
smgr->getMeshManipulator()->scaleMesh(
tangentSphereMesh, core::vector3df(50,50,50));
// create mesh scene node
scene::ISceneNode* sphere = smgr->addMeshSceneNode(tangentSphereMesh);
sphere->setPosition(core::vector3df(-70,130,45));
// load heightmap, create normal map from it and set it
video::ITexture* earthNormalMap = driver->getTexture("media/earthbump.bmp");
driver->makeNormalMapTexture(earthNormalMap, 20.0f);
sphere->setMaterialTexture(1, earthNormalMap);
// adjust material settings
sphere->setMaterialFlag(video::EMF_FOG_ENABLE, true);
sphere->setMaterialType(video::EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA);
// add rotation animator
scene::ISceneNodeAnimator* anim =
smgr->createRotationAnimator(core::vector3df(0,0.1f,0));
sphere->addAnimator(anim);
anim->drop();
// drop mesh because we created it with a create.. call.
tangentSphereMesh->drop();
}
// add light 1 (nearly red)
scene::ILightSceneNode* light1 =
smgr->addLightSceneNode(0, core::vector3df(0,0,0),
video::SColorf(0.5f, 1.0f, 0.5f, 0.0f), 200.0f);
// add fly circle animator to light 1
scene::ISceneNodeAnimator* anim2 =
smgr->createFlyCircleAnimator (core::vector3df(50,300,0),190.0f, -0.003f);
light1->addAnimator(anim2);
anim2->drop();
// attach billboard to the light
scene::ISceneNode* bill =
smgr->addBillboardSceneNode(light1, core::dimension2d<f32>(60, 60));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->setMaterialTexture(0, driver->getTexture("media/particlered.bmp"));
// add light 2 (gray)
scene::ISceneNode* light2 =
smgr->addLightSceneNode(0, core::vector3df(0,0,0),
video::SColorf(1.0f, 0.2f, 0.2f, 0.0f), 200.0f);
// add fly circle animator to light 2
anim2 = smgr->createFlyCircleAnimator (core::vector3df(0,150,0),200.0f);
light2->addAnimator(anim2);
anim2->drop();
// attach billboard to light
bill = smgr->addBillboardSceneNode(light2, core::dimension2d<f32>(120, 120));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
bill->setMaterialTexture(0, driver->getTexture("media/particlewhite.bmp"));
// add particle system
scene::IParticleSystemSceneNode* ps =
smgr->addParticleSystemSceneNode(false, light2);
ps->setParticleSize(core::dimension2d<f32>(30.0f, 40.0f));
// create and set emitter
scene::IParticleEmitter* em = ps->createBoxEmitter(
core::aabbox3d<f32>(-3,0,-3,3,1,3),
core::vector3df(0.0f,0.03f,0.0f),
80,100,
video::SColor(0,255,255,255), video::SColor(0,255,255,255),
400,1100);
ps->setEmitter(em);
em->drop();
// create and set affector
scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
ps->addAffector(paf);
paf->drop();
// adjust some material settings
ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialTexture(0, driver->getTexture("media/fireball.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
/*
// create triangle selector for the terrain
scene::ITriangleSelector* selector
= smgr->CTriangleSelector(terrain, 0);
Terrain->setTriangleSelector(selector);
selector->drop();
// create collision response animator and attach it to the camera
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(60,100,60),
core::vector3df(0,0,0),
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
// create event receiver
MyEventReceiver receiver(terrain);
device->setEventReceiver(&receiver);
*/
// create skybox
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
smgr->addSkyBoxSceneNode(
driver->getTexture("media/irrlicht2_up.jpg"),
driver->getTexture("media/irrlicht2_dn.jpg"),
driver->getTexture("media/irrlicht2_lf.jpg"),
driver->getTexture("media/irrlicht2_rt.jpg"),
driver->getTexture("media/irrlicht2_ft.jpg"),
driver->getTexture("media/irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
// display frames per second in window title
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"A game by infernus - Driver type: [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
BlueLight
Change
to
Code: Select all
scene::ITriangleSelector* selector = smgr->CTriangleSelector(terrain, 0);
Code: Select all
scene::ITriangleSelector* selector = smgr->createTriangleSelector( tangentSphereMesh2, sphere2 );