enmaniac

12-18-2003, 03:51 PM

Is it possible to find a vector which is parallel to a given plane ?? ( of course the normal of a plane is given as well as one point on a plane )??

View Full Version : Vector parallel to plane

enmaniac

12-18-2003, 03:51 PM

Is it possible to find a vector which is parallel to a given plane ?? ( of course the normal of a plane is given as well as one point on a plane )??

Clockwork

12-19-2003, 05:25 AM

There are an infinite number of planes parallel to a given plane, each of those has an infinite number of vectors in it...

are you looking for any one in particular?

You could take a vector that is on your first plane and translate it 'up' the plane's normal...

are you looking for any one in particular?

You could take a vector that is on your first plane and translate it 'up' the plane's normal...

enmaniac

12-19-2003, 03:44 PM

Yes you are right. There is infinite number of parallel vectors. But I need a vector which will be lying on this plane ( so it will be perpendicular to normal of a plane )

lapiz

12-20-2003, 07:21 AM

Let a normal vector N=(nx,ny,nz) at a point P=(px,py,pz) on a plane.

The equation of that plane is nx*X+ny*Y+nz*Z - (nx*px+ny*py+nz+pz) = 0.

Any vector (X,Y,Z) which satisfies that equation is on the plane.

Is this an answer that you want ?

The equation of that plane is nx*X+ny*Y+nz*Z - (nx*px+ny*py+nz+pz) = 0.

Any vector (X,Y,Z) which satisfies that equation is on the plane.

Is this an answer that you want ?

enmaniac

12-20-2003, 02:50 PM

Ok maybe I was a little bit unclear. I tell you what I really want to do.

I am writing a space strategy game. There will be some stars of course. The star is just a textured sphere and it doesnt look very impressive. I want to add some flares around it ( like in NeHe star project ). I have a texture which is 2D and whole world is 3D. So I want that texture to be ALWAYS perpendicular to camera position so it would always be seen from the front ( I dont want to see this texture or a quad it is mapped to from the angle different than 90 degs ). Such a quad ( plane ) should always pass through the centre of a star and the vector joining camera position and a star's centre should be a normal of a plane. AND FINALLY problem is how to determine 4 vertices of a quad which are on this plane to put texture there ??

Hope it is more clear now ;-)

If not please ask me once again. If you know any other idea I would be pleased to hear it.

Here is a Nehe demo to show the idea:

http://nehe.gamedev.net/data/projects/stars/stars.zip

Note that in that case everything is 2D only. So there is no problem of placing flares around star.

I am writing a space strategy game. There will be some stars of course. The star is just a textured sphere and it doesnt look very impressive. I want to add some flares around it ( like in NeHe star project ). I have a texture which is 2D and whole world is 3D. So I want that texture to be ALWAYS perpendicular to camera position so it would always be seen from the front ( I dont want to see this texture or a quad it is mapped to from the angle different than 90 degs ). Such a quad ( plane ) should always pass through the centre of a star and the vector joining camera position and a star's centre should be a normal of a plane. AND FINALLY problem is how to determine 4 vertices of a quad which are on this plane to put texture there ??

Hope it is more clear now ;-)

If not please ask me once again. If you know any other idea I would be pleased to hear it.

Here is a Nehe demo to show the idea:

http://nehe.gamedev.net/data/projects/stars/stars.zip

Note that in that case everything is 2D only. So there is no problem of placing flares around star.

jebus

12-22-2003, 05:25 AM

this sounds like "billboarding". there's a myriad of information on this topic. search these forums or gamedev.net.

Clockwork

12-22-2003, 06:17 AM

Ah, I see. Usually those are called bill board polygons. If you're using gluLookAt then you've got all the data you'll need.

First get your camera's Forward vector by subtracting the point you're looking at from your camera's position.

Then take the cross product of the Forward vector and the vector you're using for the universal Up (I use the Z axis (0, 0, 1) for this). The result of that cross product is the Right vector of your camera.

Then take the cross product of the Forward vector and this Right vector to get the actual Up vector of the camera.

Now you've got two vectors that describe the plane of your billboard polygon. To use it, you'll have to add and subtract the up and right vectors to create the 4 vertices for the actual polygon. And, of course, you'll want to scale things so that your polygon sticks outside of your star.

Hope that helps!

First get your camera's Forward vector by subtracting the point you're looking at from your camera's position.

Then take the cross product of the Forward vector and the vector you're using for the universal Up (I use the Z axis (0, 0, 1) for this). The result of that cross product is the Right vector of your camera.

Then take the cross product of the Forward vector and this Right vector to get the actual Up vector of the camera.

Now you've got two vectors that describe the plane of your billboard polygon. To use it, you'll have to add and subtract the up and right vectors to create the 4 vertices for the actual polygon. And, of course, you'll want to scale things so that your polygon sticks outside of your star.

Hope that helps!

enmaniac

12-22-2003, 07:23 AM

I haven't checked it out yet but I think this will solve my little prob :-)

It is called 'billboarding', it's good to know :-)

Thx ppl :-)

It is called 'billboarding', it's good to know :-)

Thx ppl :-)

enmaniac

12-22-2003, 03:01 PM

I've implemented billboarding and it seems to do what I wanted but something strange is occuring. Look at this image:

http://www.republika.pl/enmaniac/prob.JPG

Why the first texture covers the second star ( whole star ) but it doesnt cover the lines behind them all ??

PS When you look in oposite direction I mean from white star towards orange one the texture on white star DOES NOT cover the white star...

[This message has been edited by enmaniac (edited 12-22-2003).]

http://www.republika.pl/enmaniac/prob.JPG

Why the first texture covers the second star ( whole star ) but it doesnt cover the lines behind them all ??

PS When you look in oposite direction I mean from white star towards orange one the texture on white star DOES NOT cover the white star...

[This message has been edited by enmaniac (edited 12-22-2003).]

Clockwork

12-23-2003, 01:52 PM

I would guess that it's an alpha blending issue related to the rendering order. If you issue the command to draw the halo around the yellow star before you've drawn the white star, then the white star will not be present to be blended with the yellow halo. When you go to draw the white star's halo, the yellow star is already complete, so the blending is done correctly.

If that is what's happening, the correct way to fix that problem is to always render objects farther from the camera first. I'm not sure what the best way to accomplish that is though.

If that is what's happening, the correct way to fix that problem is to always render objects farther from the camera first. I'm not sure what the best way to accomplish that is though.

enmaniac

12-23-2003, 02:21 PM

You are absolutely right. I have just fixed it. The order of rendering is crucial here. The order is quite easy to determine. During rendering of a star sphere I add its distance into a sorted list and after redering of all spheres ( after rendering whole scene in fact ) I show all glows one after another :-)

Thx for help :-)

Thx for help :-)

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.