I guess you will find the Java3D Tutorial very usefull. You can get it at Java3D Collateral page: http://java.sun.com/products/java-media/3D/collateral/
About materials and Wavefront OBJ models: The best 3D tools exports allongside Wavefront OBJa small text file with ".mtl" extension. example: spike.obj spike.mtl
Java3D's ObjectFile loader loads the obj and creates the correct material with .mtl file info.
To add your own Appearance setting just create a new Appearance object and do update the nodes, as Lorenzo sugested:
// s is your obj scene loaded AFTER your load it
Hashtable hashObjNames = s.getNamedObjects();
Enumeration enum = hashObjNames.keys();
System.out.println("Element in the loaded file:");
while (enum.hasMoreElements())
{
Object item = enum.nextElement();
Object obj = hashObjNames.get(item);
if (obj instanceof Shape3D)
{
// add my new appearance
((Shape3D)obj).setAppearance(myNewAppearance);
}
System.out.println((String)(item)+" - "+hashObjNames.get(item));
}Try it on ObjLoad demo ;)
Alessandro
Johannes Neubauer escreveu:
Hello,
I’ve a real big Problem with Java3d. I try to program a Java3d multiplayer Space Shooter. The objects like the landscape and the space ship models are loaded with a loader (ObjectFile). My 3d Modeling Program exports Wavefront .obj files only without lights and materials and so on. So I don’t know how to add an Appearance object to a loaded .obj file and its geometry. I can’t set the Appearance object to the BranchGroup object I get from the Scene object. How can I change the material and/or set something like CULL_NONE.
I hope you can help me,Thank you very much,
Sincerely,
Johannes Neubauer
=========================================================================== 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".
