Main Menu
Menu

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.

Show posts Menu

Topics - raft

#81
Support / why 2 matrices ?
January 01, 2010, 09:16:32 PM
hi,

what's the purpose of having 2 matrices (rotation and translation) per Object3D ? AFAIK rotation matrix uses the upper left 3x3 part and translation matrix only uses the 3 entries in last row. seems as these can be merged into one, or not ?

why is it so ? for historical reasons or to maintain backwards compatibility or ?

thanks,
r a f t
#82
Support / vertex sharing and vertex indices
December 28, 2009, 07:13:16 PM
hi,

indeed i would keep this as a surprise ::) what i'm after is to make a skeletal animation implementation based on Ardor3d's Collada loader. i'm aiming it will be very lightweight and the runtime will not require Ardor3d.

i've constructed the mesh out of Ardor3d's mesh, assigned texture and coordinates but stuck at vertex indices. Ardor3d stores weights and joint indices in buffers where data is ordered according to mesh vertices. i need a way to match ardor3d vertices and jPCT vertices but there seems no way. futhermore Ardor3d also makes its own vertex sharing among polygons (not sure if engine optimizes it or Collada file is already optimized but that doesnt matter). so Object3D.disableVertexSharing doesnt help either.

only solution i can think of is, use same exact vertices and vertex sharing in jPCT to create an Object3D.

so is it possible to add a method or constructor to Object3D which takes vertice and texture coordinates as float arrays and an int array as index buffer ?

thanks,
r a f t

#83
Support / creating an object from FloatBuffer
December 27, 2009, 06:58:28 PM
hi,

i'm trying to reconstruct an Ardor3d object in jPCT. it internally stores mesh data (vertices and texture coords) as FloatBuffers. it then directly feeds GL with that float buffers:
GL11.glVertexPointer(3, 0, vertexBuffer);

and this is what i do in an Object3D constructor. read the data from vertex and textures buffers and create polygons out of them:

        FloatBufferData vertexCoords = mesh.getMeshData().getVertexCoords();
FloatBuffer vertexBuffer = mesh.getMeshData().getVertexBuffer();
vertexBuffer.rewind();

        FloatBufferData textureCoords = mesh.getMeshData().getTextureCoords().get(0);
FloatBuffer textureBuffer = textureCoords.getBuffer();
textureBuffer.rewind();

       
        final float[] vertexData = new float[3];
        final float[] textureData = new float[6];
       
for (int i = 0; i < vertexCoords.getTupleCount()/3; i++) {
System.out.println(i);

vertexBuffer.get(vertexData);
SimpleVector vert1 = new SimpleVector(vertexData);

vertexBuffer.get(vertexData);
SimpleVector vert2 = new SimpleVector(vertexData);
vertexBuffer.get(vertexData);

SimpleVector vert3 = new SimpleVector(vertexData);
textureBuffer.get(textureData);

addTriangle(vert1, textureData[0], textureData[1],
vert2, textureData[2], textureData[3],
vert3, textureData[4], textureData[5]);
}


something is definetly wrong as the constructed object is totally shapeless. any ideas ?

thanks,
r a f t
#84
Support / applying a 3rd party transform
December 26, 2009, 08:15:46 PM
hi,

i want to apply ardor3d's transform to a jPCT object. it has a 3x3 rotation matrix, a translation and a scale vector. ardor3d's coordinate system differ from jPCT (Y up i guess)

i'm trying to create two jPCT matrices, fill them in and set as rotation and translation matrices on Object3D.

* translation: straightforward: new Matrix().translate(x, y, z)
* rotation: AFAIK in jPCT rotation matrix, only upper left 3x3 part is used. i guess filling them in will be enough. but how to handle coordinate system difference ?
* scale vector: jPCT does not directly support scaling at different axis. but is it possible to achive the effect by playing with matrices ?

ardor3d transform also has a method which returns a 4x4 matrix in the following form. maybe using it with some modification on the result makes more sense ?


R R R Tx
R R R Ty
R R R Tz
0 0 0 1

thanks,
r a f t

#85
Support / create a pyramide pointing some location
December 26, 2009, 06:51:21 PM
hi,

i have two points: from and to. i want to create a pyramide so that, it's bottom center is placed at from and top corner is at to.

i'm using the following code but it doesnt correctly set direction. what's wrong here ?

public static Object3D createPyramide(SimpleVector from, SimpleVector to) {
SimpleVector direction = to.calcSub(from);
float length = direction.length();
Object3D p = Primitives.getPyramide(length);
// Pyramide is centered at origin, so move bottom to origin
p.translate(0, -length/2, 0);
p.setRotationMatrix(direction.getRotationMatrix());
p.translate(from);

return p;
}


thanks,
r a f t
#86
Support / demos are broken under 64 bit linux
December 07, 2009, 03:55:50 AM
adding 64 bit so's to jnlp desc may help
#87
Support / feature request: continuous LoD
November 13, 2009, 07:54:24 AM
hi all,

so jPCT has compiled objects, built in software mipmapping, multi-threading support and so on.. all so good :)

if i know Egon a bit, he is possibly already thinking of next big target, i suggest continuous LoD (level of detail) ;)

at the moment, as far as i know, there is practically no way to implement such a thing on top of jPCT. one can only add triangles to an object, move their vertices with an IVertexController but cannot remove.

using separate meshes for diffent LoD levels (as i did in karga) is an option, but it's not continous, does not look good because of the flop effect, is a real pain to configure and does not fit well for large scene objects.

just a suggestion..
vote for continous LoD ;)

r a f t
#88
Support / textures are gone after some time
October 20, 2009, 04:53:08 PM
hi,

i've adapted new version of jPCT to karga. (not online yet) and been playing with mipmapping and multi threading. multi threading definetely increases fps one multi core machines :) mipmapping works almost identical to previous external MipMapper and i guess performs slightly better. and of course much easier to use. great job :)

however after some time, some of my textures are gone. it's like we have added an object with a missing texture. below are two shots:



i cannot regularly reproduce it, but i can say it happens with multi cores, mipmapping enabled and MOSTLY while resizing the window (creating a new FrameBuffer). i guess it's a multi-threading issue

any ideas ?

r a f t
#89
Projects / SwingGL - Swing on top of OpenGL
March 31, 2009, 11:26:08 PM
hello,

for a few days i've been working on a crazy idea: making Swing work on top of OpenGL. which i think will be very useful if we make it run smoothly. so i've downloaded the jdk source and started digging into it

i first tried rendering, extended awt.Graphics2D and implemented some methods of it. luckily swing seems to use only a small portion of that methods and most can be easily implemented with OpenGL commands. there are some differences though. anyway, below screenshot will give an idea.. the main trick is making top level component believe that it's placed in a container and is visible. than it happily painted itself and its children on given GL based Graphics implementation

second i tried forwarding mouse events from LWJGL display to Swing. this one was hard. all major classes and methods in this process are package private. i still couldnt find a 'normal way' but made a nasty hack: set a private field of some class with reflection. this will almost certainly wont work on a non-Sun JVM and will possibly break in the future. but still proofs, with a proper interleave point making swing event system work offline is possible. i believe, with implementing a custom awt.Tookit and a dummy peer of some component, making event system work without reflection hack is possible. i just couldnt figure out how. maybe some Swing/AWT guru may help ?

later turn will come to keyboard events and keyboard focus. similarly i believe this would be possible with customizing toolkit..

i'm not sure i will have time and continue this project. the code is a mess now, i will publish it when i clean it up. maybe somene will continue it ? if anyone is interested, i will happily go into details..

here is a a web startable link. i tried it on Ubuntu Hardy and Win XP, it worked ok altough there are some small rendering differences. i especially wonder if it will work ok on MacOSX

below is a screenshot, SwingGL running on HelloWorld example (GL one)


cheers  ;D
r a f t

edit: SwingGL can be found at http://code.google.com/p/swing-gl/
#90
Support / calling LWJGL methods directly
March 30, 2009, 08:29:40 AM
hello,

what should i do to call opengl methods directly after jPCT has done ? for example the code below doesnt draw a line


while (loop) {
    // do jPCT things
    world.renderScene(buffer);
    world.draw(buffer);
    buffer.update();

    // do lwjgl things
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(10, 10);
    GL11.glVertex2f(50, 50);
    GL11.glEnd();

    buffer.displayGLOnly();
    Thread.sleep(10);
}
#91
Support / blitting text and images
March 18, 2008, 10:34:21 PM
here is two small and (hopefully) handy classes for blitting text and images. i'm posting them hoping they may be helpful

TexturePack packs several arbitrary sized images into a jPCT texture. it automatically layouts images and adjusts Texture size.

GLFont creates GL renderable (blittable) fonts out of awt Fonts.

in the below image, the bubble images are blitted with TexturePack and text is blitted with GLFont :)


note: these two classes use new FrameBuffer.blit(..) method in the upcoming 1.16 release

cheers,
r a f t
#92
Support / changing alpha when blitting a texture
March 15, 2008, 01:41:38 AM
hello,

first my aim: i want to port karga speech bubbles to GL renderer. they are currently blitted over awt.Graphics by using methods of graphics class. the bubbles has a popup effect, that is when they first appear they have an alpha value of 0 and alpha value increases in time giving a feeling of they appear from nothing.

how can i do that with GL renderer ? can i change alpha value of a texture when blitting it ? FrameBuffer.blit(..) method doesnt support it. Texture class itself also doesnt have any methods to change alpha.

Texture has an add method to mix two or more textures with some weight. adding bubble texure to an empty texture with an increasing weight may be an option, but that way colors will also change in time.

what else can i do ?

thanks,
r a f t
#93
Support / glMipmap
March 08, 2008, 02:34:01 PM
hello,

i've found that setting Config.glMipmap = true has a huge performance boost on my computer. it increases fps up to 3-4 times :o i find this really interesting and wonder if this is the case on all machines.

the performance boost is especially higher when there are many many polygons one after another in a line. for example, run the fps sample, turn back, stand next to elevator and look at the corner to the right, now you are looking diagonally to all level. on my machine fps is ~25 with mipmapping disabled and ~60 enabled  ::) i doubt this maybe because of my stupid video card uses painter's algorithm ?

r a f t
#94
Support / changing display mode
March 08, 2008, 01:19:10 AM
hello,

is it possible to change FrameBuffer's size without destroying it ? LWJGL allows changing display mode while running: Display.setDisplayMode(mode) jPCT continues to operate after change but it doesnt realize mode has changed. if we switch to a larger mode, jPCT renders only to a smaller area on screen, if we switch to a smaller mode, i guess it is over rendering.

is the only way to do this, disable GL renderer, dispose buffer and re-create with new size ? besides that popping efect, jPCT prints warnings below:
WARNING: ZBuffer depth of 24 not supported - trying something else now...!
WARNING: ZBuffer depth is now set to 16bpp!

if i dispose and re-create buffer again, it says:
WARNING: ZBuffer depth of 16 not supported - trying something else now...!
WARNING: ZBuffer depth is now set to 16bpp!

this goes on like this: 24 not supported, 16 not supported, 24 not supported...

and, just for wonder, the javadocs says first GL renderer should be enabled than sw will be disabled. is it really important ? cant we change the order ?

thanks
r a f t
#95
Support / FengGUI menu breaks jPCT textures
February 13, 2008, 04:28:45 PM
hello,

i'm toying with new version of FengGUI. but somehow it breaks jPCT textures now. some widgets render ok but when a try to add a menu bar it doesnt showup. furthermore if i add menubar before jPCT renders once, all textures are gone. the scene looks like all textures are dummy textures. no warning on console.

here is a shot:


very odd, any ideas ?
#96
Support / keyboard modifiers
February 13, 2008, 12:42:03 AM
i'm trying to map KeyState to awt.KeyEvent with the following code piece:

                int modifiers = 0;
                if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) ||  Keyboard.isKeyDown(Keyboard.KEY_RCONTROL))
                    modifiers |= KeyEvent.CTRL_DOWN_MASK;
                if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ||  Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
                    modifiers |= KeyEvent.SHIFT_DOWN_MASK;

                final KeyEvent keyEvent;
                if (state.getState()) // pressed
                    keyEvent = new KeyEvent(EVENT_SOURCE, KeyEvent.KEY_PRESSED, 0, modifiers, state.getKeyCode(), KeyEvent.CHAR_UNDEFINED);
                else keyEvent = new KeyEvent(EVENT_SOURCE, KeyEvent.KEY_RELEASED, 0, modifiers, state.getKeyCode(), KeyEvent.CHAR_UNDEFINED);


but unfortunately Keyboard.isKeyDown(left-right control) never returns true. pressing/releasing control key never generates an event either. any ideas why this may happen ?

this is a fedora 4 linux laptop, with only left control key. awt itself properly generates control key events

btw, it may be handy to include modifiers in KeyState class.

r a f t
#97
Support / wireframe mode per object/mesh
September 29, 2007, 07:52:24 PM
hello,

is it possible to add support for rendering only some objects in wireframe mode ? it may be great for special effects or for helpers like grids, trajectories etc. it may even be greater if such a mode supports optionally not rendering hidden vertices/edges (just like a regular render)

i guess this can be emulated by making all other objects invisible and rendering in wireframe mode to same framebuffer but this emulation ignores hidden status vertices/edges

thanks,
r a f t
#98
hello,

as Todd mentioned about unfulfilled promises to post code i felt guilty. here is the Animater class i use in karga to animate avatar movements. it coordinates animations deciding when to switch animation and during completion either rollback the animation or go till end. you cannot directly compile it but it will give an idea

say your avatar is walking forwards and you animate accordingly. then movement stopped but you're in the middle of walk animation, what will you do now ? leave the avatar as it is (one foot top) or play animation till end, or play it backwards ? what will you do when avatar decided to strafe left/right while he was walking forward ? how will you smootly switch between walk forward and strafe animation ? Animater class takes care of these. it does the low level dirty job..

the typical usage is as follows: this code piece is called every frame. seconds is passed seconds since last frame

// clamping mode is important here, as we dont want roundings at ends
Avatar.getAnimationSequence().setClampingMode(Animation.USE_CLAMPING);
if (moving) {
    Animater.Frame frame = animater.getNext(step, seconds);
    animate(frame.index, getSequenceNumber(frame.sequence));
} else {
    if (animater.hasNext()) {
        Animater.Frame frame = animater.getNext(seconds);
        animate(frame.index, getSequenceNumber(frame.sequence));
    }
}

Util3D.Step is an enum defining what step avatar makes during movement, one of:

NONE, FORWARD, BACKWARD,  JUMP_UP, JUMP_FALL, FALL_DOWN,
LEFT, RIGHT, // strafe
TURN_LEFT, TURN_RIGHT, // turn around
FAST_FORWARD; // run


AvatarInfo.Animation stores information about animation sequences of avatar. the only relevant part used here is period, how long the sequence lasts. the enum Interval is the segments of animation sequences. as forum settings doesnt allow to post such a long piece of code i placed it in karga site  ::) here is the Animater class

hope this helps  ;)
r a f t

#99
Support / scaling an object with animation
May 27, 2007, 04:49:54 PM
hello,

is it possible to scale an animation ? simply scaling an Object3D doesnt work because the Animation is not scaled. maybe Object3D.animate(..) methods may use scale information when animating ?

thx
#100
Projects / jKilavuz: a guide in the polygon soup
May 25, 2007, 10:36:15 AM
welcome jKilavuz, a sister project of karga ;D

for a couple of months i've been working on a pathfinding system for karga. i've read a lot, thought a lot and concluded in pathfinding is not that hard, hard part is collecting necessary data. i've barrowed the idea at the great article at gamasutra. now it is already shaped and i'm happy with the results. here is how it works in short:

starting a from a set of points on ground, floodfills to 4 cardinal directions until all map is explored. this is our massive raw grid data consists of cells. it's a kind of 2d grid in 3d space which can take us up or down slopes, across bridges and over and under overpasses.  we than analyze cells and collide them into freely traversable rectangular regions called sectors and portals between sectors. all the process is automized and quite time consuming. we have the option to intercept with sector creation and to create custom portals for elevators teleporters etc.

here is a demo for our old friend quake level of fps example. move camera freely with arrow keys, a, z, s, x. click anywhere around and the avatar will come. f to follow avatar and toggle free camera again. almost all places are reachable. although unlikely if stuck r to reset to start position. v to visualize path finding sectors. dont miss the elevator  ;)

it takes about 15 minutes to generate pathfind data on my 1.86 ghz notebook. there are a total of 384 sectors and 1348 portals. although the grid takes 5-6mb the runtime pathfinding information is only ~207k uncompressed

here are some key features and design goals:
* the pathfind algorithm is A*. it's a generic one not limited to kilavuz sectors
* minimum JRE version is 1.5
* kilavuz is targeted to java users not especially jPCT users. flood filling is plugable. there is a default implementation which uses jPCT's collision detection capabilities but it is not mandatory. the runtime only requires SimpleVector and Matrix classes to work. so any non-jPCT user can use kilavuz by simply transforming coordinates into his space
* all calculations are done in grid space. when executing path, coordinates are transformed back into world space. elevations are calculated by interpolation. the demo doesnt use any kind of collision detection but avatar nicely fits on ground almost all times
* users may intercept both with sector/portal creation and path exectution. the runtime supllies a small and limited set of classes to iterate over paths (either linear or curved) over time but anyone can use his own path execution system. the methods for converting between grid and world space provided. for special portals (like the elevator), the runtime uses factory interfaces to create relevant path segments. for example, this way one can plug actions like going somehere and calling the elevator by pressing a button

here is a shot from demo. top view with sectors visualized


and this is how our grid looks like. notice how the found path goes upstairs passing over itself. you can see the cells (the small circles), transitions between cells and sectors and portals here


although not certain, kilavuz will most likely be a commercial api with a limited freeware version. sorry i'm really broke nowadays :/

i will soon make a site for it when polished and documented the api

just for reference, kilavuz means guide in turkish

cheers
r a f t

edit: added a link to home site and moved the demo link to home too