### 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.

### Topics - gamerfan

Pages: 1 [2]
16
##### Support / Object translation clarification
« on: July 01, 2011, 04:02:23 pm »
I am further understanding this rotation and camera movement of collisionDemoSoftware.This time I have added the code for moving the cube along Y-axis.And this is the following code I have added.But what happens is that the camera itself is moving up and the cube disappears.
Code: [Select]
if(keyA) {
SimpleVector t = cube.getYAxis();
t.scalarMul(SPEED);
moveRes = cube.checkForCollisionEllipsoid(moveRes, ellipsoid, 8);
if(moveRes.y < 0) {
System.out.println(" less than zer0....");
cube.translate(0, 0.25f, 0);
}
else {
cube.translate(moveRes);
}

cube.translateMesh();
cube.clearTranslation();
}
I have added the above two lines. But the cube is not moving along y-axis, similarly the way it is moving along z-axis. Instead of that, the camera itself is moving up as I described earlier.What exactly I am missing here?

17
##### Support / Object rotation
« on: June 29, 2011, 11:44:23 am »
Hi,
I was going through the CollisionDemoSoftware and trying to understand how it works.There I noticed one thing that the small cube has been placed on the plane.Here I need to rotate the small cube along X-axis to a certain degree.But when rotated the cube, the entire scene was away from the other objects along with small cube. (In fact, only the small cube is visible). What I want to achieve here is everything should be there as expected but the small cube should be rotated along x axis. This is the code I have used.

Code: [Select]
cube = Primitives.getCube(2);
cube.translate(-50, -10, -50);
cube.rotateX(SPEED);
cube.rotateMesh();

How to handle this? Thanks in advance.

18
« on: June 20, 2011, 07:37:56 pm »
Hi,
I am new to jPCT and am using this framework to develop a sample game.I am trying yo load .obj file under 3ds folder.I have created .obj file from .blender file using its exporter.But when I run the following code I am getting this exception:

Quote
Processing object from OBJ-file: Cube_Cube.001
Object 'Cube_Cube.001_jPCT0' created using 12 polygons and 8 vertices.
Processing object from OBJ-file: Plane.001_Plane
Object 'Plane.001_Plane_jPCT1' created using 10368 polygons and 5329 vertices.
Processing object from OBJ-file: butterfly_logic
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -10000
at jpctdemo.Main.<init>(Main.java:46)
at jpctdemo.Main.main(Main.java:83)

Let me paste the code here.This sample I have taken from the forum only.

Code: [Select]
package jpctdemo;

import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
import com.threed.jpct.*;
import java.io.File;

class Main extends JFrame
{
private FrameBuffer _buffer = null;
private World _world = null;
private TextureManager _texMgr = null;
private Camera _camera = null;
private int _width = 800;
private int _height = 600;
private Graphics _graphics = null;
private int _titleBarHeight = 0;
private int _leftBorderWidth = 0;
private Object3D[] _model = null;

public Main()
{
super("jPCT " + Config.getVersion());
Config.glFullscreen = false;
Config.glMipmap = true;
Config.glColorDepth = 16;
Config.maxPolysVisible = 64000;

_world = new World();
_world.getLights().setOverbrightLighting(Lights.OVERBRIGHT_LIGHTING_DISABLED);
_world.getLights().setRGBScale(Lights.RGB_SCALE_2X);
_world.setAmbientLight(25, 30, 30);
_world.addLight(new SimpleVector(-1000, -150, 1000), 22, 5, 4);
_world.addLight(new SimpleVector(1000, -150, -1000), 4, 2, 22);

_texMgr = TextureManager.getInstance();
char c = File.separatorChar;

for (int i = 0; i < _model.length; i++)
{
_model[i].setTexture("prop_butterfly_diff");
}

_camera = _world.getCamera();
_camera.setPosition(-12, 90, 0);  // ARGGGHH  how can I center the camera over the stick figure?
_camera.lookAt(_model[0].getTransformedCenter());

_world.buildAllObjects();
Config.tuneForOutdoor();

Insets insets = getInsets();
_titleBarHeight = insets.top;
_leftBorderWidth = insets.left;
setSize(_width + _leftBorderWidth + insets.right, _height + _titleBarHeight + insets.bottom);
setResizable(false);
setVisible(true);

_graphics = getGraphics();

_buffer = new FrameBuffer(_width, _height, FrameBuffer.SAMPLINGMODE_NORMAL);
_buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
_buffer.setBoundingBoxMode(FrameBuffer.BOUNDINGBOX_NOT_USED);
_buffer.optimizeBufferAccess();
_buffer.disableRenderer(IRenderer.RENDERER_OPENGL);

drawWorld();
}

public static void main(String[] args)
{
new Main();
}

private void drawWorld()
{
_buffer.clear();
_world.renderScene(_buffer);
_world.draw(_buffer);
_buffer.update();
_buffer.display(_graphics, _leftBorderWidth, _titleBarHeight);
}

private class MouseDragListener implements MouseMotionListener
{
final float speed = 0.05f;
int lastX = 0;
int lastY = 0;

public void mouseDragged(MouseEvent me)
{
int currentX = me.getX();
int currentY = me.getY();

if (currentX > lastX)
{
// the mouse is going to the right
_model[0].rotateX(speed);
}
else if (currentX < lastX)
{
// the moust is going to the left
_model[0].rotateX(-speed);
}

if (currentY > lastY)
{
// we are going down on the screen
_model[0].rotateY(speed);
}
else if (currentY < lastY)
{
// we are going up on the screen
_model[0].rotateY(-speed);
}

lastX = currentX;
lastY = currentY;
drawWorld();
}

public void mouseMoved(MouseEvent arg0)
{
}
}
}

Can you please look into this issue and tell what I am doing wrong here.

Thanks,

Pages: 1 [2]