Hi, all:
This could be a silly question but I really need a help… Urgent help please…
- First, I’m able to load .obj file successfully. For instance, the current loaded .obj file “a.obj” looks like:
In order to display “a.obj” on the screen, I have to load this “a.obj” by using
int flags = ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY | ObjectFile.RESIZE;
ObjectFile f = new ObjectFile(flags, (float)(creaseAngle * Math.PI / 180.0));
Scene s = f.load("a.obj"); // Exception is ignored here by me
BranchGroup bg = s.getSceneGroup();
Shape3D obj3d = (Shape3D)bg.getChild(0);
Whenever I updated the values of “v” (let’s just call it “updated-v”), I saved the data into another .obj file “b.obj”.
(Note, values of “vt” and “f” are unchanged. )
In order to display it on the screen, I have to reload this “b.obj” by using
int flags = ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY | ObjectFile.RESIZE;
ObjectFile f = new ObjectFile(flags, (float)(creaseAngle * Math.PI / 180.0));
Scene s = f.load("b.obj");
again, which I think is a very silly way.
Because to save the data onto the hard-drive and reload the data from the hard-drive into the memory is very very time-consuming.
- I’m guessing that I should be able to assign the “updated-v” values directly into the already-loaded Shape3D “obj3d”.
Therefore, I tried the following:
GeometryArray ga = (GeometryArray)obj3d.getGeometry();
GeometryInfo gi = new GeometryInfo( ga );
gi.setCoordinates("updated-v");
obj3d.setGeometry(gi.getGeometryArray());
However, there is something displayed, but the scaling is wrong, and the shape and texture is not what I expected.
I re-iterate it once again.
a) If I save “updated-v” into the “b.obj” directly and reload “b.obj”, I can display the object correctly, with correct Shape3D, but this is too time-consuming.
b) If I just use the above 4 lines of codes as shown in 2), the object is displayed wrongly, wrong Shape3D for sure, and wrong scaling. Wrong displaying texture is probably due to the wrong Shape3D.
Can anybody please give me a hand on my difficulty?
Best Regards
JIA