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 - dunkedbiscuit

Pages: [1]
1
Support / Vector calculation
« on: January 27, 2012, 09:59:50 pm »
Hi

I have two SimpleVectors, with which I create a direction vector. I will use this direction vector draw a line between the two SimpleVectors. I want to draw multiple lines that are parallel to this line, and with a bit of distance between them. Does anyone know how I could do this?

Many thanks

2
Support / Isometric 3D in JPanel
« on: January 12, 2012, 01:03:43 am »
Hi

I've got (I think) isometric 3D working, which is pretty nice. However, when I try to put it into a JPanel I get an error like this:

Code: [Select]
Exception in thread "main" java.lang.NullPointerException
        at org.lwjgl.opengl.GL11.glMatrixMode(GL11.java:2052)
        at orthogonal_test.Main.loop(Main.java:56)
        at orthogonal_test.Main.main(Main.java:22)

And here's all the code:

Code: [Select]
package orthogonal_test;

import com.threed.jpct.*;
import org.lwjgl.opengl.GL11;

import javax.swing.*;
import java.awt.*;

/**
 * A simple HelloWorld using the OpenGL-renderer.
 * @author EgonOlsen
 *
 */
public class Main {

private World world;
private FrameBuffer buffer;
private Object3D box;
        private Camera cam;

public static void main(String[] args) throws Exception {
new Main().loop();
}

public Main() throws Exception {
world = new World();
world.setAmbientLight(0, 255, 0);

box = Primitives.getBox(1f, 1f);
box.build();
world.addObject(box);

                float dist = 30f;

                cam = world.getCamera();
                cam.setPosition( new SimpleVector( dist, dist, dist ) );
                cam.lookAt( new SimpleVector( 0, 0, 0 ) );
}

private void loop() throws Exception {
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);

                JFrame frame = new JFrame();
                Canvas canvas = buffer.enableGLCanvasRenderer();
                frame.add(canvas);
                frame.setVisible(true);
                frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
               
while ( frame.isVisible() ) {

buffer.clear(java.awt.Color.BLACK);
world.renderScene(buffer);
world.drawWireframe(buffer, java.awt.Color.YELLOW);
buffer.update();

                       
                        GL11.glMatrixMode(GL11.GL_PROJECTION);
                        GL11.glLoadIdentity();
                        float scalar = 50f;
                        //GL11.glOrtho(-13, 13, -1, 10, -30, 100);
                        GL11.glMatrixMode(GL11.GL_MODELVIEW);
                        GL11.glLoadIdentity();
                        GL11.glRotatef(35.264f, 1.0f, 0.0f, 0.0f);
                        GL11.glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
                        GL11.glScalef(1.0f, 1.0f, -1.0f);
                        GL11.glTranslatef( 0, 0, 0 );
                       
                        GL11.glBegin(GL11.GL_LINES);
                        GL11.glColor3f(1.0f, 0.0f, 0.0f);
                        GL11.glVertex3d(0, 0, 0);
                        GL11.glVertex3d(10, 0, 0);
                        GL11.glEnd();

                        GL11.glBegin(GL11.GL_LINES);
                        GL11.glColor3f(0.0f, 1.0f, 0.0f);
                        GL11.glVertex3d(0, 0, 0);
                        GL11.glVertex3d(0, 10, 0);
                        GL11.glEnd();

                        GL11.glBegin(GL11.GL_LINES);
                        GL11.glColor3f(0.0f, 0.0f, 1.0f);
                        GL11.glVertex3d(0, 0, 0);
                        GL11.glVertex3d(0, 0, -10);
                        GL11.glEnd();

buffer.displayGLOnly();
Thread.sleep(10);
}
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.dispose();
System.exit(0);
}
}

Any help / code snippets would be greatly appreciated.

3
Support / Orientating a car object to face a point
« on: November 23, 2011, 12:31:58 am »
Hello,

I would like a function which makes one object face another object, in that object A "points towards" object B. This would allow me to make some racing car pathfinding, since they need to move in the direction of successive point vectors to simulate driving along a road. I suppose I should be more precise with "pointing"; maybe the vertical axis of object A should be aligned with a vector travelling from the centre of object A to the centre of object B?

Many thanks!

4
Support / Accessing openGL object
« on: November 16, 2011, 09:24:53 pm »
Greetings!

I'm writing a level editor using Swing and JPCT. I make a JFrame, and then fill it with a JPanel. The JPanel is provided with a reference to the framebuffer so that it draws its contents whenever it's time to update:

Code: [Select]
@Override
    public void paintComponent( Graphics g )
    {
        this.fb.display( g );
    }

The framebuffer seems to be initialising an openGL context, since I start it like so:

Code: [Select]
canvas = fb.enableGLCanvasRenderer();
My question is: how do I then access the openGL object? Reason being, whenever I call openGL code in the IPostProcessor I have attached to the framebuffer, I get a null pointer error. Any thoughts?

Pages: [1]