Jump to content
  • Advertisement

Archived

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

Arch@on

Problem with drawing vertices from quadtree.

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Right now I have a bit of a problem here. I have my quadtree and I can store the heights of my map in it. However, initially it stored the heights as vertices, as was thought at gametutorials.com. However, this eats up a lot of memory so I decided to turn the vertices into floats. I still used the vertice algorithm, but now I came to a problem. I can identify one quad from another and all of the quads get drawn on each other. Istead of splitting the heights, between the nodes, should I just split "sort of lists" to nodes which tell what vertices are contained in that node and then they are drawn according to that? I mean splitting the one big array into smaller ones is very clumsy. Also when turning into vertex arrays it would be harder. Is there any decent way to store the referer list of the main array so that it doesn''t eat up tons of memory. Is there point having as many arraylists as there are nodes? My logic would be this: If heightarray[x +(z*columns)] is listed in the node tested draw it. Where as right now it is: if node tested contains something draw it, if not proceed to child nodes. I''ve had tons of problems with maps that are not divisible by 2, since they are not even I''ve had to ceil them producing one extra column every uneven node. If i''d only store referer list, I wouldn''t have this problem. I hope I''m making sense.

Share this post


Link to post
Share on other sites
Advertisement
First,dude can you show me a code example(only) about how to build a quadtree.Second,yes you don''t have to store vertices in the nodes and leafs but only indices to them.Around 100 less memory.Cheers!

The PAIN is coming...this summer!!!In cinemas everywhere.

Share this post


Link to post
Share on other sites
Sure, but I'm writing it in Java and OpenGL, but I can show you the quadtree code. I'll put it on my site. What I thought I would store

Anyway, the broken code is in QNode.java QTree where as the working ones are QuadNode & Quadtree.

Basically, the idea behind it is from gametuts.com, but 90% of the code is changed, only the comments are in there, since I didn't bother to remove them. I can't remember correctly, but most of them are inaccurate.

http://www.suicidesolutions.com/quadtree.zip

Aren't you the guy who got his ass flamed off at help wanted awhile ago? Anyway, not that it matters is important.

[edited by - Captain Goatse on April 3, 2003 3:34:44 AM]

Share this post


Link to post
Share on other sites
My problem is that I don''t know how to store the indices so that I can invoke them when required. Right now they are in height_array[] which is basically float array of the heights.

Share this post


Link to post
Share on other sites
Here is a suggestion that will 100% work(i''ve tried it).You create a global face list.Ofcourse face will be build from indices that tells which from the terrain''s vertices are building the current face.Then for every node perform a geometry check and store the index of any face that is in the node''s bounding box.Simple use the face''s indices to draw geometry latter.Not very hard!

The PAIN is coming...this summer!!!In cinemas everywhere.

Share this post


Link to post
Share on other sites
Could you explain bit more in detail?

Do you mean I should have global an ArrayList or BooleanList, where all the flags for the indices are stored? I''m working under very memory critical conditions and I can''t afford building idle lists, but I need to have an algorithm, which can build the list of indices from as little data as possible.

Or could you post the code that you used to get it work?

Share this post


Link to post
Share on other sites
Here is the trick:

you have a global vertex array with all of the terrain vertices.You also store in global array the indices of the vertices that are building the terrain faces.You you're storing mesh information about the whole terrain.In each node you calculate how many triangles are visible and you store only TRIANGLE indices,not vertices or something else.Only TRIANGLE indices.When you determine the visible set you get the faces from the global face list via the indices in to node,then get the vertices from the global list and render triangles.That's how you won't have to store about 100000000000000 vertices when the terrain has 1000.If you don't understand again i'll write you a mail with scheme and everything else.


The PAIN is coming...this summer!!!In cinemas everywhere.

[edited by - Mihail121 on April 3, 2003 11:17:25 AM]

Share this post


Link to post
Share on other sites
I get it, looks like you are using vertices as the storage structure, where as I''m attempting to use single float array in order to save memory. In this model, the x and z coordinates are generated run-time. In a way this should be much more efficient since, because I use java vectors uses a lot more memory compared to simply type.

What data structure are you using to store the indices?

However, if you are not storing the vertices as vector(x,y,z) or vertex(x,y,z) please mail me at goatse@suicidesolutions.com

Share this post


Link to post
Share on other sites
For vertex is use simply:

typedef float vertex[3];

vertex *terrain_vertices;

For faces it''s:

typedef int face[4];

face *terrain_faces;

and for face index it''s simply "int".


The PAIN is coming...this summer!!!In cinemas everywhere.

Share this post


Link to post
Share on other sites
Uh.. that was basically there and there was nothing new to it. You just basically copied the working quadtree of mine. However, I''m not going to use vertices, because I''ll have to store 3 values instead of one.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!