What happens if you make slowCamMovement smaller, like say 5.0f? Also, make sure all your variables are either floats or type-cast as floats in your "speed=" algorithm (so Java doesn't try to do integer division and round to zero).
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 Menu // Creates a cube of the specified color
private Object3D coloredCube( float scale, Color color )
{
TextureManager.getInstance().addTexture( "CubeClr",
new Texture( 4, 4, color) );
// 'offset' is simply half the length of the cube's side:
float offset = 0.5f * scale;
// Create a new object with the proper number of polys:
Object3D obj = new Object3D( 12 );
// Define the object's polys:
obj.addTriangle( new SimpleVector( -offset, -offset, -offset ), 0, 0,
new SimpleVector( -offset, offset, -offset ), 0, 1,
new SimpleVector( offset, offset, -offset ), 1, 1,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( offset, offset, -offset ), 1, 1,
new SimpleVector( offset, -offset, -offset ), 1, 0,
new SimpleVector( -offset, -offset, -offset ), 0, 0,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( offset, -offset, offset ), 0, 0,
new SimpleVector( offset, offset, offset ), 0, 1,
new SimpleVector( -offset, offset, offset ), 1, 1,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( -offset, offset, offset ), 1, 1,
new SimpleVector( -offset, -offset, offset ), 1, 0,
new SimpleVector( offset, -offset, offset ), 0, 0,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( -offset, -offset, offset ), 0, 0,
new SimpleVector( -offset, offset, offset ), 0, 1,
new SimpleVector( -offset, offset, -offset ), 1, 1,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( -offset, offset, -offset ), 1, 1,
new SimpleVector( -offset, -offset, -offset ), 1, 0,
new SimpleVector( -offset, -offset, offset ), 0, 0,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( offset, -offset, -offset ), 0, 0,
new SimpleVector( offset, offset, -offset ), 0, 1,
new SimpleVector( offset, offset, offset ), 1, 1,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( offset, offset, offset ), 1, 1,
new SimpleVector( offset, -offset, offset ),1, 0,
new SimpleVector( offset, -offset, -offset ), 0, 0,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( -offset, -offset, offset ), 0, 0,
new SimpleVector( -offset, -offset, -offset ), 0, 1,
new SimpleVector( offset, -offset, -offset ), 1, 1,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( offset, -offset, -offset ), 1, 1,
new SimpleVector( offset, -offset, offset ), 1, 0,
new SimpleVector( -offset, -offset, offset ), 0, 0,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( -offset, offset, -offset ), 0, 0,
new SimpleVector( -offset, offset, offset ), 0, 1,
new SimpleVector( offset, offset, offset ), 1, 1,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.addTriangle( new SimpleVector( offset, offset, offset ), 1, 1,
new SimpleVector( offset, offset, -offset ), 1, 0,
new SimpleVector( -offset, offset, -offset ), 0, 0,
TextureManager.getInstance().getTextureID( "CubeClr" ) );
obj.build();
return obj;
}
public void rotateScene90( Object3D[] sceneObjects, SimpleVector lookTarget, Camera camera )
{
SimpleVector sourcePosition, targetPosition, translation;
for( int x = 0; x < sceneObjects.length; x++ )
{
// convert object's position into camera space:
sourcePosition = new SimpleVector( sceneObjects[x].getTransformedCenter() );
sourcePosition = sourcePosition.calcSub( camera.getPosition() );
sourcePosition.matMul( camera.getBack() );
// determine the new position (in camera space):
targetPosition = new SimpleVector(sourcePosition.z, sourcePosition.y, sourcePosition.x );
// convert new position into world space:
targetPosition.matMul( camera.getBack().invert3x3() );
targetPosition.add( camera.getPosition() );
// translate to the new position:
sceneObjects[x].translate( targetPosition.calcSub( sceneObjects[x].getTransformedCenter() ) );
}
// convert the look-target into camera space:
sourcePosition = new SimpleVector( lookTarget );
sourcePosition = sourcePosition.calcSub( camera.getPosition() );
sourcePosition.matMul( camera.getBack() );
// determine the new look-target (in camera space):
targetPosition = new SimpleVector(sourcePosition.z, sourcePosition.y, sourcePosition.x );
// convert the new look-target into world space:
targetPosition.matMul( camera.getBack().invert3x3() );
targetPosition.add( camera.getPosition() );
// look toward the new look-target:
SimpleVector look = targetPosition.calcSub( camera.getPosition() ).normalize();
SimpleVector up = camera.getYAxis();
up.scalarMul( -1 ); // Bug fix, shouldn't be necessary? Try removing if scene is upside-down
camera.setOrientation( look, up );
}
vector.matMul( camera.getBack().invert3x3() );
vector.add( camera.getPosition() );
camera.setPosition( 0, 50, 0 );
camera.setOrientation( new SimpleVector( 0, -1, 0 ), new SimpleVector( 0, 0, -1 ) );
SimpleVector vector = new SimpleVector( 50, 0, 0 );
vector.matMul( camera.getBack().invert3x3() );
vector.add( camera.getPosition() );
Quote from: AGP on September 28, 2010, 10:45:13 PMIs camera at 0,0,0? If not, you'll need to subtract it from the converted vectors. Also try reversing the sign of x, z, or both.
I flipped the values now and, unfortunately, no cigar. I see nothing on screen.
Quote from: AGP on September 28, 2010, 10:31:09 PM
Well, jPCT's up axis is -y, whereas worldspace up for max is +z. I accounted for that. Or do you mean something else?
Quote from: AGP on September 28, 2010, 09:05:01 PMWhen I commented-out the entire matrix thing and set the FOV to 45 (as it is in Max), and entered the position of the camera (-y/z flipped) and set camera.lookAt to the position of Max's camera's target, I got a camera looking sideways at the scene (as if it had been jpctY-rotated 90ยบ around the center of the scene). But I got to see the characters (the height was right). Bizarre, right?This sounds like you have the wrong coordinate system. The fact that you see the characters should mean that the target position is in the same coordinate system as the camera lookAt position, but the fact that in jPCT's coordinate system everything is rotated and you are looking from the side could mean that the entire scene (including the lookAt vector you are using) is rotated 90 around the jPCT camera's y-axis. You should be able to just flip the x and z coordinates (in camera space) for the object positions and the camera lookAt vector (leave the camera in the position you have it), to have everything oriented properly.
Quote from: AGP on September 28, 2010, 10:15:45 PMCorrect as long as the camera is aligned with the cardinal directions.
Question: is the up-vector just, say, a (0, 1, 0)-type of vector? Meaning are there only three (or six with negative values) possibilities for it?
myTexture = new Texture( width, height, true );
BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_4BYTE_ABGR );
myTexture = new Texture( image, true );
Page created in 0.024 seconds with 10 queries.