`q3node' undeclared, first use of this function

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
humbrol2
Posts: 1
Joined: Wed Jan 05, 2005 5:02 am

`q3node' undeclared, first use of this function

Post by humbrol2 »

86 C:\irrlicht\irrlicht-0.7\Project\HelloWorld.cpp `q3node' undeclared (first use this function)

getting this error when i try to run this code

Code: Select all

// Include the Irrlicht header
#include "irrlicht.h"
#include <iostream>
#pragma comment(lib, "Irrlicht.lib")

// Irrlicht Namespaces
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;


int main()
{
   // ask user for driver

video::E_DRIVER_TYPE driverType = video::EDT_DIRECTX9;
printf("Please select the driver you want for this example:\n"\
       " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.2\n"\
       " (d) Software Renderer\n (e) NullDevice\n (otherKey) exit\n\n");

char i;
std::cin >> i;

switch(i)
{
   case 'a': driverType = video::EDT_DIRECTX9;	break;
   case 'b': driverType = video::EDT_DIRECTX8;	break;
   case 'c': driverType = video::EDT_OPENGL;   break;
   case 'd': driverType = video::EDT_SOFTWARE; break;
   case 'e': driverType = video::EDT_NULL;     break;
  default: return 1;
}

// create device and exit if creation failed

IrrlichtDevice *device =
    createDevice(driverType, core::dimension2d<s32>(640, 480));

if (device == 0)
   return 1;
   
   video::IVideoDriver* driver = device->getVideoDriver();
   scene::ISceneManager* smgr = device->getSceneManager();
   
   device->getFileSystem()->addZipFileArchive("c:/irrlicht/irrlicht-0.7/media/map-20kdm2.pk3");
   
   scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node = 0;

if (mesh)
    node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
    
    if (node)
    node->setPosition(core::vector3df(-1300,-144,-1249));
    
    smgr->addCameraSceneNodeFPS();
    
    int lastFPS = -1;

while(device->run())
{
  driver->beginScene(true, true, video::SColor(0,200,200,200));
  smgr->drawAll();
  driver->endScene();

  int fps = driver->getFPS();

  if (lastFPS != fps)
  {
     core::stringw str = L"Irrlicht Engine - Vertex and pixel shader example [";
     str += driver->getName();
     str += "] FPS:";
     str += fps;
     device->setWindowCaption(str.c_str());
     lastFPS = fps;
  }
}
     device->drop();
  return 0;
scene::ITriangleSelector* selector = 0;
	
	if (q3node)
	{		
		q3node->setPosition(core::vector3df(-1370,-130,-1400));

		selector = smgr->createOctTreeTriangleSelector(
            q3levelmesh->getMesh(0), q3node, 128);
		q3node->setTriangleSelector(selector);
		selector->drop();
	}
  scene::ICameraSceneNode* camera = 	
		camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
	camera->setPosition(core::vector3df(-100,50,-150));

	scene::ISceneNodeAnimator* anim =
    smgr->createCollisionResponseAnimator(
		selector, camera, core::vector3df(30,50,30),
		core::vector3df(0,-100,0), 100.0f, 
		core::vector3df(0,50,0));

	camera->addAnimator(anim);
	anim->drop();
  // disable mouse cursor

	device->getCursorControl()->setVisible(false);

	// add billboard

	scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
	bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
	bill->setMaterialTexture(0, driver->getTexture(
         "../../media/particle.bmp"));
	bill->setMaterialFlag(video::EMF_LIGHTING, false);
	bill->setSize(core::dimension2d<f32>(20.0f, 20.0f));

	// add 3 animated faeries.

	video::SMaterial material;
	material.Texture1 = driver->getTexture(
         "../../media/faerie2.bmp");
	material.Lighting = true;

	scene::IAnimatedMeshSceneNode* node = 0;
	scene::IAnimatedMesh* faerie = smgr->getMesh(
        "../../media/faerie.md2");

	if (faerie)
	{
		node = smgr->addAnimatedMeshSceneNode(faerie);
		node->setPosition(core::vector3df(-70,0,-90));
		node->setMD2Animation(scene::EMAT_RUN);
		node->getMaterial(0) = material;

		node = smgr->addAnimatedMeshSceneNode(faerie);
		node->setPosition(core::vector3df(-70,0,-30));
		node->setMD2Animation(scene::EMAT_SALUTE);
		node->getMaterial(0) = material;

		node = smgr->addAnimatedMeshSceneNode(faerie);
		node->setPosition(core::vector3df(-70,0,-60));
		node->setMD2Animation(scene::EMAT_JUMP);
		node->getMaterial(0) = material;
	}

	material.Texture1 = 0;
	material.Lighting = false;

	// Add a light

	smgr->addLightSceneNode(0, core::vector3df(-60,100,400),
		video::SColorf(1.0f,1.0f,1.0f,1.0f),
		600.0f);
  scene::ISceneNode* selectedSceneNode = 0;
	scene::ISceneNode* lastSelectedSceneNode = 0;

	
	int lastFPS = -1;

	while(device->run())
	{
		driver->beginScene(true, true, 0);

		smgr->drawAll();
	core::line3d<f32> line;
		line.start = camera->getPosition();
		line.end = line.start +
         (camera->getTarget() - line.start).normalize() * 1000.0f;

		core::vector3df intersection;
		core::triangle3df tri;

		if (smgr->getSceneCollisionManager()->getCollisionPoint(
			line, selector, intersection, tri))
		{
			bill->setPosition(intersection);
				
			driver->setTransform(video::ETS_WORLD, core::matrix4());
			driver->setMaterial(material);
			driver->draw3DTriangle(tri, video::SColor(0,255,0,0));
		}
        selectedSceneNode = smgr->getSceneCollisionManager()->
          getSceneNodeFromCameraBB(camera);

		if (lastSelectedSceneNode)
			lastSelectedSceneNode->setMaterialFlag(
                video::EMF_LIGHTING, true);

		if (selectedSceneNode == q3node ||
           selectedSceneNode == bill)
			selectedSceneNode = 0;

		if (selectedSceneNode)
			selectedSceneNode->setMaterialFlag(
               video::EMF_LIGHTING, false);

		lastSelectedSceneNode = selectedSceneNode;
        		driver->endScene();

		int fps = driver->getFPS();

		if (lastFPS != fps)
		{
		  core::stringw str = L"Collision detection example - Irrlicht Engine [";
		  str += driver->getName();
		  str += "] FPS:";
		  str += fps;

		  device->setWindowCaption(str.c_str());
		  lastFPS = fps;
		}
	}

	device->drop();
	
	return 0;
}

   
   
digfarenough
Posts: 39
Joined: Sat Oct 30, 2004 4:35 pm
Location: Boston, MA
Contact:

Post by digfarenough »

I'm gonna go ahead and say the obvious here, but q3node is undeclared :)

not only do you not declare it (something like scene::IAnimatedMeshSceneNode* q3node=0; ) but you never add it to the scene manager with addAnimatedMeshSceneNode()

both of those have to be done before you do if(q3node) which tests to make sure q3node isn't the null pointer, i.e. that it actually points to a real object
Post Reply