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

Pages: [1]
Support / how to synch wav audio and 3D animation?
« on: April 10, 2010, 02:20:54 pm »
Hi all.

This is really a 'any ideas?' sort of post .....

What's the best approach would be for synching an audio track to an animatio?  A use case here would be lip synching an avatar to dialog.

The audio is WAV format, being played with Paul's SoundSystemJPCT, and the game loop and timing is derived from from the Slick2D libraries, and uses LWJGL's Sys class to generate deltas as milliseconds. It all works OK, but various latencies and system loads mean the audio and animation can get out of synch very easily.

If it helps, I'm using Acid Pro 7 to sequence and create the audio.

My thoughts at the moment are to create time markers, then
  • at runtime calculate the number of bytes to be played until the next marker,
  • count bytes
  • call a listener method

or to do the audio as MIDI, which would entail
  • implement a custom MIDI sequencer
  • intercept 'Wire' protocol data
  • call listeners for 'note on' and 'note off' messages

Does anyone have an other ideas?

On a slightly different topic, anyone interested in using a Wiimote for game input? If there's interest I'll post my sample code and details of setting it all up.


Support / after object rotation what happens to object axis?
« on: March 29, 2010, 11:10:18 pm »
This has been driving me crazy all weekend and all day!!

If an object is rotated 90 degrees around it's X axis (so the object's Y axis is now aligned with the world's Z axis ), when it's translated along the Z axis it actually moves along the world's Y axis ..... is this correct?

And as a follow on, after rotating an object how can it be re-aligned with the world's axis so that the rotation is not undone?


Support / units in world space?
« on: March 25, 2010, 11:03:50 pm »
A few more questions for the day ....

  • What are the units in world space?
  • What are they related to?
  • Is there a notion of scale or size .... how many units would be considered 'close,' 'far,' 'small,' and so on?

I download and started using jPCT only yesterday morning, and this is my first foray into 3D, so please forgive all the beginners questions all in a row.



Support / transparency - wrong color
« on: March 25, 2010, 07:38:50 pm »
Unfortunately for me, my hardware doesn't support shadows, so I'm trying to implement pseudo-shadows. It's going OK, but the transparency has got my a bit stumped. My texture is an all black JPG (made in Photoshop) with the opacity set to 50%

When the pseudo shadow is rendered, it's white, not black. This is probably something to do with Lights, but I can't figure it out. Any help appreciated!!

A screen grab and code are below. BTW, the program itself is basically a hacked up version of HelloWorld from the Wiki, with the World ambient light is 255,255,255, the code below is almost 100% taken from a forum post (sorry, can't remember who posted it).


Code: [Select]
private Object3D makePseudoShadow(float transZ) {
Object3D obj = new Object3D( 2 );
        float offset = 50;  // width / height of the billboard (assumes it is square)
        obj.addTriangle( new SimpleVector( -offset, -offset, 0 ),
                           0, 0,
                           new SimpleVector( -offset, offset, 0 ), 0, 1,
                           new SimpleVector( offset, offset, 0 ), 1, 1,
                                                             "shadow" ) );
        obj.addTriangle( new SimpleVector( offset, offset, 0 ),
                           1, 1,
                           new SimpleVector( offset, -offset, 0 ), 1, 0,
                           new SimpleVector( -offset, -offset, 0 ), 0, 0,
                                                             "shadow" ) );




Support / object not translating as expected?
« on: March 25, 2010, 02:46:39 pm »
Hi all.

Completely new to 3D here .... I used to be a middleware product engineer (BEA was probably my best known employer), but am really rusty after a few years as a stay-at-home-dad! And this 3D geometry has really got me messed up!! Most likely it's because of the perspective projection .... I just can't get out of the 2D x,y type of thinking.

I'm trying to move a group of objects along the Z axis. The camera view should be fixed so that the objects appear to move under the camera and out of the view. The goal is to have a group of objects with co-ordinated movement, all time synched to midi events .... think of a row of pineapples zig-zagging over a terrain while they 'bob' to a beat.

This is my 1st hacked-up experiment at translating objects, just to get the basics of movement figured out. With 1 box, the box appeared to move along the Z axis as expected. Then I changed the code to an array of boxes, and now the boxes appear to zoom off into space, not moving along the Z axis at all.  Can anyone tell me why?


Code: [Select]
import com.threed.jpct.*;

public class MyTest {

private static float PI = (float) Math.PI;

private World world;
private FrameBuffer buffer;
private Object3D [] box = new Object3D[3];
private Object3D plane = null;

int counter = 0;
boolean right = true;

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

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

TextureManager.getInstance().addTexture("box", new Texture("box.jpg"));
TextureManager.getInstance().addTexture("ground", new Texture("cobblestones.jpg"));

for (int i=0;i<3;i++) {
box[i] = Primitives.getBox(13f, 2f);


plane = Primitives.getPlane(20, 30);
plane.rotateX(PI / 2f);



world.getCamera().setPosition(0, -150, -500);

private void loop() throws Exception {
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);

SimpleVector tm = null;

while (!org.lwjgl.opengl.Display.isCloseRequested()) {
for (int i = 0; i < 3; i++) {
tm = box[i].getTranslation();
if (tm.z < -200) {
tm.z = 200;
System.out.println("RESET ORIGIN");
} else {
tm.z -= 0.1f;

Pages: [1]