Idea of mine,but whats the best method?

Hello all.. I was thinking of making a useful tool for the community Im from.

I have studied C++ in my spare time.

I'm thinking of making a tool the reads a file and and rewrites it based on a users prefrence.

The file is a wrl file thats read by 3ds max,I understand the information in the file myself,and just need a way for my C++ program to look for a certain line in the file,but I'm not sure the absolute best method of this.

Heres what the file looks like inside it:

#VRML V1.0 ascii

Separator
{
Coordinate3 { point[-2783.678246 -2852.563858 -486.420774, -2733.060074 -2903.199387 -486.420774, -2614.924049 -2903.199387 -486.420774, -2581.120491 -2869.443703 -486.420774, -2581.120491 -2723.169136 -486.420774, -2592.390251 -2711.887932 -486.420774, -2749.914169 -2700.650787 -486.420774, -2783.678246 -2734.474373 -486.420774] }
MaterialBinding { value PER_FACE }
Material { diffuseColor[1.000000 0.500000 0.000000] transparency[0.000000] }
IndexedFaceSet { coordIndex[0,1,2,3,4,5,6,7,-1] }
}
Separator
{
Coordinate3 { point[-2783.678246 -2852.563858 -486.420774, -2800.521660 -2846.892548 -486.420774, -2763.945198 -2883.462906 -486.420774, -2758.330345 -2877.848244 -486.420774] }
MaterialBinding { value PER_FACE }
Material { diffuseColor[1.000000 0.500000 0.000000] transparency[0.000000] }
IndexedFaceSet { coordIndex[0,1,2,3,-1] }
}

Basically I know what every bit of the above means,all I need is for the program to look for that Material info which if your wonder is the line

"Material { diffuseColor[1.000000 0.500000 0.000000} transparency"

all this line is,is RGB info.

If I can make it where my program finds those lines,then takes that ifo between {
}

and writes it to a seperate file.

Basically the .wrl makes alot of unuseful info and I want to make a program that lets you get the useful info out of it...

Im sure I lost alot of people if so just ask me what you need to know.

Willing to learn myself Im not asking anyone to write it thereself just wan't suggestions.

Thnkyou
It's not hard at all.
Does this whole thing have to be in one line?
If yes, std::getline(file, string) until string until, when you cut the string at 9'th char, the first half is "Material". Then return the second half.
Though you should probably be using perl for text processing. It's not difficult to learn.
Last edited on
Though you should probably be using perl for text processing. It's not difficult to learn.


Aha I see a forum-er suggest language besides C++ in here. I agree also. Heavy text pattern processing are best done using scripting language like Perl, Python instead of C++.
Topic archived. No new replies allowed.