I'm struggling to come up with a proper design pattern for a VRML file exporter I'm writing. Your typical VRML file has a hierarchy like so:
Transform {
translation 0 0 100
children [
Shape {
appearance Appearance {
texture ImageTexture {
repeatS TRUE
repeatT TRUE
url [
"texture.png"
]
} # end texture
} # end appearance
geometry IndexedFaceSet {
normalPerVertex TRUE
solid TRUE
coord Coordinate {
point [
-5.400000 0.030000 -0.000000,
...
] # end point
} # end coord
texCoord TextureCoordinate {
point [
0.062500 0.086207,
...
] # end point
} # end texCoord
normal Normal {
vector [
0 1 0,
]
} # end normals
coordIndex [
0, 1, 2, -1,
...
] # end coordIndex
texCoordIndex [
0, 1, 2, -1,
...
] # end texCoordIndex
normalIndex [
0, 0, 0, -1,
...
] # end normalIndex
} # end geometry
} # end shape
] # end children
} # end Transform
Right now I'm inheriting from a base class called Node that has your basic start/end strings. This is starting to create dependency hell though. Here's an example:
#include "IndexedFaceSetNode.h"
#include "TextureCoodinateNode.h"
#include "NormalNode.h"
struct GeometryNode : Node
{
IndexedFaceSetNode* indexedFaceSet;
TextureCoordinateNode textureCoordinate;
NormalNode normal;
GeometryNode(string isNormalNodePerVertex, string isSolid, vector<float> coordinates, vector<int> ind) :
Node("\tGeometryNode IndexedFaceSet { \n",
"\t}\n")
{
indexedFaceSet = new IndexedFaceSetNode(isNormalNodePerVertex, isSolid, coordinates, ind);
}
};
What can I do about this? Is there a better pattern or OOP structure I can use?
Aucun commentaire:
Enregistrer un commentaire