Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (428)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  View Culling Problem LWGL  (Read 1178 times)
0 Members and 1 Guest are viewing this topic.
Offline Captain-Goatse

Junior Member




I suck at teh 2D. XBOX IS BIG LOL!111


« Posted 2003-02-04 18:21:51 »

Now it is blatantly obvious that I messed up somewhere and pretty badly because I managed to turn perfect piece of code into huge pile of crap.

When I'm at the position 0,0,1 facing towards up vector 0,1,0 it works ok, except that it can't render some of the balls that go beside it.

Now the biggest problem is that it doesn't work as it is supposed to and I can't figure out what the hell is wrong with the planes.

I've re-written them about 1000 000^7 times, but they still keep messing up. This is grabbed directly from gametutorials com. At first I thought they worked, but I had the camera positioned wrong and no mouse move. But when the mousemove is included it craps up. Hence there must be something wrong with the panes.

Now I beg you, please can you check the pane code that it is at least seemingly right?

I'm thinking about turning the frustum into one single array instead of logical array, but that is not supposed to be the matter since it works like that in gametuts examples, unless there is some major difference between c++ and java arrays that I'm unaware of.


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
Matrix4f.mul(modl, proj, clip);             
            // This will extract the RIGHT side of the frustum
           m_Frustum[RIGHT][A] = clip.m30 - clip.m00;
            m_Frustum[RIGHT][B] = clip.m31 - clip.m01;
            m_Frustum[RIGHT][C] = clip.m32 - clip.m02;
            m_Frustum[RIGHT][D] = clip.m33 - clip.m03;
     
            // Now that we have a normal (A,B,C) and a distance (D) to the plane,
           // we want to normalize that normal and distance.
     
            // Normalize the RIGHT side
           normalizePlane(m_Frustum, RIGHT);
     
            // This will extract the LEFT side of the frustum
           m_Frustum[LEFT][A] = clip.m30 + clip.m00;
            m_Frustum[LEFT][B] = clip.m31 + clip.m01;
            m_Frustum[LEFT][C] = clip.m32 + clip.m02;
            m_Frustum[LEFT][D] = clip.m33 + clip.m03;
     
            // Normalize the LEFT side
           normalizePlane(m_Frustum, LEFT);
     
            // This will extract the BOTTOM side of the frustum
           m_Frustum[BOTTOM][A] = clip.m30 + clip.m10;
            m_Frustum[BOTTOM][B] = clip.m31 + clip.m11;
            m_Frustum[BOTTOM][C] = clip.m32 + clip.m12;
            m_Frustum[BOTTOM][D] = clip.m33 + clip.m13;
     
            // Normalize the BOTTOM side
           normalizePlane(m_Frustum, BOTTOM);
     
            // This will extract the TOP side of the frustum
           m_Frustum[TOP][A] = clip.m30 - clip.m10;
            m_Frustum[TOP][B] = clip.m31 - clip.m11;
            m_Frustum[TOP][C] = clip.m32 - clip.m12;
            m_Frustum[TOP][D] = clip.m33 - clip.m13;
     
            // Normalize the TOP side
           normalizePlane(m_Frustum, TOP);
     
            // This will extract the BACK side of the frustum
           m_Frustum[BACK][A] = clip.m30 - clip.m20;
            m_Frustum[BACK][B] = clip.m31 - clip.m21;
            m_Frustum[BACK][C] = clip.m32 - clip.m22;
            m_Frustum[BACK][D] = clip.m33 - clip.m23;
     
            // Normalize the BACK side
           normalizePlane(m_Frustum, BACK);
     
            // This will extract the FRONT side of the frustum
           m_Frustum[FRONT][A] = clip.m30 + clip.m20;
            m_Frustum[FRONT][B] = clip.m31 + clip.m21;
            m_Frustum[FRONT][C] = clip.m32 + clip.m22;
            m_Frustum[FRONT][D] = clip.m33 + clip.m23;
     
            // Normalize the FRONT side
           normalizePlane(m_Frustum, FRONT);            
Offline Spasi
« Reply #1 - Posted 2003-02-04 22:57:36 »

Here is how I do it. I've been using it for a long time with no problems.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
// Left
frustum[0] = matrix.m03 + matrix.m00;
frustum[1] = matrix.m13 + matrix.m10;
frustum[2] = matrix.m23 + matrix.m20;
frustum[3] = matrix.m33 + matrix.m30;

// Right
frustum[4] = matrix.m03 - matrix.m00;
frustum[5] = matrix.m13 - matrix.m10;
frustum[6] = matrix.m23 - matrix.m20;
frustum[7] = matrix.m33 - matrix.m30;

// Top
frustum[8] = matrix.m03 - matrix.m01;
frustum[9] = matrix.m13 - matrix.m11;
frustum[10] = matrix.m23 - matrix.m21;
frustum[11] = matrix.m33 - matrix.m31;

// Bottom
frustum[12] = matrix.m01 + matrix.m03;
frustum[13] = matrix.m11 + matrix.m13;
frustum[14] = matrix.m21 + matrix.m23;
frustum[15] = matrix.m31 + matrix.m33;

// Near
frustum[16] = matrix.m02 + matrix.m03;
frustum[17] = matrix.m12 + matrix.m13;
frustum[18] = matrix.m22 + matrix.m23;
frustum[19] = matrix.m32 + matrix.m33;

// Far
frustum[20] = matrix.m03 - matrix.m02;
frustum[21] = matrix.m13 - matrix.m12;
frustum[22] = matrix.m23 - matrix.m22;
frustum[23] = matrix.m33 - matrix.m32;


Of course with the normalizations in between.

Spasi
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #2 - Posted 2003-02-05 07:14:51 »

You mention that you have this working in Gl4Java? There rumours that Gl4Java flips a couple of matricies when it shouldn't. Or possibly you're expecting row-major and getting coloumn major. Try flipping you matrix on its main diagonal and see if that helps.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Captain-Goatse

Junior Member




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #3 - Posted 2003-02-05 08:58:26 »

I made transformation grid on paper so the cells of the matrices should correspond to one another.


When I use the LWGL load, does it really load the cells into right places?

I'm going to go through the code for awhile and perhaps report the code from markmoley.com....

Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #4 - Posted 2003-02-05 09:07:31 »

Have a look at Cas' SPL over at sourceforge, theres a Frustum class that I used as an example when I did my view culling Frustum..

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Captain-Goatse

Junior Member




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #5 - Posted 2003-02-05 09:22:28 »

My bad.. I will go blast my brains out....

Never ever copy and paste same code over and over... NEVER EVER!!!

Well ok ok I was tired, but this post will remain as mark of my stupidity.
Offline Captain-Goatse

Junior Member




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #6 - Posted 2003-02-05 09:37:12 »

My problem still remains, the matrix code is now 100% correct, but due the fact that my result looks different from GT result I can't be sure whether my mathematics is correct. I drew the planes on paper and they seemed to be fine, now if you know what the GT code is supposed to look like, you know that the speheres are supposed to go behind you.

In my example they don't.

Would someone bother to take look at my code? it will be hosted suicidesolutions.com/fos3d.zip


I will give birth to your manbabies if you'd do so.

The rendering code is verry dirty and in GameEngine, viewfrustum is the frutum,
Offline Captain-Goatse

Junior Member




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #7 - Posted 2003-02-05 10:01:00 »

Matrix4f.mul(proj, modl, clip);

had to be changed in order it works properly. Most likely I had the math right from the very beginning then I got it wrong myself, and fell deeper into the hole. Oh so dreamy!
Now the occlusion culling.. HAR HAR.

My own math library does things other way around, but now it works perfectily. THX MR. GOATSE.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (79 views)
2014-04-15 18:08:23

BurntPizza (70 views)
2014-04-15 03:46:01

UprightPath (81 views)
2014-04-14 17:39:50

UprightPath (66 views)
2014-04-14 17:35:47

Porlus (82 views)
2014-04-14 15:48:38

tom_mai78101 (106 views)
2014-04-10 04:04:31

BurntPizza (166 views)
2014-04-08 23:06:04

tom_mai78101 (262 views)
2014-04-05 13:34:39

trollwarrior1 (212 views)
2014-04-04 12:06:45

CJLetsGame (221 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!