tutorial 3 not working

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
Tubby2877
Posts: 12
Joined: Fri Sep 12, 2008 1:54 pm

tutorial 3 not working

Post by Tubby2877 »

hello everyone

The 3rd tutorial for some reason is not working for me and i can't find any forum questions for it.

i have typed it out exactly like it is done in the tutorial but when i try to compile it i get over 20 errors most being towards the render virtual function because the scene manager is an undecleared identifier

also the isceneNode does not have any onPreRender function ???

and the final thing is that when i create my sample node it says it cannot instantiate abstract class.

i don't know what is going on or what i have done wrong but please help cause it's really ticking me off
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: tutorial 3 not working

Post by rogerborg »

Tubby2877 wrote:The 3rd tutorial for some reason is not working for me
Make it work for you! Slap it upside the head and make it your beeyatch.

Tubby2877 wrote:i have typed it out exactly like it is done in the tutorial but when i try to compile it i get over 20 errors most being towards the render virtual function because the scene manager is an undecleared identifie
Questions:

Why are you "[typing] it out"?

Can you build and run the original, unchanged example project? Have you tried?

What errors do you get, in either case? Don't make us guess, tell us.

What version of Irrlicht are you using, and what platform / compiler / IDE?

If your code is still relatively short, consider posting it in its entirety. We're not telepathic. Well, Vitek might be, but we're keeping that quiet.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
asphodeli
Posts: 36
Joined: Thu Jul 24, 2008 12:46 am
Location: Singapore

Re: tutorial 3 not working

Post by asphodeli »

Tubby2877 wrote:hello everyone

The 3rd tutorial for some reason is not working for me and i can't find any forum questions for it.

i have typed it out exactly like it is done in the tutorial but when i try to compile it i get over 20 errors most being towards the render virtual function because the scene manager is an undecleared identifier

also the isceneNode does not have any onPreRender function ???

and the final thing is that when i create my sample node it says it cannot instantiate abstract class.

i don't know what is going on or what i have done wrong but please help cause it's really ticking me off
Have you tested the development and build environment? That's one of the uses of the sample code given. Also, posting error messages and/or code is very helpful, rather than stating what went wrong.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

A wild guess: did you use the examples from the web page (they're out of date) ?!?!?
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Tubby2877
Posts: 12
Joined: Fri Sep 12, 2008 1:54 pm

Code and errors

Post by Tubby2877 »

so this is the code and it looks identical to the example code that is in the file as far as i can see. I tried to run the example code and it does work so i can't understand what i am doing wrong.

i did use the tutorial of the main website but if there is a better place to get the tutorials from please fill me in

Thanks for all the help

Code: Select all

#include <irrlicht.h>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

//For the created scene node to be inserted into the engine, the class needs to be dirived from the iscenenode class
class CSampleSceneNode : public scene::ISceneNode
{
	core::aabbox3d<f32> Box;
	video::S3DVertex Verticies[4];
	video::SMaterial Material;

public:

	CSampleSceneNode(scene::ISceneNode* parent,  scene::ISceneManager* mgr, s32 id)
		: scene::ISceneNode(parent,mgr,id)
	{
		Material.Wireframe = false;
		Material.Lighting = false;

		Verticies[0] = video::S3DVertex(0,0,10,1,1,0,video::SColor(255,0,255,255),0,1);
		Verticies[1] = video::S3DVertex(10,0,-10,1,0,0,video::SColor(255,255,0,255),1,1);
		Verticies[2] = video::S3DVertex(0,20,10,0,1,1,video::SColor(255,255,255,0),1,0);
		Verticies[3] = video::S3DVertex(-10,0,-10,0,0,1,video::SColor(255,0,255,0),0,0);

		Box.reset(Verticies[0].Pos);

		for(s32 i = 1; i < 4; ++i)
			Box.addInternalPoint(Verticies[i].Pos);
	}

	virtual void OnRegisterSceneNode()
	{
		if(IsVisible)
			SceneManager->registerNodeForRendering(this);

		ISceneNode::OnRegisterSceneNode();
	}

	virtual void render()
	{
		u16 indices[] = {0,2,3, 2,1,3, 1,0,3 2,0,1};
		
		video::IVideoDriver* vDriver = SceneManager->getVideoDriver();

		vDriver->setMaterial(Material);
		vDriver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
		vDriver->drawIndexedTriangleList(&vertices[0],4, &indices[0], 4);
	}

	virtual const core::aabbox3d<f32>& GetBoundingBox() const
	{
		return Box;
	}

	virtual s32 getMaterialCount()
	{
		return 1;
	}

	virtual video::SMaterial& getMaterial(s32 i)
	{
		return Material;
	}
};

int main()
{
	IrrlichtDevice* tDevice = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640,480),16,false);

	tDevice->setWindowCaption(L"Custom Scene Node - Irrlicht Engine Demo");

	video::IVideoDriver* vDriver = tDevice->getVideoDriver();
	scene::ISceneManager* sSceMan = tDevice->getSceneManager();

	sSceMan->addCameraSceneNode(0, core::vector3df(0,-40,0), core::vector3df(0,0,0));

	CSampleSceneNode *MyNode = new CSampleSceneNode(sSceMan->getRootSceneNode(), sSceMan, 666);
	MyNode->drop();

	scene::ISceneNodeAnimator* anim = sSceMan->createRotationAnimator(core::vector3df(0.8f, 0, 0.8f));
	MyNode->addAnimator(anim);

	anim->drop();

	while(tDevice->run())
	{
		vDriver->beginScene(true,true, video::SColor(0,100,100,100));
		sSceMan->drawAll();
		vDriver->endScene();
	}

	tDevice->drop();
	return 0;
}
and these are the main errors the rest of the errors are just repeats of these.


Error 8 error C2040: 'vDriver' : 'int' differs in levels of indirection from 'irr::video::IVideoDriver *'

Error 4 error C2065: 'SceneManager' : undeclared identifier

Error 21 error C2259: 'CSampleSceneNode' : cannot instantiate abstract clas
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The getMaterialCount and getMaterial must use u32, and the former must be a const method.
Tubby2877
Posts: 12
Joined: Fri Sep 12, 2008 1:54 pm

Post by Tubby2877 »

thank you for the help have corrected that error
and the const is after just how it is like in the example

Code: Select all

	virtual u32 getMaterialCount() const
	{
		return 1;
	}

	virtual video::SMaterial& getMaterial(u32 i)
	{
		return Material;
	}
unfortunatly that still hasn't helps and i am stillgetting the same errors as above
Tubby2877
Posts: 12
Joined: Fri Sep 12, 2008 1:54 pm

Post by Tubby2877 »

have gone though it line by line with the example and fixed the abstract class, it was because an o was a capital instead of lowercase

The rest of the errors have something to do with the scenemanager in the render() function.

for some reason it is being classed as an undecleared identifier and so the intellisence isn't working.

This is what is going wrong!!!

for some reason the scenemanager above in the OnRegisterSceneNode() works fine but the render() dosn't.

i copied and pasted the example one into this project to see if it was something i left out but it worked so it is something within the code and i went though line by line but i can't see a difference.

a second pair of eyes would be handy that you. and before you say it, i know the driver pointer and scenemanager pointer variables are named different but that shouldn't effect it if they are all named in that way, at least what i know it shouldn't.

Thanks for all the help
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Ah, right.

In your Irrlicht SDK, there's an examples directory. The examples in there are far more likely to be up to date and correct than anything you'll find on a web page.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There are also other typos such as GetBoundingBox instead of getBoundingBox, etc. which is simply not working under C/C++.
Post Reply