I made a gun model with Milkshape, and when i imported it, it kind of showed up, but it was completely black, even though i had textured it, then I tried a model i downloaded and it worked fine, so whats the deal?
A few things to check:
(1) Does your loader egenrate normals or does it assume you have set them? if the latter are your normals set proiperly?
(2) Does your loader expect you to have set a material in your modeler? If so, did you?
ok I realized that in milkshape, you have to, when your done, regroup the entire model into one group,
I had it where i grouped it differently, to do textures (i.e. different colors for stuff), are I did this, the model imported with success.
ONLY problem is, and its a big problem, when I regrouped, all the texturing stuff got deleted, so do you know how to keep the textures?
Also another problem, I can run my program as a Application just fine, but when I try to open it as an applet in html, it has an error initializing
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.vp.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.loaders.*;
import com.glyphein.j3d.loaders.milkshape.MS3DLoader;
public class LandTest extends Applet
{
SimpleUniverse u;
BoundingSphere bounds;
ViewingPlatform ourView;
OrbitBehavior B;
public void init()
{
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
u = new SimpleUniverse(c);
BranchGroup scene = createSceneGraph();
u.addBranchGraph(scene);
ourView = u.getViewingPlatform();
ourView.setNominalViewingTransform();
B = new OrbitBehavior(c);
B.setSchedulingBounds(bounds);
ourView.setViewPlatformBehavior(B);
add("Center",c);
}
public BranchGroup createSceneGraph()
{
BranchGroup objRoot = new BranchGroup();
bounds = new BoundingSphere();
String filePath="file://localhost/"+System.getProperty("user.dir")+"/";
String texturePath=filePath + "stone.jpg";
Land s = new Land(6, 6, texturePath);
try
{
java.net.URL modelPath = new java.net.URL(filePath+"gun2.ms3d");
Loader msLoader = new MS3DLoader();
Scene ourScene;
ourScene = msLoader.load(modelPath);
BranchGroup modelBranch = ourScene.getSceneGroup();
Shape3D model= (Shape3D)modelBranch.getChild(0);
modelBranch.removeChild(0);
/*Appearance modelapp = new Appearance();
Color3f objColor = new Color3f(0.7f, 0.2f, 0.8f);
Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
modelapp.setMaterial(new Material(objColor, black, objColor, black, 80.0f));
model.setAppearance(modelapp);*/
objRoot.addChild(model);
}
catch(Exception e){
}
Color3f alColour = new Color3f(0.4f, 0.4f, 0.4f);
AmbientLight aLgt = new AmbientLight(alColour);
aLgt.setInfluencingBounds(bounds);
Color3f DirColour = new Color3f(0.35f, 0.35f, 0.3f);
Vector3f DirVec = new Vector3f(-0.5f, -0.2f, 0.6f);
DirectionalLight DirLig = new DirectionalLight(DirColour, DirVec);
DirLig.setInfluencingBounds(bounds);
objRoot.addChild(DirLig);
objRoot.addChild(aLgt);
objRoot.addChild(s);
objRoot.compile();
return objRoot;
}
public static void main(String[] args) {
new MainFrame(new LandTest(), 256, 256);
}
}
error message:
Java Plug-in 1.5.0_06
Using JRE version 1.5.0_06 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\peter
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.lang.NoClassDefFoundError: javax/media/j3d/Bounds
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NoClassDefFoundError: javax/media/j3d/Bounds
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-8" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
It seems the errors point to a J3D installation issue (the applet classloader can’t find J3D classes).
Yet, this line:
String filePath="file://localhost/"+System.getProperty("user.dir")+"/";
also looks mighty suspicious (although the error would be a security exception, not a NoClassDefFoundError, taking the applet is unsigned)…
well this is how i installed java3d
i put the contents t in my jdk_1.5.06, jre_1.05.06, and also my jdk_1.5.06/jre_1.5.06
AIR you need to put the Java3D install into the jre dir within the JDK distriubtion…