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

Pages: [1] 2
Bugs / FrameBuffer.blit() - int[] version
« on: October 16, 2007, 04:20:47 am »
I highly doubt that the FrameBuffer.blit() - int[] contains bug. For the Texture version is ok, but if i use the int[] version, no matter how I do it, I always get java.lang.ArrayIndexOutOfBoundsException: 9 saying that no such item at index 9. But obviously I'm passing an image with a length of 307200. If you can help, the following program will reproduce the error.

Code: [Select]
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import com.threed.jpct.*;
import com.threed.jpct.util.*;

public class Blitting {
private int width = 640, height = 480, granularity = (1000 / 40), numOfUpdates;
private long now, justNow = System.currentTimeMillis(), start, offset;
private boolean running = true;

private World world;
private KeyMapper keyMapper;
private Object3D box;
private FrameBuffer buf;
private KeyState keyState;
private Image fpsImage = new BufferedImage(200, 100, BufferedImage.TYPE_INT_ARGB);

public Blitting() {
Config.glFullscreen = false;

world = new World();
keyMapper = new KeyMapper();
box = Primitives.getBox(1, 1);
buf = new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);

world.setAmbientLight(50, 50, 50);
box.translate(0, 0, 5);


while (running) {
now = System.currentTimeMillis();
offset = now - justNow;
numOfUpdates = 0;
if (offset >= granularity) {
justNow = now - (offset % granularity);
numOfUpdates = (int )(offset / granularity);

for (int i = 0; i < numOfUpdates; i++) {
update(System.currentTimeMillis() - start);

while ((keyState = keyMapper.poll()) != KeyState.NONE) {


protected void update(long elapsed) {
// TODO: update here

protected void poll(KeyState keyState) {
if (keyState.getKeyCode() == KeyEvent.VK_ESCAPE) {
running = false;
// TODO: process your other key ere

protected void blit(FrameBuffer buffer) {
// TODO: make your additional 2D drawing here
Graphics g = fpsImage.getGraphics();
g.setColor(new Color(0.9f, 0.9f, 0.9f, 0.9f));
g.fillRect(0, 0, 200, 100);
PixelGrabber grabber = new PixelGrabber(fpsImage, 0, 0, -1, -1, false);
try {
if (grabber.grabPixels()) {
int[] data = buffer.getPixels();
buffer.blit(data, 200, 100, 0, 0, 0, 0, 200, 100, FrameBuffer.TRANSPARENT_BLITTING);
} catch (Exception ex) {
throw new RuntimeException(ex);

public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
new Blitting();

Feedback / jPCT getting popular?
« on: July 08, 2007, 03:59:56 pm »
Today I saw a soar in the number of users online, the number actually doubled.

Most Online Today: 48. Most Online Ever: 48 (Today at 07:03:30 pm)

That's quite impressive, but Egon will get busy lol.

Support / (Urgent) Switching to 3DS for animation
« on: July 03, 2007, 01:18:00 pm »
For those of you who've done the animation using concatenated 3DS files, I have questions that need to be confirmed.

1. Each 3DS file is used for/as a keyframe right?

2. Once animation keyframe is added and built correctly, the interpolation is done automatically by jpct right?

3. For each of the keyframe 3ds file exported, do i have to set keyframes in 3ds max? Or all i need is just make a pose, export it, then it will be used as a keyframe?

I need urgent answers thanks.

Support / Need Another Help
« on: June 27, 2007, 02:52:27 pm »
I loaded my scene model from a 3DS file. For the sake of some special processing, i have to break a box such that its one side is detached but their geometric information intact. In other words, the box will turn into a mesh and a plane, for which, i will do the special processing.

The problem is when the plane is far away from the camera, it flickers terribly. I can guarantee that this problem only occurs if I break a plane from a box. I am not sure whether this problem exists if manually creating a plane though. Without further ado, i will give you the shots.

When the cam is near the plane, it is displayed correctly.

However, if the cam is far from the gradient plane, it is shown like this

Feedback / 3DS object naming convention
« on: June 27, 2007, 01:59:01 pm »
Every time i export my object/save my scene to .max or .3ds, if the name of the object is longer than 8 characters, it will be truncated. Anyone knows whether this limitation is reinforced by the tool (i.e. 3d max) or by the document standard?

Support / World.checkCameraCollisionSpherical()
« on: June 26, 2007, 02:50:14 pm »
Generally this method works without problem. But sometimes if my camera moves too fast, it will still bump out of walls/ceilings.

I'm sure this can be solved by changing some of the values in the parameters, so what to adjust?

FYI: Im using this version:

public boolean checkCameraCollisionSpherical(int mode, float radius, float moveSpeed, boolean slideMode)

Feedback / Noticed something interesting
« on: June 20, 2007, 11:33:21 am »
If your message contains words like exceptions (i.e. Array_Index_Out_Of_Bounds_Exception), they will be converted to "...ception". For security reason?

Support / How to use the int[] version of FrameBuffer.blit()
« on: June 20, 2007, 08:56:48 am »
I need a short example, because all my attempts end up with either an array out of bounds exception or a "Blitting region out of bounds" Error

Feedback / I experienced an extremely wierd network problem.
« on: June 15, 2007, 06:09:51 pm »
My server is on the public internet (so incoming connections should not be a problem.) I use UDP as my protocol. Two clients, one NATed behind a router, the other one doesn't use router but use ADSL dial up. Both clients have firewall turned off. When sending packets to the server, the strangest thing happened. The one NATed can send and receive from the server, but the one exposed to the public cannot.

You may think that it's the problem of firewall still. But let me tell you the much stranger thing. The second client, if wanted to connect, must enable "Internet Connection Sharing" from Control Panel, by that way it works. But as you know, I cannot call each and every one to manually open that because that will give a lot of troubles.

After searching through the notes all i can know is that when "Internet Connection Sharing" enabled, the IP of that computer turned from a end node to a router ip (i.e., by that way the server and this client can work.

Anyone have any experience about it? This problem never happens on Mac i think.

Or in general does anyone have any experience with UDP programming? I don't need the fancy p2p architecture, I can't even make the client-server architecture work. There are always more or less 1 type of computers that cannot interact with the server.

Support / Make a complete clone of an Object3D
« on: June 14, 2007, 08:39:02 pm »
Is it possible to clone an Object3D that is fully independent from the source object (don't share mesh etc.)? I want it cloned to the extent that it looks like loading the object twice from the model file?

Support / Help me inspect this model
« on: June 14, 2007, 03:09:26 pm »
I get a lot of warnings about this

"WARNING: Texture coordinates are not within the allowed range (0f-1f)"

Although the model was loaded correctly, and the textures are applied correctly as well. But i don't know what i have done wrong.

The workflow is as follows.

1. I model in 3Ds max. After that
2. I import it using MilkShape
3. I do my texturing and animating in milkshape
4. I export it to md2 using milkshape

I put my model for download at the following link. If you are helpful, inspect this model on what I have done wrong here.

The included file contains the exported .md2, exported .ms3d, the skin and the .qc file. All in one.

any idea what is causing this kind of error when loading md2 models? I get this error on every md2 model i created on my own. And recent incidents cause the program not running at all. This warning just keep printing on new lines forever.

Support / Using ITexture Effect
« on: June 11, 2007, 04:54:08 pm »
I am trying to get started with implementing the ITextureEffect interface. I did the following.

Code: [Select]
public void apply(int[] dest, int[] source) {
            Graphics g = image.getGraphics();
            g.setColor(new Color(0, 0, 0));
            g.fillRect(i, i, 100, 100);
            PixelGrabber grab = new PixelGrabber(image, x, y, w, h, false);
            System.out.println("number: " + i);
            try {
            } catch (Exception ex) {
            Object o = grab.getPixels();
            int[] array = (int[] )o;
            System.arraycopy(array, 0, dest, 0, Math.min(array.length, dest.length));

First of all, it somehow works and it is much better than replacing texture for each frame (actually much much better, at least the memory usage is about the same, unlike the latter which soars up 7MB per second >:() But I m sure i didn't get it right. What I tried to do, clearly is to fill a black rect on the 0,0 of the texture, but when i run the app, it is green instead. I am afraid i copied my int array wrongly?

Let's say i'm given a rectangular plane, with a known and fixed pair of width and height (e.g. 512 x 512 or 128 x 128 etc.) How could i position my camera so that it fits exactly into my screen. (exactly doesn't mean totally covered, because i know the screen won't be square! and also i do not want to change the fov or frustrum)

I know this question was asked before, but i think at that time this was not possible because the dimension of the object is unknown. Now i have the dimension of my plane defined and fixed, is it a possibility then?

Support / How to "Render to texture"
« on: June 11, 2007, 08:22:34 am »
By looking at the "window_blinds" video i think that is something i need to use in the near future. Any hint on how is it done? And is it possible that image created on the fly (e.g. ImageIcon painted by Graphics) can be used as textures to be drown in this manner, and in GLCanvas mode?

Pages: [1] 2