Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / View Frustum Clipping Lines/Culling Points

Author
Message
Abraxas77
14
Years of Service
User Offline
Joined: 26th Aug 2010
Location:
Posted: 27th Sep 2010 02:39
Hello, again.

I created a class for a special "effect". It's not a true .fx effect ... but rather an object that generates a series of points in world space, translates them to screen space, and connects them with the Basic2D command: dbLine.

My problem is that, every so often, a point will be generated outside the view frustum and in a position where the resulting screen space representation yields a line artifact spanning the entire screen.

So, I created a Frustum class designed to cull any points generated outside the view frustum. But it is not working. Everything gets culled or--if I swap the test condition result--nothing gets culled. I think it must be an issue with how I acquired my frustum planes. Can anyone confirm this? ... or offer a better solution?

Here is my frustum code:


and the Plane code:


and finally, the effect code (which generates the points and owns the frustum object to check each point)


The #includes not included in this post are likely not relevant to the question, but I'll post any that may lead to a resolution.
"Contants.hpp" - contains constants global to my project (namespace PAL_LIB), namely IDs for DarkGDK functions.
"Vector3.hpp" - is a simple object-oriented approach to 3D vectors.
"Math.hpp" - contains basic math, trig, and 3D util type functions, namely (IsZero is used in the plane class. It looks like this:
)


Thanks in advance,
~Andrew~
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 27th Sep 2010 18:17
From what I can see from above: of a point falls outside of the 6planes , you delete it. You shouldn't do that unless both points that make the line are outside. Instead, you should clip the point to the point on the plane it intersects with.

To do that, google for line/plane intersection.

There are lots of special circumstances where both points fall outside of the planes, but when clipped to the planes the line would still be visible. So for now, start with just clipping to the planes and not delete anything.

There may be a way to do this via hardware - check the dx docs.

Hope this helps,


JTK
Abraxas77
14
Years of Service
User Offline
Joined: 26th Aug 2010
Location:
Posted: 28th Sep 2010 04:17
Thanks for the reply. I came up with a temporary solution that is somewhat similar. I created a very small cube object which I'm using to test whether either endpoint is in view via dbObjectInScreen. I then move whichever is out of view nearer to the other; and if the are both out of view, nothing is generated--the effect fails and nothing happens.

This works for now ... and perhaps may even serve as a final solution. However, I still want to figure out what went wrong with my original solution. I think it has to do with my clip planes. When I clip the line as you said, all I see are tiny artifacts if anything at all. It seems my clip planes may either be in the wrong coordinate space or I have made some other error in extracting them.

I will check the dx docs as you suggest. Thanks again for you help.


Cheers,
~Andrew~

Login to post a reply

Server time is: 2024-10-02 09:30:56
Your offset time is: 2024-10-02 09:30:56