FOV

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
screwgh
Posts: 19
Joined: Tue Oct 14, 2008 12:27 am

FOV

Post by screwgh »

Hi,

I am trying for several of days to make a FOV(Field Of View) but I got stuck all the time.

I have the following code

part of enemy.h

Code: Select all

void drawFOV()
{
		IVideoDriver* driver = device->getVideoDriver();
		vector3df e = enemy->getPosition();	
		triangle.set(vector3df(0, 0, 0),vector3df(-50, 0, 100),vector3df(50, 0, 100));
		driver->draw3DTriangle(triangle,SColor(255,255,255,255));
}
part of main.cpp

Code: Select all

while(device->run())
	{

		driver->beginScene(true, true, SColor(255,100,101,140));	//Must draw between begin and end. Begin drawing
		//////////////////////////////////////////////////////////////Begin drawing

			drawFOV();

smgr->drawAll();											//Scenemanager drawing
		

	
		guienv->drawAll();											//Gui environment drawing
	
		

		//////////////////////////////////////////////////////////////End drawing
		driver->endScene();	
}

	device->drop();
	 return 0;

}
This works good he draws the triangle but it moves with the nemey who moves from waypoint A to B. But he doesn`t use any of the positions of the enemy wierd. But what more weirder is that when I use the positions of the enemy the triangle just wont draw. I can`t see why he isn`t drawing it.

if someone has an idea let me know because I`m out of ideas. And does anyone knows how to fill color but this is not necesary. Thanks in advance.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

I'm not sure about all you're saying, but this is probably one of your problems:

Code: Select all

drawFOV();
smgr->drawAll();
you draw the FOV and then you draw the sene over it... :lol:
so change the order like this:

Code: Select all

smgr->drawAll();
drawFOV();
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
screwgh
Posts: 19
Joined: Tue Oct 14, 2008 12:27 am

Tried

Post by screwgh »

Hi,

Thanks for the reply but I already tried that this draws to triangles one on the place where it needs to be and the other attached to the enemy. Weird here some pics

Now I use vertex so I can fill it with color it easier to use

This is the basic position where it must come
Image

But here it is also draw by the enmey and the enemy is moving with the vertext very weird.
Image

Hopefully it is getting more clear now.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You need to set the transform and material used to render the triangle. More specifically, you need to call driver->setTransform(video::ETS_WORLD, ...) and driver->setMaterial(...), just like all other code that draws 3d primitives must do.

Hint: If you get the coordinates of the triangle relative to the position and orientation of an object, you need to use that objects absolute transformation as the transformation matrix.

Travis
screwgh
Posts: 19
Joined: Tue Oct 14, 2008 12:27 am

Hi

Post by screwgh »

Just a small update I still didn`t get it working but now I use collision detection so the enemy can see me if I am near him.

Just a quick solution I am still working to get the FOV right I keep you updated
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Are your problems the same as before? Did Vitek's suggestions not help you? That should have made it work...

You could look into my IrrAI source to see how i do this stuff if you're still having trouble.
Image Image Image
Post Reply