Author Topic: new JPCT user - receiving error in the first steps  (Read 4967 times)

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
new JPCT user - receiving error in the first steps
« on: May 14, 2015, 11:43:06 am »
Hi guys,

in the first steps of coding a Java program which uses JPCT, I encounter this error, could you help me please?
machine: Laptop Sony VAIO VGN-FW 190
Display Adapter: Mobile Intel(R) 45 Express Chipset family (Microsoft Corporation WDDM 1.1)
my graphics drivers are up to date.
I am waiting for help of one of JPCT forum users and maybe changing the current IDE from Netbeans to Eclipse. but I do not think this error depends on the current IDE I am using.
============
run:
Loading Texture...box.jpg
[ Thu May 14 13:59:44 IRDT 2015 ] - ERROR: File 'box.jpg' not found - replacement texture used instead!
Java version is: 1.8.0_25
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Current mode:800 x 600 x 32 @59Hz
[ Thu May 14 13:59:44 IRDT 2015 ] - WARNING: ZBuffer depth of 24 not supported - trying something else now...!
[ Thu May 14 13:59:44 IRDT 2015 ] - WARNING: Does this machine actually support OpenGL? Trying everything at lowest settings now!
Driver is unknown!
[ Thu May 14 13:59:44 IRDT 2015 ] - ERROR: Unable to set any valid videomode on this machine!
[ Thu May 14 13:59:44 IRDT 2015 ] - ERROR: Can't set videomode - try different settings!
org.lwjgl.LWJGLException: Pixel format not accelerated
   at org.lwjgl.opengl.WindowsPeerInfo.nChoosePixelFormat(Native Method)
   at org.lwjgl.opengl.WindowsPeerInfo.choosePixelFormat(WindowsPeerInfo.java:52)
   at org.lwjgl.opengl.WindowsDisplay.createWindow(WindowsDisplay.java:247)
   at org.lwjgl.opengl.Display.createWindow(Display.java:306)
   at org.lwjgl.opengl.Display.create(Display.java:848)
   at org.lwjgl.opengl.Display.create(Display.java:757)
   at com.threed.jpct.GLHelper.init(GLHelper.java:208)
   at com.threed.jpct.GLRenderer.init(GLRenderer.java:24)
   at com.threed.jpct.FrameBuffer.enableRenderer(FrameBuffer.java:1134)
   at com.threed.jpct.FrameBuffer.enableRenderer(FrameBuffer.java:753)
   at com.threed.jpct.FrameBuffer.enableRenderer(FrameBuffer.java:700)
   at Reza.main(Reza.java:29)
BUILD SUCCESSFUL (total time: 5 seconds)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: new JPCT user - receiving error in the first steps
« Reply #1 on: May 14, 2015, 12:33:20 pm »
Are you sure that this is an official Intel driver and not something that came by Windows Update? Because Microsoft's graphics drivers don't support OpenGL.

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
Re: new JPCT user - receiving error in the first steps
« Reply #2 on: May 14, 2015, 03:16:34 pm »
[WIP]
Dear EgonOlsen,

you were right. my graphic Chipset was not updated by official Intel driver. I updated it and problem solved!
I just created my first hello world program. a cube started dancing in a 800*600 window. many thanks for your help.
My next project is loading a specific .obj mesh and its texture in this window.
do you have any clue how to start it. I got familiar with JAVA and now I want to know available techniques and methods in JPCT. I think I have to read wiki first?

Best,
reza

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: new JPCT user - receiving error in the first steps
« Reply #3 on: May 14, 2015, 04:54:08 pm »
Maybe not the whole wiki, but there's a Hello World tutorial which might help.

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
Re: new JPCT user - receiving error in the first steps
« Reply #4 on: May 14, 2015, 11:32:17 pm »
Thanks a lot for your help!!

I could just finish a program which loads my .OBJ mesh and its texture using jPCT.

Now I want to be able to rotate the model using mouse drag event. I want the model to be only rotated around y axis as mouse is dragged on the screen by user.
Could you please give me a clue to start it?

Many thanks,
Reza

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: new JPCT user - receiving error in the first steps
« Reply #5 on: May 14, 2015, 11:59:14 pm »
Here's a basic example that lets you rotate an object with the mouse. It offers a solution of both, object and camera rotation. In your case, I would go for object rotations.

Edit: Forgot the link: http://www.jpct.net/forum2/index.php/topic,977.msg6207.html#msg6207

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
Re: new JPCT user - receiving error in the first steps
« Reply #6 on: May 15, 2015, 01:27:53 pm »
Thanks for code snippet explaining rotation of objects using mouse events.
my specific questions are:
#1 - when creating a world and then a camera, what is the default position of camera in the world?
#2 - when loading an .obj mesh, does jPCT place the model in its default position which was used while creating the model? (whilst designing the model, it could have a desired distance from 0,0,0)
#3 - why do we have to use third line in the below code?

        Camera cam=world.getCamera();
        cam.moveCamera(Camera.CAMERA_MOVEUP, distance);
 -->  cam.rotateCameraX((float)Math.PI/2f);

================code for roatting object using mouse========
import com.threed.jpct.*;
import com.threed.jpct.util.*;
import org.lwjgl.opengl.*;
import org.lwjgl.input.*;

/**
 * A Simple demo for mouse-powered object viewing.
 * It offers two modes: Camera around object (default) and object "around" camera.
 */
public class GoogleCube {

    private static float distance=50;

    // If true, the object transforms related to the camera. If false, the camera to the object.
    private static boolean affectObject=false;

    public static void main(String[] args) throws Exception {
        World world=new World();
        FrameBuffer buffer=new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
        buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
        buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
        Object3D cube=Primitives.getSphere(15);
        world.addObject(cube);
        cube.build();
        Camera cam=world.getCamera();
        cam.moveCamera(Camera.CAMERA_MOVEUP, distance);
        cam.rotateCameraX((float)Math.PI/2f);
        world.setAmbientLight(100, 100, 100);
        Light light=new Light(world);
        light.setIntensity(0, 0, 255);
        light.setPosition(new SimpleVector(-100, 0, 0));

        Mouse.create();

        while (!Display.isCloseRequested() && !Mouse.isButtonDown(1)) {
            buffer.clear();
            world.renderScene(buffer);
            world.draw(buffer);
            buffer.update();
            buffer.displayGLOnly();

            int x=Mouse.getDX();
            int y=Mouse.getDY();
            int w=Mouse.getDWheel();

            if (Mouse.isButtonDown(0)) {
                SimpleVector line=new SimpleVector(x, 0, y);
                Matrix m=line.normalize().getRotationMatrix();
                if (affectObject) {
                    // Object "around" camera
                    cube.rotateAxis(m.getXAxis(), line.length() / 200f);
                } else {
                    // Camera around object
                    m.rotateAxis(m.getXAxis(), (float) -Math.PI/2f);
                    cam.moveCamera(Camera.CAMERA_MOVEIN, distance);
                    cam.rotateAxis(m.invert3x3().getXAxis(), line.length() / 200f);
                    cam.moveCamera(Camera.CAMERA_MOVEOUT, distance);
                }
            }
            if (w!=0) {
               float d=w/200f;
                if (affectObject) {
                    cube.translate(0, -d, 0);
                } else {
                    distance-=d;
                    cam.moveCamera(Camera.CAMERA_MOVEIN, d);
                }
            }

            Thread.sleep(10);
        }
        Mouse.setGrabbed(false);
        Mouse.destroy();

        buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
        buffer.dispose();
    }
}
==========================================

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: new JPCT user - receiving error in the first steps
« Reply #7 on: May 15, 2015, 06:59:47 pm »
Default camera is located at the origin looking along the positive z-axis. Each model will be loaded with the object space coordinates that the exporter assigns to it. Which these are depends on the exporter and the scene setup. After calling build(), you can get the center from an Object3D, which is usually a good indicator for the object space position.
The third line makes the camera look down. It highly depends on the scene, how the camera should be positioned. In this particular case, it moves up and then looks down.

Offline 3DLover

  • byte
  • *
  • Posts: 12
    • View Profile
Re: new JPCT user - receiving error in the first steps
« Reply #8 on: May 16, 2015, 04:03:49 pm »
Thank you.
another question, color of world  and background is black. how can I change it?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: new JPCT user - receiving error in the first steps
« Reply #9 on: May 16, 2015, 07:37:27 pm »
The background can be changed by clearing the screen with another color. And the world has a setter for ambient light.