Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - madhava.s

Pages: [1] 2
1
Support / Re: ClassCastException while using AWTGL renderer
« on: February 15, 2013, 04:09:38 am »
It's not consistently reproducible, when i try to reproduce It many times it ends in
ArrayOutOfBoundException in visList.

2
Support / Re: ClassCastException while using AWTGL renderer
« on: February 15, 2013, 04:07:43 am »
Quote
unless you have another thread that does funny things with jPCT related objects in parallel to your rendering thread. Do you?
yes Egon, there's another thread that keeps polling mouse and keyboard transforming, removing adding objects based on action. And another thing is ,
I get the error when I decrease the sleep time when I give sleep time above 1000 it never happens

3
Support / Re: ClassCastException while using AWTGL renderer
« on: February 14, 2013, 03:36:10 pm »
Manifest info

Manifest-Version: 1.0
Created-By: EgonOlsen
Version: 1.15beta3

4
Support / ClassCastException while using AWTGL renderer
« on: February 14, 2013, 03:35:35 pm »
Below is the exception i'm getting.

I'm spanning a separate thread for rendering as Below.
Code: [Select]

     new Thread(){
        @Override
        public void run(){
         while(true){   
            buffer.clear(java.awt.Color.WHITE);
            world.renderScene(buffer);
            world.draw(buffer);
            buffer.update();
            buffer.displayGLOnly();
            canvas.repaint();
            try {
                sleep(100);
            } catch (InterruptedException ex) {
                //do nothing     
            }
         }
        }
     }.start();
   
Getting the below exception
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.ClassCastException: com.threed.jpct.Camera cannot be cast to com.threed.jpct.World
   at com.threed.jpct.AWTJPCTCanvas.paintGL(AWTJPCTCanvas.java:233)
   at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:339)
   at org.lwjgl.opengl.AWTGLCanvas.update(AWTGLCanvas.java:368)
   at sun.awt.RepaintArea.updateComponent(RepaintArea.java:239)
   at sun.awt.RepaintArea.paint(RepaintArea.java:216)
   at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:310)
   at java.awt.Component.dispatchEventImpl(Component.java:4727)
   at java.awt.Component.dispatchEvent(Component.java:4481)
   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
   at java.awt.EventQueue.access$000(EventQueue.java:84)
   at java.awt.EventQueue$1.run(EventQueue.java:602)
   at java.awt.EventQueue$1.run(EventQueue.java:600)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
   at java.awt.EventQueue$2.run(EventQueue.java:616)
   at java.awt.EventQueue$2.run(EventQueue.java:614)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.ClassCastException: com.threed.jpct.Camera cannot be cast to com.threed.jpct.World
   at com.threed.jpct.AWTGLRenderer.executeGL(AWTGLRenderer.java:125)
   at com.threed.jpct.AWTJPCTCanvas.paintGL(AWTJPCTCanvas.java:190)
   ... 25 more






5
Support / Re: PolyLine update
« on: February 14, 2013, 03:31:46 pm »
Thanks Egon,
  Works fine tried with latest and Beta both of them work.

6
Support / Re: PolyLine update
« on: February 11, 2013, 06:40:52 am »
I'm creating a plane on which cubes are added as children. When user drags mouse  from one cube to other a line is drawn between them. Plane is rotatable. When plane is rotated cubes rotate with them, but not poly line, hence tried to update polyline. It din't work looks as in below image. Is there any way I can add polyline as child to plane ?

[attachment deleted by admin]

7
Support / PolyLine update
« on: February 10, 2013, 04:38:29 am »
I'm using PolyLine to draw line between 2 cubes. But updating the position of polyline after cubes are translated& rotated isnot taking effect.

Initial set up -- works fine
Code: [Select]
bounds=toy.getMesh().getBoundingBox();
                SimpleVector vec1=SimpleVector.create(
                        (bounds[0]+bounds[1])/2,
                        (bounds[2]+bounds[3])/2,
                        (bounds[4]+bounds[5])/2
                        );
                bounds=toy3.getMesh().getBoundingBox();
                SimpleVector vec2=SimpleVector.create(
                        (bounds[0]+bounds[1])/2,
                        (bounds[2]+bounds[3])/2,
                        (bounds[4]+bounds[5])/2
                        );
Polyline line1=new Polyline(new SimpleVector[]{vec1,vec2}, Color.GREEN);


Code used to update line position
Code: [Select]
line1.update(new SimpleVector[]{toy.getTransformedCenter(),toy3.getTransformedCenter()});
[attachment deleted by admin]

8
Thanks Egon and Thanks to paul for his examples. Dummy object did the trick
Code: [Select]
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jcptexp;

import com.threed.jpct.*;
import java.awt.Color;

public class JcptExp {
   
    public static void main(String[] args) {
                World w = new World();
FrameBuffer fb = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
fb.enableRenderer(IRenderer.RENDERER_OPENGL);
                Object3D dummy=Object3D.createDummyObj();
Object3D toy= Primitives.getCube(1);
Object3D toy2=Primitives.getPlane(2, 10f);


toy.setScale(0.5f);
toy2.setScale(2f);

toy.setAdditionalColor(Color.BLUE);
toy2.setAdditionalColor(Color.YELLOW);
toy2.setEnvmapDirection(Object3D.ENVMAP_XZ);
                toy2.rotateAxis(toy2.getRotationMatrix().getXAxis(), -0.3f);
                toy2.rotateAxis(toy2.getRotationMatrix().getYAxis(),0.2f);
                toy2.rotateAxis(toy2.getRotationMatrix().getYAxis(), -0.2f);
w.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 100);
w.getCamera().moveCamera(Camera.CAMERA_MOVEUP, 50);
                w.getCamera().setOrientation(SimpleVector.create(1,0,0), SimpleVector.create(0,-1,0));
                w.getCamera().align(toy2);
w.setAmbientLight(130, 130, 130);
                toy2.setOrientation(SimpleVector.create(1,0,0), SimpleVector.create(0,-1,0));
                dummy.setOrientation(SimpleVector.create(1,0,0), SimpleVector.create(0,-1,0));
                toy2.rotateZ(0.01f);
toy.build();
toy2.build();
float[] bounds=toy2.getMesh().getBoundingBox();
toy.addParent(toy2);
toy2.addParent(dummy);
w.addObject(toy);
w.addObject(toy2);

w.getCamera().lookAt(toy.getTransformedCenter());

offset(toy2, new SimpleVector(2,2,0));

                int i=-1;
while(!org.lwjgl.opengl.Display.isCloseRequested()) {
                        i*=-1;
                        //dummy.setRotationPivot(SimpleVector.create(i*0.001f,0,0));
                        dummy.rotateAxis(dummy.getRotationMatrix().getYAxis(),-0.0002f);
fb.clear(Color.RED);
w.renderScene(fb);
w.draw(fb);
fb.update();
fb.displayGLOnly();

                        try {
//Thread.sleep(100);
} catch(Exception e) {}

                       


}
fb.dispose();
System.exit(0);
}

static private void offset(Object3D which, SimpleVector amount) {
Matrix mb=which.getTranslationMatrix();
which.setTranslationMatrix(new Matrix());
which.translate(amount);
which.translateMesh();
which.setTranslationMatrix(mb);
}

}

9
Problem is i'm unable rotate around axis , but don't know where have I gone wrong in placing the Rotation pivot or rotating the axis.

10
Removed translation code still behavior is same . I'm using below code to set Rotation Pivot
Code: [Select]
                float[] bounds=layer1.getMesh().getBoundingBox();
                layer1.setCenter(SimpleVector.create(
                (bounds[0]+bounds[1])/2,
                (bounds[2]+bounds[3])/2,
                (bounds[4]+bounds[5])/2));
        layer1.setRotationPivot(layer1.getCenter());
Anything wrong here?


11
Tried to translate vector from origin to Geometric center. I was thinking this will give us vector parallel to absolute axes.

12
Thanks thomas, Problem solved only for Y-axis. :(
For Y-axis object rotates on center where as for Z & X axes plane circles around a point out it's bounds. pasting code below.

Code: [Select]
Matrix m = object.getRotationMatrix();
        SimpleVector objectAxis ;
        switch(axis){
            case X_AXIS:objectAxis=m.getXAxis();
                        objectAxis.add(object.getCenter());
                        object.rotateAxis(objectAxis, radians);
                        break;                       
               
            case Y_AXIS:objectAxis=m.getYAxis();
                        objectAxis.add(object.getCenter());
                        object.rotateAxis(objectAxis,radians);
                        break;
               
            case Z_AXIS:objectAxis=m.getZAxis();
                        objectAxis.add(object.getCenter());
                        object.rotateAxis(objectAxis,radians);
                        break;
        }


13
Unalbe to upload image..as in image in hyperlink. But insteand of plane there's a jcpt plane 300X300.

http://virtualskies.arc.nasa.gov/aeronautics/images/3axis.gif


14
i was experimenting with rotation plane around it's geometric center with mathematical X,Y,Z axis(not default Y Z axis of ) , I needed to do trial and error to get the position. Tried searching documentation, couldn't find it. Pls anybody shed some light on this, if it's already there in documentation n I have missed pls point me towards that.

15
Thanks Egon,
  I'm new JCPt, I was trying to set a texture if not available i want switch to another one. hence was expecting the exception. Thanks for pointing towards config.

Pages: [1] 2