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

--Tim.

2
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?

TIA,
Tim.

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

TIA.

--Tim.

4
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).

--Tim.




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,
                           TextureManager.getInstance().getTextureID(
                                                             "shadow" ) );
        obj.addTriangle( new SimpleVector( offset, offset, 0 ),
                           1, 1,
                           new SimpleVector( offset, -offset, 0 ), 1, 0,
                           new SimpleVector( -offset, -offset, 0 ), 0, 0,
                           TextureManager.getInstance().getTextureID(
                                                             "shadow" ) );

obj.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
obj.setTransparency(100);
obj.setLighting(Object3D.LIGHTING_NO_LIGHTS);
obj.setAdditionalColor(java.awt.Color.BLACK);

        obj.build();

obj.rotateX(-80);
obj.translate(0,0,transZ);

return(obj);
}

5
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?

Thanks.
--Tim.

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);
box[i].setTexture("box");
box[i].setEnvmapped(Object3D.ENVMAP_ENABLED);
box[i].build();
world.addObject(box[i]);
box[i].setOrigin(SimpleVector.ORIGIN);
}
box[0].translate(-40,-1,0);
box[1].translate(0,-1,0);
box[2].translate(40,-1,0);

box[0].setAdditionalColor(java.awt.Color.RED);
box[1].setAdditionalColor(java.awt.Color.GREEN);
box[2].setAdditionalColor(java.awt.Color.BLUE);

plane = Primitives.getPlane(20, 30);
plane.rotateX(PI / 2f);
plane.setSpecularLighting(true);
plane.setTexture("ground");


world.addObject(plane);

plane.build();


plane.compileAndStrip();

world.getCamera().setPosition(0, -150, -500);
world.getCamera().lookAt(box[1].getTransformedCenter());
}

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

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;
box[i].translate(tm);
box[i].setOrigin(SimpleVector.ORIGIN);
System.out.println("RESET ORIGIN");
} else {
tm.z -= 0.1f;
box[i].translate(tm);
}
}
buffer.clear(java.awt.Color.BLUE);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
Thread.sleep(300);
}
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.dispose();
System.exit(0);
}
}


Pages: [1]