Login  Register

Re: 3D loaders - 2 questions

Posted by jfpauly on Nov 10, 2024; 2:25pm
URL: https://forum.jogamp.org/3D-loaders-2-questions-tp4043577p4043612.html

*  _________________________________________________________________________
 * Changes  to the ObjectFile class:
 
 * lines 422 > 427 added to create a default group to allow material change
 * readFile method has been changed : if an unknown token is encountered skip
 * it instead of crash
 * makeScene method : add code to allow changes to geometry and appearance
_____________________________________________________
 readGroup()
 * some files contains null groups. Create one to get material assigned

             if (st.sval.contains("null")) {    
                 curGroup = "group" + grpnum;
                 grpnum++;
             }
_________________________________________________________
  readUsemtl()
 * make a group to get a separate shape3d.

if (st.ttype == ObjectFileParser.TT_WORD) {
            // next two lines added : make a group to get a separate shape3d. jfp 02/2017
            curGroup = "group" + grpnum;    
                 grpnum++;                  
            groupMaterials.put(curGroup, st.sval);
            // System.out.println(" Material Property " + st.sval + " assigned to group " + curGroup);
        }
______________________________________________________________
 readFile()
 * Add o token (object)

else if (st.sval.equals("o")) {      // object name
                    st.skipToNextLine();

 * Add else statement to prevent crashes (unknown token)

else {
                    System.out.println(st.sval + " unsupported token in this release");
                    st.skipToNextLine();
                    //throw new ParsingErrorException( st.sval + " token unknown. Line " + st.lineno());
                }
______________________________________________________________
 makeScene()
 * Add capabilities for picking change and appearance change
 geometry
 * allow coordinates change

                // Put geometry into Shape3d
                Shape3D shape = new Shape3D();
                // code change. jfp 25/02/2017. Add capabilities to the shape
                shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
                shape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
                shape.setCapability(Shape3D.ENABLE_PICK_REPORTING);
                shape.setCapability(Shape3D.ALLOW_PICKABLE_WRITE);
                //_______________________________________________
                // issue 638; default to BY_COPY for consistency
                shape.setGeometry(gi.getGeometryArray(false, false, false));
                // code change. jfp 25/02/2017. Add capabilities to the geometry
                GeometryArray geo = (GeometryArray) shape.getGeometry();
                geo.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
                geo.setCapability(GeometryArray.ALLOW_COORDINATE_READ);