draw3DLine() : Has anyone got this going?

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
Haeal
Posts: 3
Joined: Thu Dec 09, 2004 12:30 am
Location: New Zealand

draw3DLine() : Has anyone got this going?

Post by Haeal »

From what I've read in the other posts in this forum, there's some significant trouble with this. My problem is that no matter what I do, the line is transparent. :cry:

Does anyone have any work arounds for drawing lines? I can't just use directx calls since this program needs to be platform independent.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

I suggest that 3d line changes own color dependence on previos loaded node. Maybe this is a bug, but at now I have not playing with this.
Guest

Post by Guest »

I don't know where is the problem, 3d lines are working fine for me. I looked in source code, only what I don't understand is why Niko has implemented clipping for DirectX9? Clipping is allredy done by DirectX.

Anyway, this function is not enough for me, I have implemented function drawIndexed3DLineList which can render lines as much you want in one pass.
Haeal
Posts: 3
Joined: Thu Dec 09, 2004 12:30 am
Location: New Zealand

Got it.

Post by Haeal »

Well, I figured it out. It was the order that things were done. By the look of it, there's like a global material that is used for drawing, and isn't saved and restored after each draw. This is what I had to do to get it drawing properly.

Code: Select all

	
	//Run message loop.
	while(device->run())
	{
		driver->beginScene(true, true, SColor(0,200,200,200));
		driver->setTransform(video::ETS_WORLD, core::matrix4());
		smgr->drawAll();
		driver->setTransform(video::ETS_WORLD, core::matrix4());
		guienv->drawAll();
		
		driver->setTransform(video::ETS_WORLD, core::matrix4());
		video::SMaterial m;
		m.MaterialType = EMT_SOLID;
		m.AmbientColor = SColor(0,255,255,255);
		m.Lighting = false;
		driver->setMaterial(m);

		driver->draw3DLine(core::vector3df(0.0, 0.0, 0.0),
			core::vector3df(10.0, 0.0, 0.0), SColor(0, 255, 0, 0)) ;
				
		driver->draw3DLine(core::vector3df(0.0, 0.0, 0.0),
			core::vector3df(00.0, 10.0, 0.0), SColor(0, 0, 255, 0)) ;
				
		driver->draw3DLine(core::vector3df(0.0, 0.0, 0.0),
			core::vector3df(00.0, 0.0, 10.0), SColor(0, 0, 0, 255)) ;
		driver->endScene();
		Sleep(.01);
	}
I'm sure a few of those calls to reset the matrix are redundant, but everything seems to need resetting to get normal lines drawn.
Post Reply