jPCT - a 3d engine for Java => Support => Topic started by: Trob on February 09, 2005, 05:29:43 pm

Title: 3ds loader
Post by: Trob on February 09, 2005, 05:29:43 pm
Does 3ds loader load texture coordinates?
Another Question:
If i only want to use materials does loaded 3ds objects contain name of the objects...i mean these names i attached to them when modeling them
so i can attach materials later in jpct...

Jpct is a great engine, thx for that.
Title: 3ds loader
Post by: EgonOlsen on February 09, 2005, 11:29:54 pm
jPCT does load texture coords but it won't care for the names you gave to your (sub-)objects. They are loaded and named in the order that they have in the file. jPCT will query the TextureManager for textures named like the ones that you've added, if that's your question!?
Title: 3ds loader
Post by: Trob on February 10, 2005, 01:12:49 am
I want show a house indoor with jpct, which file format is the best one,
if i dont want to use textures but only materials?
Is exporting my house to .md2 a good idea?

I tryed 3ds but the loader seemed only importing poly-level information
Title: 3ds loader
Post by: EgonOlsen on February 10, 2005, 01:22:45 am
The 3ds loader should import textures (which you are obviously not using) and material colors. It won't import anything else like transparency, shinyness etc.
3DS should be the format of choice in your case. Just keep in mind that jPCT's 3DS loader (or the engine itself) is not meant to be a complete 3DS-viewer. Some information of the 3DS will get lost on the way...
If you are still having problems, feel free to send your 3DS file to me, so that i can verify what exactly you are trying to display and how to do that in the best way possible,
Title: 3ds loader
Post by: Anonymous on February 10, 2005, 01:31:39 am
Thx for the information...i was confused cause all polys on the screen was white 255,255,255... all walls every face  was a white mess in jpct...so therefore i wondered if jpct didnt load materials.

Im sure i assigned materials for my faces so i dont know what i did wrong  :roll:
Title: 3ds loader
Post by: EgonOlsen on February 10, 2005, 01:49:39 am
IF your materials contain colors, jPCT should load them. Due to the nature of jPCT, it should create a unicolored texture for each of them. Have a look at the console output while loading the 3DS. Does it tell you that some textures have been added to the TextureManager? If it does, the colors are most likely loaded correctly.
Title: 3ds loader
Post by: Anonymous on February 10, 2005, 11:50:57 am
No it says only that material have been added. Other 3D applications can load my 3ds file correctly with materials. I dont create a texmanager now....maybe i should?

Btw thx for the quick response, u are a life saver  8)
Title: 3ds loader
Post by: EgonOlsen on February 10, 2005, 01:11:40 pm
Can you send me a 3DS file that shows this problem, please?! If it says that materials have been added, it should work. If it doesn't, something is wrong either with your code or with my loader, but i can't verify it without an example.

TextureManager is a singleton. It will be created automatically if needed. You don't have to care about it.
Title: 3ds loader
Post by: Trob on February 10, 2005, 01:30:48 pm
Da Code:
Code: [Select]

 * @(#)Huset.java 1.0 05/02/04
 * Author: Risto Karhu 2005

import java.awt.*;
import java.applet.*;
import com.threed.jpct.*;
import com.threed.jpct.util.*;

public class Huset2 extends Applet implements Runnable {
Thread tTrad = null;
World mWorld = null;
Camera mCamera = null;
FrameBuffer buffer = null;

public void init(){
tTrad = new Thread(this);
mWorld = new World();

//skapa ljus
      mWorld.setAmbientLight(155, 15, 155);
      //sätt up kameran
        mCamera.lookAt(new SimpleVector(0f,10f,10f));

   //sätt upp ett ljus ovanför kameran
        mWorld.addLight(new SimpleVector(-10, 10, 0), 130, 130, 200);

        //ladda 3ds...
        Object3D[] oHuset = Loader.load3DS(this.getDocumentBase(),"testhus.3ds", 2f);      
        for(int i=0; i<oHuset.length; i++){
        //build objects

public void start(){
//starta animations tråden
tTrad = new Thread(this);

public void stop(){
mWorld = null;
tTrad = null;

public void update(Graphics g){

public void paint(Graphics g) {

public void myUpdate(Graphics g) {

public void run(){
//oändlig loop

   buffer=new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);


 //flytta kameran


try{ tTrad.sleep(20);}
catch(InterruptedException e){}


//stäng ner java
Title: 3ds loader
Post by: Trob on February 10, 2005, 02:16:11 pm
Im a newb using a 3d engine like jpct so my code could be bad. Btw my 3d object is flickering when i rotate my camera. Should i use doublebuffer or what? Maybe i have missed something somewhere...
Title: 3ds loader
Post by: Trob on February 10, 2005, 04:43:19 pm
Is jpct supposed to only run in a window (=Frame)?
Title: 3ds loader
Post by: EgonOlsen on February 10, 2005, 05:20:19 pm
As mentioned: I can't really test it without the model that you are using. I compiled your code and loaded a 3ds of mine instead and it looked fine. I suggest to change the ambient lighting to
mWorld.setAmbientLight(155, 155, 155);
and to remove the additional light source that you are adding to mWorld.
What do you get then? Still everything white?
I'm also unable to notice any flickering in your applet. What is there is some tearing, because you can't synchronize the applet's drawing with the monitor's refresh, but that's ok.
jPCT doesn't care about frames or other components. All it does, is to render into an Image. You can do with this image whatever you want to. The draw(Graphics)-methods from FrameBuffer are just shortcuts to g.drawImage(...) calls. You don't have to use them...
Title: 3ds loader
Post by: Trob on February 10, 2005, 06:18:57 pm
This is very very strange. I tested the "ql.3ds" file and viewed it from every point (so i didnt see back of faces) . I did it with other files too and all i get is every polygon has the white color. ITs constantly white all over every face indepent if i see them from front or back or from side.
BUT every example works very well and i can see the earth on the main page so im beginning thinking something must be wrong when i compile my projects.  Im going to compile the examples if its going to show the same white mess.  :shock:

Im using JavaSDK 1.4 And eclipse.
Windows XP Pro
2.5Ghz AMD
Gf4 Ti with nvidia drivers
512MB Memory.

Should i use Java 1.1 instead cause im using applets, what do u think?
(Im using appletviewer to test my project so it should take 1.4)

Im almost giving up but thank u that u always are willing to answer..
Title: 3ds loader
Post by: Trob on February 10, 2005, 06:20:43 pm
Btw, i removed the light and set the ambientlight to 155,155,155...no diffetence except the color switced to slightly yellow(!????)

Title: 3ds loader
Post by: EgonOlsen on February 10, 2005, 09:04:55 pm
The ql.3ds doesn't define diffuse colors for its materials, so it's to be expected if it shows up all white. I think that you are somehow not defining diffuse colors for your materials too (or the loader is buggy, but i never noticed anything like that). Try this file: http://www.jpct.net/download/Park.zip
Its materials are using diffuse color information only and it definitely loads and displays fine in your applet (i used it to test it).
I can only repeat myself: I can't really help you, if i don't have the model at hand that you are using.
Title: 3ds loader
Post by: Anonymous on February 10, 2005, 09:09:13 pm
Um.... :oops:  u were right it showed the colors, used blender to assign material and didnt set the diffuse colors there i think.

Thank u very much for ur very BIG help. 8)
Title: 3ds loader
Post by: Trobs on February 10, 2005, 09:56:18 pm
I did set the diffuse colors but maybe the converter doesnt convert it right to .3ds.

But i know that code is right so i think i have to  change coverter or something :)