How to load a geometry (.obj, .wrl, .jvx, ... )
How to load a geometry (.obj, .wrl, .jvx, ... )
Hi,
To view a geometry, we can just use the interface and open it. But, how can I load it from my program and do some processing on it?
Regards
To view a geometry, we can just use the interface and open it. But, how can I load it from my program and do some processing on it?
Regards
Re: How to load a geometry (.obj, .wrl, .jvx, ... )
To see how to read a file into a Java program, see the following jReality tutorial:
http://www3.math.tu-berlin.de/jreality/ ... e_a_reader
If you need also to write the results out again, there are a more restricted set of classes for writing. Please post again if you want more information on these.
http://www3.math.tu-berlin.de/jreality/ ... e_a_reader
If you need also to write the results out again, there are a more restricted set of classes for writing. Please post again if you want more information on these.
jReality core developer
Re: How to load a geometry (.obj, .wrl, .jvx, ... )
Thank you!
The problem is only that, one need to load it from file via a javacode. I think there is a way to load it directly from the interface and the javacode will get the geometry from the viewer automatically for processing. In this case, we can process any geometry we want without specifing the path but I need a hint for that.
Regards
The problem is only that, one need to load it from file via a javacode. I think there is a way to load it directly from the interface and the javacode will get the geometry from the viewer automatically for processing. In this case, we can process any geometry we want without specifing the path but I need a hint for that.
Regards
Re: How to load a geometry (.obj, .wrl, .jvx, ... )
Hi,
Instead of ScenegraphGomponent, is it possible to get an indexedFaceSet of the geometry?
Regards
Instead of ScenegraphGomponent, is it possible to get an indexedFaceSet of the geometry?
Regards
Re: How to load a geometry (.obj, .wrl, .jvx, ... )
You can get the first geometry found (by depth-first traversal) of the scene graph rooted at a SceneGraphComponent using the following code snippet:
Note the method returns a Geometry. If you expect it to be an IndexedFaceSet, you'll need to check as shown in the code.
If your SceneGraphComponent contains more than one geometry of interest, then you'll probably need to merge the geometries into a single one. To do this, see the tutorial
http://www3.math.tu-berlin.de/jreality/ ... ge_factory
Code: Select all
#import de.jreality.import.SceneGraphUtility
SceneGraphComponent sgc = ... // produce a SceneGraphComponent containing Geometry
Geometry geom = getFirstGeometry(sgc);
if (geom instanceof IndexedFaceSet) {
...
}
If your SceneGraphComponent contains more than one geometry of interest, then you'll probably need to merge the geometries into a single one. To do this, see the tutorial
http://www3.math.tu-berlin.de/jreality/ ... ge_factory
jReality core developer
Re: How to load a geometry (.obj, .wrl, .jvx, ... )
Hi,
I don't know if you are familiar with the old Half edge data structure of JReality, actually I can not use a converter from the ifs to the heds,
so, I can not process any obj.
I got the following errors,
If you could help me!
Regards
I don't know if you are familiar with the old Half edge data structure of JReality, actually I can not use a converter from the ifs to the heds,
so, I can not process any obj.
Code: Select all
Input input = Input.getInput("6prism.obj");
ifset= (IndexedFaceSet) Readers.read(input).getGeometry();
heds = Converter.hedsFromIfs(ifset);
Code: Select all
at de.jtem.halfedge.jReality.converter.ConverterJR2Heds.getDataListOfTyp(ConverterJR2Heds.java:66)
at de.jtem.halfedge.jReality.converter.ConverterJR2Heds.ifs2heds(ConverterJR2Heds.java:163)
Regards
Re: How to load a geometry (.obj, .wrl, .jvx, ... )
Hi,
please try to invoke the method
IndexedFaceSetUtility.makeConsistentOrientation()
on the IndexedFaceSet and try if this solves the problem.
please try to invoke the method
IndexedFaceSetUtility.makeConsistentOrientation()
on the IndexedFaceSet and try if this solves the problem.
Re: How to load a geometry (.obj, .wrl, .jvx, ... )
Hi there,
In fact the brut casting (IndexedFaceSet) doesn't even work. Does anyone has issues for getting IndexedFaceSet from the given Obj?
Regards
In fact the brut casting (IndexedFaceSet) doesn't even work. Does anyone has issues for getting IndexedFaceSet from the given Obj?
Regards
Re: How to load a geometry (.obj, .wrl, .jvx, ... )
Try to do something like this:
Code: Select all
ReaderOBJ reader = new ReaderOBJ();
SceneGraphComponent c = reader.read(file);
Geometry g = SceneGraphUtility.getFirstGeometry(c);
if (g == null) return;
if (g instanceof IndexedFaceSet) {
IndexedFaceSet ifs = (IndexedFaceSet)g;
IndexedFaceSetUtility.calculateAndSetNormals(ifs);
}