Page 1 of 1

.obj loader

Posted: Tue Jan 23, 2007 10:42 pm
by Earl
Hi guys,
I have a newbie question.
A friend of mine and I are beginning a VR project, and we've chosen to use the Irrlicht engine to accomplish this. He's a CompSci major but he's not being too helpful at the moment, and I'm trying to learn to program in order to get the project rolling.
I've decided to use .obj files, since we already have a copy of Maya and I know it fairly well.
Unfortunately try as I might I just cannot get a program to compile. I've tried all I know (which isn't much, mind you...) including forum diving here, and I'm more or less stuck..

So, I was wondering if any of you programming gurus out there might point out the ID10t s in my code.

Code: Select all

#include <irrlicht.h>
#include <iostream>

using namespace irr;

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

int main()
{

	// ask user for driver

	video::E_DRIVER_TYPE driverType;

	printf("Please select the driver you want for this example:\n"\
		" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
		" (d) Software Renderer\n (e) Apfelbaum Software Renderer\n"\
		" (f) NullDevice\n (otherKey) exit\n\n");

	char i;
	std::cin >> i;

	switch(i)
	{
		case 'a': driverType = video::EDT_DIRECT3D9;break;
		case 'b': driverType = video::EDT_DIRECT3D8;break;
		case 'c': driverType = video::EDT_OPENGL;   break;
		case 'd': driverType = video::EDT_SOFTWARE; break;
		case 'e': driverType = video::EDT_SOFTWARE2;break;
		case 'f': 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; // could not create selected driver.

	
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();


	device->getFileSystem()->addZipFileArchive("../../media/test.zip");

	return 0;

 int object ()              *********
  {
    IAnimatedMesh* mesh = smgr->getMesh("regularsize.obj"); 
      IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(regularsize); 
	if (mesh)
		node = smgr->addOctTreeSceneNode(mesh->getMesh(0));


	if (node)
		node->setPosition(core::vector3df(-1300,-144,-1249));

	smgr->addCameraSceneNodeFPS();


	device->getCursorControl()->setVisible(false);
return 0;
}
; int lastFPS = -1;

	while(device->run())
	if (device->isWindowActive())
	{
		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"STILL trying to make a basic .obj loader![";
			str += driver->getName();
			str += "] FPS:";
			str += fps;

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

	
	device->drop();
	
	return 0;
}

The code I have here is really just the second tutorial from the engine package, badly mutilated.

Error codes are:
in function int main ()
Line 55- expected primary expression before 'int'
Line 55- expected ';' before 'int'
Stars denote line 55- *********

Thanks for all your help!

Posted: Tue Jan 23, 2007 10:48 pm
by CuteAlien
remove those stars: *********

Hm and also: try example09. It can be used as .obj loader already.

Posted: Tue Jan 23, 2007 10:49 pm
by Saturn
You're missing a '}' before line 55. Seriously, that's something you should have figured out yourself!

Posted: Tue Jan 23, 2007 10:51 pm
by CuteAlien
ehm, wait.. on a closer look: int object() looks like a function. But it's defined inside another function (main). You can't do that.
Move it outside of main.

Posted: Wed Jan 24, 2007 8:53 pm
by Earl
I did try placing the } and I got a slew of other errors instead, I thought this layout was closer to what would work...
I had read in a few places that it was quite plausible to use functions within functions, and I thought that was getting me closer but it is true that I'm just a beginner and I shouldn't be messing around like that :D
I'll check out example 9 for sure, maybe I'll have better luck there.

Thanks for your help so far!

Chris