Okay all,
I have started building my 3D greenhouse world and am making a java program to generate the x3d files based on a few inputs.
I believe I may be doing things the hard way so I wanted to get feedback on two points.
1) The geometry of the greenhouse requires a lot of repeated instances so I am using DEF and USE.
Currently I am tracking the first time I use a particular piece of geomtery (and an associated transform to get it to a neutral location and orientation) and adding a DEF attribute to the transform node and later using Shape nodes with USE to reuse it.
To make my life simpler I would like to make the world initially with all these reused geometry/transform nodes predefined but hidden in a branch of the scene-graph not shown and forgo tracking "first use" data completely. Is there a way to avoid rendering a whole branch of a scene-graph yet still have sub-branches of that scene graph visible when referenced elsewhere in the scene-graph?
2) I am using the java xml parsing and translating packages to read in a valid x3d scene (that is empty) and then adding nodes to it (DOM package) and then writting it to a new file name. This works but means I have to work at one level higher abstraction than I would like. I mean I have to make an element or node of the right tag type and add the correct attributes rather than make a Transform node directly. Is there an java package that has classes for each node in x3d and a way of loading/writting x3d files to be viewed externally (or internally).
I haven't had time to review CyberX3D for Java or Xj3D X3D Developer Toolkit . In the long run I want to make a tabbed user interface that will allow me to define specific parameters describing a greenhouse (not limited to stuff relevant to the x3d model) and have it save/load those in a xml file. The same program could should also generate an x3d file that may be viewed on another tab of the program (or in a browser) depending on performance limitations. The other greenhouse data will be used to generate output on other tabs ....
--------------------
Here is a sample of the code I have been writing so you can see why I would like a more x3d specific approach and predefine the DEF nodes in the "empty" .x3d base file I load and add branches too.
Node getFrontNode(String trans)
{
Element t = document.createElement("Transform");
t.setAttribute("translation", trans);
Element f;
if(firstFront)
{
f = document.createElement("Transform");
// 6.5, 0, 0 ft in meters
f.setAttribute("translation", "1.9812 0 0");
f.setAttribute ("DEF", "front");
Element ff = document.createElement("Inline");
ff.setAttribute("url", "front.wrl");
f.appendChild(ff);
firstFront = false;
} else {
f = document.createElement("Shape");
f.setAttribute("USE", "front");
}
t.appendChild(f);
return t;
}
Thanks
John