Hi, That is exactly I did : A Hashtable to store part name as key and TransformGroup as stored objects. So I could easily and quickly apply movements to a character in a keyframe demo. I always knew what the part were doing what. I guess OBJ files results in Shape3Ds instead TGs as vrml models do, but you can create a sligthly approach to it : de-attach the shape3Ds and add then to TGs, then add these TGs as child of a Group node. Every thing under control .
Alessandro ----- Original Message ----- From: "Florin Herinean" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, June 02, 2003 4:27 AM Subject: [JAVA3D] AW: [JAVA3D] 3D Studio MAX Just a quick comment: if you have few objects, the Vector stuff should be ok. However, if the number of objects increases and you need speed, you may consider using a HashMap or Hashtable for storing the name-shape pairs instead of a Vector. Cheers, Florin -----Urspr�ngliche Nachricht----- Von: Martin Frey [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 30. Mai 2003 21:31 An: [EMAIL PROTECTED] Betreff: Re: [JAVA3D] 3D Studio MAX Hi andrei in my programs i do the same. i make a class that hold the shape3D and every other information i need. An other way is to attach a UserData-Object to every shape3D which's holding these informations. i don't know which way is better, but i prefer the first, that's why i can create behaviors and so on in the class which holds the shape too. Here's a loaderclass for obj-files which is holding a vector of loaded shapes or loads the obj-file with the given name: To all other people out there: look at the code too please and tell me if this is a good way to handle objects in a scene. Regards Martin /*************************************************************************** ************ * Loader.java * * Created on 23. April 2003, 17:49 */ package MyProg.util; import javax.vecmath.*; import javax.media.j3d.*; import com.sun.j3d.loaders.objectfile.ObjectFile; import java.util.*; /** * * @author Administrator */ public class Loader { public Loader(){ shapes = new Vector(); } public Shape3D getShape(String name){ Enumeration e = shapes.elements(); while (e.hasMoreElements()){ Shape3D shape = (Shape3D) e.nextElement(); if (name.equals(shape.getUserData())){ return (Shape3D) shape.cloneTree(); } } loadShape(name); return getShape(name); } private void loadShape(String name){ ObjectFile file = new ObjectFile(ObjectFile.RESIZE); try{ com.sun.j3d.loaders.Scene s = file.load(getClass().getResource("/MyProg/resources/" + name + ".obj")); Shape3D shape = (Shape3D) s.getSceneGroup().getChild(0); shape.setCapability(Shape3D.ALLOW_APPEARANCE_READ); shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); shape.getAppearance().setCapability(Appearance.ALLOW_MATERIAL_READ); shape.getAppearance().setCapability(Appearance.ALLOW_MATERIAL_WRITE); shape.setUserData(name); shapes.add(shape); } catch (Exception e) { System.out.println(e); } } private Vector shapes; } **************************************************************************** *********/ All you have to do is create your class and pass the Loader to it to get the shapes. Here's my GameObject-Class: /*************************************************************************** ********* * GameObject.java * * Created on 21. April 2003, 17:02 */ package MyProg.gameobjects; import MyProg.util.Loader; import javax.media.j3d.*; import javax.vecmath.*; /** * * @author Administrator */ public abstract class GameObject { /** Creates a new instance of Enemy */ public GameObject(Loader loader, String name){ tg = new TransformGroup(); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); shape = loader.getShape(name); tg.addChild(shape); } public Shape3D getShape(){ return shape; } public TransformGroup getTransformGroup(){ return tg; } private Shape3D shape; private TransformGroup tg; } ***********************************************************************/ I hope this helps you a little. Greetz Martin ----- Original Message ----- From: "andrei" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 29, 2003 2:30 PM Subject: Re: [JAVA3D] 3D Studio MAX > Martin Frey wrote: > > >download the obj-file exporter and load these objfiles. it works great and > >they works with textures and so on. > > > >greetz Martin > > > hello list, > > what loaders for 3DS and DXF files do you like more? > > I need to build several classes for objects that are external files. So, > when an object is created, the constructor loads the file and this is > the 3d object. I tried some loaders yesterday, but something is not > working... > > thank you, > andrei > > -- > "First of all you can't be subversive without being subversive to yourself, that's very important. You miss something crucial if you think subversion means to have clearly defined enemies and act against them. The enemy always is always you, too and in the first place." > > http://www.koreawebart.org/0100101110101101org.html > > =========================================================================== > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff JAVA3D-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". ========================= To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
