#### Archived

This topic is now archived and is closed to further replies.

# Would this method of triangle culling work?

This topic is 5283 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, in my game im making a isometric shooter where the map consists of tiled ground, tiled walls, eg on different angle to ground, tiled so i can use vertex shaders to make smooth lighting, anyway!, im thinking of storing all the square tiles into a one dimensional array that each element has the 6 vertices that are used to make a square for the tile. Also storing the texture index assoicated with that tile. I then find the four corners of the screen, the 2D points and project them into 3D to find what on the scene is in the screen. I then loop through my one dimensional array holding the triangle/square/tile/texture information to see which triangles are in the scene. I then organise the vertices into an index buffer so i can do one call to draw all triangles of one texture, another draw call to draw all triangles of another texture and so on. What i am worried about is that by doing this i would be slowing down my program as say my whole map consisted of 300,000 triangles wouldnt i be using up alot of my speed constantly looping through this 300,000 triangles? ................................. On that i thought maybe i could find whats within a larger area then the screen, so i could maybe update my index buffer for what to drawing over a few loops, eg store enough data on what to draw enough for the player to move the screen around while still in the drawn area,while i calculate the next lot of data to be drawn. Thanks, [edited by - johnnyBravo on May 31, 2004 9:54:13 PM] [edited by - johnnyBravo on May 31, 2004 9:55:39 PM]

##### Share on other sites
If all of your tiles are of a set size then you should use say a 2d indexmap which is just the indexes (identifiers) of the floor tiles in a grid. Also have a 2d index map of your walls but have it so that each cell hold 4 indices for the walls this will work provided that the walls are at least one cell in thickness. Just have say 0 for NULL value if no tile/wall is present.

Since this is an isometric you can quite easily determine where the four points of your view frustrum will fall on the 2d maps and then use a scanline algo to draw them.

Also you may need to work out a reordering scheme for you vertices because when you draw your culled indexbuffer all the vertices within the entire range (ie from lowest index value to highest) of the buffer will be transformed. For instance you could only send two tris, both at extreme ends of your vertex buffer and the entire vertex buffer will be transformed. This is the case under dx, I am unsure of opengl.

: changed wall stuff.

[edited by - SoulSpectre on May 31, 2004 10:16:41 PM]

##### Share on other sites
I thought about having a two dimensional array for an index map of the floor, but i dont see how you could do it for the walls really, eg the walls maybe 5 tiles high,(im not sure havent designed that yet)

I would also have information stored to tell the index buffer what to draw eg.
the ranges to draw from, and the triangle lists, and each for each texture, it would start a new draw call, so each draw call draws all tiles of a certain texture.

What do you mean by a scan line algorithm?

Thanks,
Im also using directx

edit:
also the walls arnt one cell thickness, sorry didnt read that properly, like i made a 2d tile version of this a while ago, and i dont really like using that method of having everything one cell each.

[edited by - johnnyBravo on May 31, 2004 10:24:12 PM]

##### Share on other sites
By scanline I mean:
get the 4 points of your view frustrum corners, projected into the 2dmap space. Then you can take the quick and dirty approach of calculating a bounding rect that can hold all 4 of those values, then simply draw all tiles that fit in the rects extents.
If your camera doesn''t yaw or pitch then it is real easy, else a little more work is involved but still easy if you want to absolutely draw only thoses tiles that are in view. For instance you will need to calc the lines between the 4 points and use these as a cut of value for the edges. Just pictre drawing 4 points on your map for the view, connect them to form a lines to form a quadrangle type shape (eg trapezoid) and use these as your view extents.

As for your walls, if they are of variable height, then you may want to implement a quad/octree structure for them. You may still be able to use the grid system for the walls with a hack or two though.

##### Share on other sites
When you said that it was a tiled base game I naturally assuned it was grid based. Is it free form or grid?
If it is above view, and grid then use a grid system, else if it is free form, use quadtree.

##### Share on other sites
well i havent really decided, but i guess its more grid,
since everything will be made of squares for my vertex lighting.

and the walls will fit in between the tiles.

Objects etc boxes, doors will be free based,

I thought if i could use a universal way of culling everything, that is the map''s triangles, it would be easier to design how the map is created and layed out

1. 1
Rutin
41
2. 2
3. 3
4. 4
5. 5

• 16
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633360
• Total Posts
3011524
• ### Who's Online (See full list)

There are no registered users currently online

×