ow ok, cool I thought every object the partakes in the collision needs to be ellipsoid or sphererical
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 Menuobject.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
object.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS | Object3D.COLLISION_CHECK_SELF);
for (int i=0;i<STATE.m_ClientObjects.size();++i)
{
SimpleVector temp= STATE.m_ClientObjects.elementAt(i).checkForCollisionSpherical(a, 128);
if (temp != a)
{
a = temp;
System.out.println("New translation: " + temp);
}
}
public Entity
{
... blah
// Create a extra light source for the bullet:
tracer = new Light(m_World);
Util.setColor(tracer,new Color(255, 210, 0, 5));
tracer.setPosition(start_pos);
}
protected void finalize() throws Throwable
{
...
m_World.removeObject(model);
tracer.disable();
}
private GLFONT glfont;
...
m_Buffer.update();
glfont.blitString(m_Buffer, "this is a blitted text", 10, 10, 1, Color.ORANGE);
m_Buffer.displayGLOnly();
m_Canvas.repaint();
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at facebookgame.IngameState.paint(IngameState.java:218)
at facebookgame.MainApp.paint(MainApp.java:58)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
private org.fenggui.Display display;
...
this.display = new Display(new AWTGLCanvasBinding((AWTGLCanvas)m_Canvas));
Window window = FengGUI.createWindow(display, true, false, false, true);
window.setTitle("my window");
window.setPosition(new Point(50,200));
window.getContentContainer().setLayoutManager(new RowLayout(false));
window.getContentContainer().getAppearance().setPadding(new Spacing(10, 10));
final ToggableGroup<String> toggableGroup = new ToggableGroup<String>();
RadioButton<String> radioButtonCoffee = new RadioButton<String>("coffee", toggableGroup, "coffee");
RadioButton<String> radioButtonTea = new RadioButton<String>("tea", toggableGroup, "tea");
radioButtonTea.setSelected(true);
Container container = new Container(new RowLayout(true));
container.addWidget(radioButtonCoffee);
container.addWidget(radioButtonTea);
window.getContentContainer().addWidget(container);
Exception in thread "Thread-21" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1348)
at org.fenggui.render.lwjgl.LWJGLTexture.createTextureID(Unknown Source)
at org.fenggui.render.lwjgl.LWJGLTexture.createTexture(Unknown Source)
at org.fenggui.render.lwjgl.AWTGLCanvasBinding.getTexture(Unknown Source)
at org.fenggui.theme.DefaultTheme.setUp(Unknown Source)
at org.fenggui.theme.StandardTheme.setUp(Unknown Source)
at org.fenggui.StandardWidget.setupTheme(Unknown Source)
at org.fenggui.RadioButton.<init>(Unknown Source)
at facebookgame.IngameState.buildGUI(IngameState.java:417)
at facebookgame.IngameState.enter(IngameState.java:105)
at facebookgame.MainApp.switchState(MainApp.java:136)
at facebookgame.MainApp.stateEvent(MainApp.java:148)
at facebookgame.LoadingState.tick(LoadingState.java:75)
at facebookgame.MainApp.run(MainApp.java:87)
at java.lang.Thread.run(Unknown Source)
package testgame;
import java.util.HashMap;
import java.util.Iterator;
import java.awt.BorderLayout;
import java.awt.Canvas;
import org.lwjgl.Sys;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
public class MainApp extends javax.swing.JApplet
{
// DATAMEMBERS -----------------------------------
protected Thread gameThread = null;
private HashMap gameStates = new HashMap();
private GameState currentState = null;
public Canvas display_parent = null;
private boolean running = false;
// -----------------------------------------------
@Override
public void destroy()
{
remove(display_parent);
super.destroy();
System.out.println("Clear Up");
}
@Override
public void start()
{
gameThread = new Thread()
{
@Override
public void run()
{
running = true;
try
{
initGL();
}
catch(LWJGLException e)
{
e.printStackTrace();
}
System.out.println("Entering Gameloop");
gameLoop();
}
};
// If setDaemon(true) the JVM will exit as soon as the main reaches completion?
gameThread.setDaemon(true);
gameThread.start();
}
@Override
public void stop()
{
//
}
@Override
public void init()
{
setLayout(new BorderLayout());
try
{
display_parent = new Canvas()
{
@Override
public final void removeNotify()
{
destroyLWJGL();
super.removeNotify();
}
};
display_parent.setSize(getWidth(),getHeight());
add(display_parent);
display_parent.setFocusable(true);
display_parent.requestFocus();
setVisible(true);
}
catch(Exception e)
{
System.err.println(e);
throw new RuntimeException("Unable to create display");
}
}
private void destroyLWJGL()
{
stopApplet();
try
{
gameThread.join();
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
private void stopApplet()
{
running = false;
}
private void addState(GameState state)
{
if (currentState == null) currentState = state;
gameStates.put(state.GetName(), state);
}
private void initGL() throws LWJGLException
{
System.out.println("display_parent.isDisplayable() = " + display_parent.isDisplayable());
// setParent needed for embedding screen in canvas
Display.setParent(display_parent);
Display.setVSyncEnabled(false);
Display.create();
// add the game states that build up our game
addState(new GearsState());
try
{
// initialise all the game states we've just created. This allows
// them to load any resources they require
Iterator states = gameStates.values().iterator();
// loop through all the states that have been registered
// causing them to initialise
while (states.hasNext())
{
GameState state = (GameState) states.next();
state.StateInitialize();
}
}
catch (Exception e)
{
// if anything goes wrong, show an error message and then exit.
// This is a bit abrupt but for the sake of this tutorial its
// enough.
Sys.alert("Error", "Unable to initialise state: " + e.getMessage());
System.exit(0);
}
}
private void gameLoop()
{
currentState.Enter(this);
long oldTime = getTime();
System.out.println("Got Time : " + oldTime);
// while the game is running we loop round updating and rendering the current game state
while (running)
{
long dTime = (getTime() - oldTime);
oldTime = getTime();
Display.update();
if (Display.isCloseRequested())
{
running = false;
break;
}
// the window is in the foreground, so we should play
else if (Display.isActive())
{
int remainder = (int) (dTime % 10);
int step = (int) (dTime / 10);
for (int i=0;i<step;i++)
{
currentState.StateCycle(10);
}
if (remainder != 0)
{
currentState.StateCycle(remainder);
}
currentState.StatePaint();
Display.sync(60);
}
else
{
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{
//
}
currentState.StateCycle(dTime);
// only bother rendering if the window is visible or dirty
if (Display.isVisible() || Display.isDirty())
{
currentState.StatePaint();
Display.sync(60);
}
}
}
}
// Change the current state being rendered and updated.
// Note if no state with the specified name can be found no action is taken.
protected void changeToState(String name)
{
GameState newState = (GameState) gameStates.get(name);
if (newState == null)
{
return;
}
currentState.Leave();
currentState = newState;
currentState.Enter(this);
}
private long getTime()
{
return (Sys.getTime() * 1000) / Sys.getTimerResolution();
}
}
package testgame;
import java.awt.BorderLayout;
import java.awt.Canvas;
import com.threed.jpct.Camera;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.IRenderer;
import com.threed.jpct.Lights;
import com.threed.jpct.Matrix;
import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.World;
import java.awt.Color;
import testgame.modelloader.Loader3ds;
public class GearsState extends javax.swing.JPanel implements testgame.GameState//, MouseListener, MouseMotionListener, Runnable
{
// -----------------------------------------------
protected static final String NAME = "gears";
private jPCTGears m_pWindow = null;
private FrameBuffer m_Buffer = null;
private World m_World = null;
private Camera m_Camera = null;
private Canvas myCanvas = null;
private Object3D redGear, greenGear, blueGear, assemblyPivot;
private float gear_rotation = 0.02f;
// -----------------------------------------------
public String GetName()
{
return NAME;
}
public void StateInitialize()
{
//
}
public void Enter(MainApp window)
{
System.out.println("Entering Menu state");
m_pWindow = window;
// sign the applet up to receive mouse messages:
m_World = new World(); // create a new world
World.setDefaultThread(Thread.currentThread());
// create a new buffer to draw on:
m_Buffer = new FrameBuffer( m_pWindow.getWidth(), m_pWindow.getHeight(), FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY );
m_Buffer.disableRenderer( IRenderer.RENDERER_SOFTWARE );
myCanvas = m_Buffer.enableGLCanvasRenderer();
m_pWindow.add( myCanvas, BorderLayout.CENTER);
myCanvas.setVisible(true);
myCanvas.requestFocus();
Loader3ds temp = new Loader3ds();
// load some 3D objects and make sure they have the correct orientation:
redGear = temp.loadMeshFile("http://users.telenet.be/decoy/FacebookApp/models/RedGear.3ds");
redGear.rotateY( (float)Math.PI / 2.0f );
redGear.rotateMesh();
redGear.setRotationMatrix( new Matrix() );
redGear.setOrigin( new SimpleVector( 0, 0, 0 ) );
redGear.build();
greenGear = temp.loadMeshFile("http://users.telenet.be/decoy/FacebookApp/models/GreenGear.3ds");
greenGear.rotateY( (float)Math.PI / 2.0f );
greenGear.rotateZ( 0.35f );
greenGear.rotateMesh();
greenGear.setRotationMatrix( new Matrix() );
greenGear.setOrigin( new SimpleVector( -145.0f, 0, 0 ) );
greenGear.build();
blueGear = temp.loadMeshFile("http://users.telenet.be/decoy/FacebookApp/models/BlueGear.3ds");
blueGear.rotateY( (float)Math.PI / 2.0f );
//blueGear.rotateZ( 0.40f );
blueGear.rotateMesh();
blueGear.setRotationMatrix( new Matrix() );
blueGear.setOrigin( new SimpleVector( 0, -140.0f, 0 ) );
blueGear.build();
// Set up a pivot point for the entire gear assembly:
assemblyPivot = Object3D.createDummyObj();
assemblyPivot.setOrigin( new SimpleVector( 0, 0, 0 ) );
// Make the gears children to assemblyPivot.
// Translations and rotations to assemblyPivot
// will affect the entire gear assembly:
assemblyPivot.addChild(redGear);
assemblyPivot.addChild(greenGear);
assemblyPivot.addChild(blueGear);
// add the objects our world:
m_World.addObject(redGear);
m_World.addObject(greenGear);
m_World.addObject(blueGear);
redGear.build();
greenGear.build();
blueGear.build();
m_World.buildAllObjects();
lookAt(redGear); // make sure the camera is facing towards the object
letThereBeLight(); // create light sources for the scene
// receive mouse input from the main applet:
//addMouseListener(m_pWindow);
//addMouseMotionListener(m_pWindow);
// also get mouse input picked up by the canvas:
//myCanvas.addMouseListener(this);
//myCanvas.addMouseMotionListener(this);
//new Thread(this).start();
}
public void Leave()
{
m_pWindow = null;
m_World.dispose();
}
public void StatePaint()
{
// He enters and does StatePaint, but nothing happens.
m_Buffer.clear(new Color(100, 100, 100)); // erase the previous frame
// render the world onto the buffer:
m_World.renderScene(m_Buffer);
m_World.draw(m_Buffer);
m_Buffer.update();
m_Buffer.displayGLOnly();
myCanvas.repaint(); // Paint the canvas onto the applet (hardware mode)
System.out.println("Painting");
}
public void StateCycle(long dTime)
{
redGear.rotateAxis( redGear.getZAxis(), -gear_rotation );
greenGear.rotateAxis( greenGear.getZAxis(), 2.0f * gear_rotation );
blueGear.rotateAxis( blueGear.getZAxis(), 2.0f * gear_rotation );
}
// create light sources for the scene
private void letThereBeLight()
{
m_World.getLights().setOverbrightLighting (Lights.OVERBRIGHT_LIGHTING_DISABLED );
m_World.getLights().setRGBScale(Lights.RGB_SCALE_2X);
// Set the overall brightness of the world:
m_World.setAmbientLight(50, 50, 50);
// Create a main light-source:
m_World.addLight(new SimpleVector(50, -50, 300 ), 20, 20, 20);
}
// point the camera toward the given object
private void lookAt( Object3D obj )
{
m_Camera = m_World.getCamera(); // grab a handle to the camera
m_Camera.setPosition( 0, 0, 500 ); // set its *relative* position
m_Camera.lookAt( obj.getTransformedCenter() ); // look toward the object
}
}
Page created in 0.038 seconds with 12 queries.