Jump to content
  • Advertisement
Sign in to follow this  
OpenGL_Guru

the best way to read this data....

This topic is 4795 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

i have some data that i am going to have to store and am wondering what would be the best way to store in in memory. the data format is as follows: x y # of points 0.0 10.0 20.0 30.0 2.0 15.0 40.0 30.0 ... ... ... ... x y # of points etc etc etc. so basically # of points tells you how many points per location you will be reading. x and y are just that... x and y this is followed by the depth of the first point and 3 attributes the point has.. then the next point until you reach to # of points whatever that is. heres the problem...# of points can vary so its not a uniform data set. but they do all have 3 attributes per point. how would i connect the data via drawing them triangle strips etc etc or whatever. i think first i just need to come up with something to store the data in and then i can worry about the drawing later. i had something of a struct set up..such as struct data { x y z att1 att2 att3 }; i dont know if this would be the best way... thanks!

Share this post


Link to post
Share on other sites
Advertisement
this is exactly what I have right now.



Struct data

{

float d;

float x;

float y;

float z;

}



data *mydata;






the input file is layed out this way…



63 -> once I find this number out I put it into a variable num , then I can declare mydata = new data[num]; //so I have this part down.

0.0 20.0 30.0 40.0 50.0

2.0 6.0 20.0 50.0 100.0

4.0 3.0 1.0 40.0 43.5

…..(all the way down 60 more times)

5 ->next number

0.0 etc etc

2.0

4.0

6.0

8.0



109

….

….

….109 of these



55



….

..55 of these



so basically I need to group all the d, x, y, z’s together at the 0.0 level, same with the 2.0, 3.0, 4.0, etc etc. My mind is fried, I know its easier than it looks. I have thought of a linked list as the best way to access the first element of each “section” and so on.. but I don’t know.. what do you think??

Share this post


Link to post
Share on other sites

- Declare container of containers of points CC.
- While still more in file:
- Read count N from file line. Create new container C of this size.
- For N lines:
- Read one line. Create a point from the data. Add it to the end of C.
- Add C to the end of CC.


If you do not have the option of a "dynamically sized" CC, then you will need to add data to your file format to indicate its size (i.e. at the very beginning of the file, write how many sections there are). Fortunately, in C++ (as well as most other modern languages) there are plenty of good options for CC. In C++ in particular, consider std::vector<data*>, where each data* would point at an array of data (your Cs).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!