*sigh*
Okay, I've probably been it at it many times and probably even asked some questions on this topic before, but, alas, I'm at it again - trying to build an LDraw file format parser in C#. Why C#? Tl;dr: I need it for other stuff, and that stuff uses C#.
Well, the question itself: How does one even go around effectively parsing LDraw? This topic is a bit confusing to me due to the recursiveness (I guess that's what the word would be) of the format. My current approach is like this:
1. Read through all of the file, store all the faces in an array, store all the submodels in a separate array
2. Go through the submodel array, go to step 1 for each of them
3. Once the process is out of this recursive mess, "resolve" each submodel by applying the transform to it's triangles and adding them to the submodel's parent
4. Done, I guess?
It is very simple and doesn't account for, like, any meta or other stuff that could be important, but it should be enough for the start. I'm just not sure if this approach is good, or how it possibly could be improved
Also, I know I can read stuff like LDView source code, but I'm really bad at reading code made by other people, so it would probably take way more time than just asking it here
Okay, I've probably been it at it many times and probably even asked some questions on this topic before, but, alas, I'm at it again - trying to build an LDraw file format parser in C#. Why C#? Tl;dr: I need it for other stuff, and that stuff uses C#.
Well, the question itself: How does one even go around effectively parsing LDraw? This topic is a bit confusing to me due to the recursiveness (I guess that's what the word would be) of the format. My current approach is like this:
1. Read through all of the file, store all the faces in an array, store all the submodels in a separate array
2. Go through the submodel array, go to step 1 for each of them
3. Once the process is out of this recursive mess, "resolve" each submodel by applying the transform to it's triangles and adding them to the submodel's parent
4. Done, I guess?
It is very simple and doesn't account for, like, any meta or other stuff that could be important, but it should be enough for the start. I'm just not sure if this approach is good, or how it possibly could be improved
Also, I know I can read stuff like LDView source code, but I'm really bad at reading code made by other people, so it would probably take way more time than just asking it here