Author Topic: Only texture color is 3D object.  (Read 1922 times)

Offline shmex

  • byte
  • *
  • Posts: 2
    • View Profile
Only texture color is 3D object.
« on: September 11, 2014, 08:22:13 pm »
Hello.
Why does picture of a texture is not displayed and all that displayed is a color of texture? 3Ds file is exported from Blender.

Code: [Select]
public class OneGraphics {

    private World world;
    private FrameBuffer buffer;
    private Object3D model;
    private String[] textures = {"OrnamentBorder0196_9_S"};
    //InputStream inputstream = new FileInputStream("/home/shmex/dddd.png");
   
    public static void main(String[] args) throws Exception{
    new OneGraphics().loop();
    }
   
    public OneGraphics() throws Exception {
       
        world = new World();
        world.setAmbientLight(200, 200, 200);
        //загрузка текстуры
       // Image image = ImageIO.read(new File("/home/***/ff.png"));
        //Texture tex = new Texture(image);
       
        TextureManager.getInstance().addTexture("trd.jpg", new Texture("/home/***/trd.jpg"));
        //TextureManager.getInstance().addTexture("Wood_Che.jpg", new Texture("/home/***/Wood_Che.jpg"));
        //загрузка модели
        model = loadModelfrom3DS("/home/shmex/rr.3ds", 2.5f);
       
        world.addObject(model);
        world.getCamera().setPosition(-10, 10, -10);
        world.getCamera().lookAt(model.getTransformedCenter());
       
    }
   
    private void loop() throws Exception {
       
        buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
        buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
        buffer.enableRenderer(IRenderer.RENDERER_OPENGL); 

        while (!org.lwjgl.opengl.Display.isCloseRequested()) {
           
            model.rotateX(0.01f);
            buffer.clear(java.awt.Color.BLUE);
            world.renderScene(buffer);
            world.draw(buffer);
            buffer.update();
            buffer.displayGLOnly();
            Thread.sleep(10);
        }
       
        buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
        buffer.dispose();
        System.exit(0);
    }
   
    private Object3D loadModelfrom3DS(String filename, float scale) {
        Object3D temp = null;
        Object3D[] file = Loader.load3DS(filename, scale);
       
        if (file.length==1) {
            temp=file[0];
            temp.setTexture("trd.jpg");
            temp.setTransparency(2);
            temp.setCulling(Object3D.CULLING_DISABLED);
            temp.rotateX(-(float)Math.PI/2f);
            temp.rotateMesh();
            temp.setRotationMatrix(new Matrix());
            temp.setAdditionalColor(new Color(100,100,100));
            temp.build();
        }
        return temp;
    }
output:

Loading Texture.../trd.jpg
Loading file /home/shmex/rr.3ds
File /home/shmex/rr.3ds loaded...476 bytes
Processing new material Material!
Processing object from 3DS-file: Cube
Object 'Cube_jPCT0' created using 12 polygons and 8 vertices.
Java version is: 1.7.0_65
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Running on Linux with a 32bit color setting...adjusting to 24bit instead!
Current mode:800 x 600 x 24 @63Hz
Driver is: unknown OpenGL driver on NVIDIA Corporation / GeForce 7300 GT/PCIe/SSE2
GL_ARB_texture_env_combine supported and used!
FBO supported and used!
VBO supported and used!
OpenGL renderer initialized (using 4 texture stages)
New WorldProcessor created using 1 thread(s) and granularity of 1!
Creating new world processor buffer for thread main
OpenGL renderer disposed
Visibility lists disposed!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Only texture color is 3D object.
« Reply #1 on: September 12, 2014, 10:48:19 am »
Most likely because the model has no proper texture coordinates.

Offline shmex

  • byte
  • *
  • Posts: 2
    • View Profile
Re: Only texture color is 3D object.
« Reply #2 on: September 12, 2014, 11:11:21 pm »
Сuriously...

Blender settings mapping:
coordinates: Generated
Projection   : Cube

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Only texture color is 3D object.
« Reply #3 on: September 14, 2014, 09:09:11 am »
I don't know much about Blender, but there are different ways to create texture coordinates and at least one of them doesn't make it into exported file formats. Might very well be that this is the case for 'projected'.