Use of IIGeometryCreator for cylinder

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
thanvilk
Posts: 23
Joined: Tue Mar 15, 2011 6:39 pm
Location: india

Use of IIGeometryCreator for cylinder

Post by thanvilk »

I am also struggling for creating cylinder as i dont want to write any seperate procedure for cylinder insteed of that i want to use the method of IGeometryCreator Method named as createGeometryMesh() but my problem is that it not showing any thing on runing/debuging the code..

Code: Select all

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

        if (device == 0)
                return 1; 
		video::IVideoDriver *driver = device->getVideoDriver();

 
        scene::ISceneManager* smgr = device->getSceneManager();
		const scene::IGeometryCreator *geo=smgr->getGeometryCreator();
		scene::IMesh *mC=geo->createCylinderMesh(100.0,500.0,0,video::SColor(0,255,255,50),true,0.000);
		mC->setMaterialFlag(video::EMF_LIGHTING,false);
		scene::ICameraSceneNode* camera=smgr->addCameraSceneNode(0,core::vector3df(0,0,5),core::vector3df(0,0,0),-1,true);
	
Laxmikant Thanvi
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You have created the mesh, but to display it you have also to put into the scene. For every object in the scene you have scenennode, so you have to create meshscenenode for that mesh. And then you also have to render the scene - you can look at the examples which all do that. Then it should work.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
thanvilk
Posts: 23
Joined: Tue Mar 15, 2011 6:39 pm
Location: india

Still Now showing Any thing

Post by thanvilk »

As you Corrected me i added the meshscenenode in scenemanger but still not showing this code any thing..
Following is my code:

Code: Select all


  scene::ISceneManager* smgr = device->getSceneManager();
		const scene::IGeometryCreator *geo=smgr->getGeometryCreator();
		scene::IMesh *mC=geo->createCylinderMesh(100.0,500.0,0,video::SColor(0,0,0,0),true,0.000);
        scene::IMeshSceneNode* node = smgr->addMeshSceneNode(mC);
		mC->setMaterialFlag(video::EMF_LIGHTING,false);


   while(device->run())
        
		{
                if (device->isWindowActive())
                {
                        driver->beginScene(true, true, video::SColor(255,200,200,0));
                     smgr->drawAll();	   
                     driver->endScene();
				}
				
		}
	
		      device->drop();
				return 0;


If there is any problem with my code then do correct me..
If you have any new idea or code available for creating Cylinder then please provide me, I am struggling for cylinder from last many days but anything not working for me.
Laxmikant Thanvi
blAaarg
Posts: 94
Joined: Tue Mar 02, 2010 9:11 pm
Location: SoCal

Post by blAaarg »

Is, maybe, your camera inside your mesh? I'm assuming your using the same position parameters for the camera as previously, since the camera disappeared from the next snippet.
"Computers don't make mistakes! What they do they do on purpose!!"

-Dale Gribble
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

To see anything you also need to have a camera, why did you remove that now? But it's probably easier starting with the code of one of the examples which come with Irrlicht (examples folder). Then you can start with a working scene already.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
thanvilk
Posts: 23
Joined: Tue Mar 15, 2011 6:39 pm
Location: india

Camera Positioning

Post by thanvilk »

As the removal of camera code is due to my mistake but now i added normal camera where position of object(cylinder) is (0,0,0) and camera position is (0,0,100) but still not any effect on the irrlicht device screen.. not showing any think :(

My code for creating cylinder is ok or not ?
if it is ok and problem is due to only object and camera positions then please suggest me dimension of object and camera from your side if anyone can..(Bcoz i had tried many combinations of camera and object position dimention but all fail to show the object with actual view) may be i am not getting the perfect relative positioning of camera for the cylinder object or the problem of mesh creation ?

Please any one have readymade working code for cylinder then do provide me ~!
Thanks in Advance !
Laxmikant Thanvi
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Post by mongoose7 »

cam->setTarget(core::vector3df(0, 0, 0)); :?:
blAaarg
Posts: 94
Joined: Tue Mar 02, 2010 9:11 pm
Location: SoCal

Post by blAaarg »

Hmmm....

let's try changing:

Code: Select all

      scene::IMesh *mC=geo->createCylinderMesh(100.0,500.0,0,video::SColor(0,0,0,0),true,0.000); 
to

Code: Select all

      scene::IMesh *mC=geo->createCylinderMesh(10.0,50.0,24,video::SColor(0,0,0,0),true,0.000); 
and assuming you retain the camera position at (0,0,100) and follow mongoose7's advice so that the target is in the same place as the mesh.

I haven't tested it, but, the extent (or width) of a cylinder with it's first parameter (radius) set to 100 is the same as its diameter (200 units). Also, (although I'm not sure whether Irrlicht cylinders align to the X, Y or Z axis) the length of the cylinder was 500 units and the camera was only 100 units away so it was still inside the cylinder, making the cylinder invisible. Also, notice that the 3rd parameter of createCylinderMesh() is the tesselation (or number of segments/quads going around the cylinder) and that probably shouldn't be zero.
"Computers don't make mistakes! What they do they do on purpose!!"

-Dale Gribble
thanvilk
Posts: 23
Joined: Tue Mar 15, 2011 6:39 pm
Location: india

Still Not any effect on Irrlicht Device Screen ~ :(

Post by thanvilk »

I tried with your suggested code replacement but still not anything displayed on the irrlicht device screen !
Follwing is the full code after replacements !

Code: Select all

int wmain()
{
 video::E_DRIVER_TYPE driverType;

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

        char i;
        std::cin >> i;

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


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

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

		  const scene::IGeometryCreator *geo=smgr->getGeometryCreator();
		  scene::IMesh *mC=geo->createCylinderMesh(10.0,50.0,24,video::SColor(0,0,0,0),true,0.0000);
		  scene::IMeshSceneNode *node=smgr->addMeshSceneNode(mC);

	
		  scene::ICameraSceneNode *cm=smgr->addCameraSceneNode(0,core::vector3df(0,0,0),core::vector3df(0,0,100),-1,true);
		  cm->setTarget(core::vector3df(0,0,0));
        while(device->run())
        
		{
                if (device->isWindowActive())
                {
                        driver->beginScene(true, true, video::SColor(255,200,200,255));
                       smgr->drawAll();	   
                       driver->endScene();
				}
				
		}
	
		      device->drop();
				return 0;
}

[quote]:

If possible then try this code for me and if you find anything extra additional then please suggest me !  Bcoz from last 1 week i am trying for creating cylinder but all attempts failed !
If you can do for me then it will be very admirable for you from my side ! [/quote]
Laxmikant Thanvi
blAaarg
Posts: 94
Joined: Tue Mar 02, 2010 9:11 pm
Location: SoCal

Post by blAaarg »

You have your camera position and lookat swapped (2nd and 3rd parameters). It's still inside the cylinder.
"Computers don't make mistakes! What they do they do on purpose!!"

-Dale Gribble
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The cylinder is aligned to the y-axis IIRC, so length goes into that direction, width defines the radius in the x/z plane.
Please use the FPS camera, and add it without parameters. Then navigate in the scene using mouse and cursor keys. Also don't use an alpha value of 0 for your colors, better use SColor(255,0,0,0) or some other values for the last three values. Also, you need to change lighting parameters and other things once you can see something rendered. The cylinder will look like a flat rectangle with the current setting.
thanvilk
Posts: 23
Joined: Tue Mar 15, 2011 6:39 pm
Location: india

Working !

Post by thanvilk »

Thanks !

Now its Rendering after changing camera to FPS camera and Alpha Color Value to 255 !
Thks a lot ! afterall cylinder shows it !

But without FPS camera i want to use it.. because i want to apply customized rotation on the cylinder object ?

Becoz My GUI Application Working with menu,textboxes,buttons after swithching to FPS the other function stop to work ! so i want normal camera that can be customized according to the user needs using text boxex ! but problem is i dont getting the actuall coodinate system Max and Min range of x,y,z direction spcially Z direction is confusing lot..
Please Clearify it as in many tutorials z co-ordinate is taken above 1500 then what is max size in irrlicht for x,y and z directions !

Thanks a lot for your help!
Last edited by thanvilk on Fri May 06, 2011 12:50 pm, edited 1 time in total.
Laxmikant Thanvi
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Working !

Post by serengeor »

thanvilk wrote:Thanks !
But without FPS camera i want to use it.. because i want to apply customized rotation on the cylinder object ?
a fps camera is only a helper to view your scene, normal camera can do the same, you just need to alter positions manually or write another camera scene node which does what you want.
Working on game: Marrbles (Currently stopped).
thanvilk
Posts: 23
Joined: Tue Mar 15, 2011 6:39 pm
Location: india

Camera Max and Min Cordinates !

Post by thanvilk »

I am working on irrlicht from last 1 and 1/2 months but not getting the actually Maximum and Minimum camera position as ! As center/origin is at Center of screen then what is the maximum range for +ive X,+ive Y and +ive Z directions ! bcoz without this how i pridict the actually co-ordinate for customization !

????????????????
Laxmikant Thanvi
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

That depends on your camera settings (field of view, near and far range, aspect ratio). But of course you could calculate those figures. There's even a way in Irrlicht, as you can get the view frustum and check the near and far corners there. Don't have code for this here, though.
Post Reply