how do u create a 3d model in java?

Recommended Answers

All 11 Replies

Google "java3d". If I remember right, there is an API for this.

>how do u create a 3d model in java?

You normally don't *create* 3D models in Java; you use a 3D modeling tool like Maya[commercial], 3DS Max[commercial] or Blender[free].

This model is then loaded and rendered in your application using a rendering API like JOGL or a game engine like jME. The first approach requires you to write all the file format parsing code and rendering the model polygon by polygon; definitely messy and scary. The second approach is much simpler since it requires you to only create the model and export it in a format supported by your game engine like .3ds, .md5 etc.

That all being said, rendering graphics and games using Java is still slower as compared to the same done using C++; so if you are serious about game development, better mess around with C++/DirectX than with Java. If this is just a hobby project, then game on. :-)

thanks for the replies. they really helped.. my problem is i need to use milkshape 3d i downloaded a file and tried this code right here

import java.net.URL;
import com.sun.j3d.loaders.*;
import com.glyphein.j3d.loaders.milkshape.MS3DLoader;

public class shoulders {
	
  	try
	{	
  		Scene s = null;
  		Loader loader = new MS3DLoader (MS3DLoader.LOAD_ALL);	// .ms3d Loader

  		
  		java.io.File file = new java.io.File("./model.ms3d");
  		if (file.getParent().length() > 0) 
  		  loader.setBasePath(file.getParent() + java.io.File.separator);
  		Scene scene = loader.load(file.getName());
  		BranchGroup group = scene.getSceneGroup();


	}

      	catch (java.net.MalformedURLException ex1){	
      	}
      	catch (java.io.FileNotFoundException ex){
      	}
}
}

but its not working for me

it sais there are restrictions in the library

Since you are gobbling up exceptions, it's difficult to say anything. You should replace your try...catch block with something like:

try {
  //loading code
} catch(Exception e) {
  e.printStackTrace();
}

BTW, I personally feel that you are better off posting questions related to Java3D on the respective forum since you would be interacting with a bunch who have actually used/are using Java3D as opposed to plain old Java programmers like us. :-)

it didnt work ... but thanks for trying and for the link

>it didnt work

The template I pasted wasn't supposed to solve the problem, it was to aid us/you in getting to the root of the problem. In simple terms, by doing e.printStacktrace(), you get a detailed report of the root cause of the problem. After running your new code, take a look at your output window/console. Do you see anything along the lines of FileNotFoundException?

{...}
e : Exception
{...}

all the underlined names that i said earlier.. at least i think i did..

say

access restriction to c:/program files/java/jre6/lib/ext/j3dutils.jar

First of all, use the classpath properly, do not place jars in the ext folder.

Second, read the documentation again, as it may be that you are suppossed to be using those classes through interfaces/factories rather than trying to instantiate them directly.

i placed them in the project folder and imported them in the project

is there a way to change the directory its trying to load?

I'm sorry, but I don't understand what you mean by

change the directory its trying to load

>is there a way to change the directory its trying to load?

You need to set the classpath when executing your Java class files.

java -cp folder\jar1.jar;folder\jar2.jar YourClass
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.