It's not consistently reproducible, when i try to reproduce It many times it ends in
ArrayOutOfBoundException in visList.
ArrayOutOfBoundException in visList.
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.
Show posts MenuQuoteunless 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 ,
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();
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);
line1.update(new SimpleVector[]{toy.getTransformedCenter(),toy3.getTransformedCenter()});
/*
* 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);
}
}
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());
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;
}
Page created in 0.097 seconds with 12 queries.