/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author nbriere */ public class FileObject extends Object3D { static final long serialVersionUID = 7549805881606093384L; // use this one! // 5484161350193026888L; // not standard void removeChild(Object3D child) { if (filecontent == child) filecontent = null; } boolean HasBigData() { return filecontent != null; } void ExtractBigData(java.util.Hashtable hashtable) { Object3D o; if (hashtable.containsKey(GetUUID())) { o = hashtable.get(GetUUID()); //Grafreed.Assert(this.filecontent == ((FileObject)o).filecontent); } else { o = new Object3D("copy of " + this.name); hashtable.put(GetUUID(), o); } ExtractBigData(o); } void RestoreBigData(java.util.Hashtable hashtable) { if (!hashtable.containsKey(GetUUID())) return; Object3D o = hashtable.get(GetUUID()); RestoreBigData(o); } boolean IsStatic() { return false; // ???? false; } // void Reset() // { // // filecontent = null; // } void ClearUI() { if (count == 0) return; super.ClearUI(); } Object3D GetObject() { if (filecontent == null) { System.out.println("Reading... " + name); if (objfile) { boolean stripify = cJME.stripify; cJME.stripify = false; // true; // Poses change stripification boolean red34 = cJME.reduction34; cJME.reduction34 = false; // true; filecontent = ObjEditor.ReadOBJ(name); cJME.stripify = stripify; cJME.reduction34 = red34; } else { filecontent = ObjEditor.ReadGFD/*z*/(name); if (filecontent != null) { filecontent.parent = null; filecontent.fileparent = this; filecontent.RepairTexture(); } // stripify on load instead? // OK... // filecontent.Stripify(); // fine. faster and read-only anyway } } return filecontent; } String name; boolean objfile; transient Object3D filecontent; FileObject(String fullname, boolean objfile) { super((String)fullname.subSequence(fullname.lastIndexOf("/")+1, fullname.length())); name = fullname; this.objfile = objfile; } void ExtractBigData(Object3D o) { super.ExtractBigData(o); o.savefilecontent = this.filecontent; // filecontent is transient this.filecontent = null; } void RestoreBigData(Object3D o) { super.RestoreBigData(o); this.filecontent = o.savefilecontent; } Object3D deepCopy() { FileObject e = new FileObject(name, objfile); deepCopySelf(e); return e; } protected void deepCopyNode(Object3D other) { super.deepCopyNode(other); } // void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected) // { // GetObject().Draw(display,root,selected); // } // cTreePath Select(int indexcount, boolean deselect) // { // return GetObject().Select(indexcount, deselect); // } public int Size() { //if (count == 0) // return 0; //if (filecontent == null) // return 0; return count>1?1:0; // GetObject().Size(); } public int size() { //if (filecontent == null) // return 0; return count>0?1:0; // GetObject().Size(); } public int size0() { //if (filecontent == null) // return 0; return count>=0?1:0; // GetObject().Size(); } public Object3D reserve(int i) { // assert(i==0); if (i != 0) System.exit(-1); return GetObject(); // .reserve(i); } public Object3D reserve0(int i) { // assert(i==0); if (i != 0) System.exit(-1); return GetObject(); // .reserve(i); } public void release(int i) { if (i != 0) System.exit(-1); // assert(i==0); // GetObject().release(i); } public Object3D get(int i) { if (i != 0) System.exit(-1); // assert(i==0); return GetObject(); //.get(i); } public int indexOf(Object3D obj) { if (obj == filecontent) return 0; return -1; //return GetObject().indexOf(obj); } }