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

Pages: 1 ... 5 6 [7] 8
Support / blitting text and images
« on: 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

r a f t

Support / changing alpha when blitting a texture
« on: March 15, 2008, 01:41:38 am »

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 ?

r a f t

Support / glMipmap
« on: March 08, 2008, 02:34:01 pm »

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

Support / changing display mode
« on: March 08, 2008, 01:19:10 am »

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 ?

r a f t

Support / FengGUI menu breaks jPCT textures
« on: February 13, 2008, 04:28:45 pm »

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 ?

Support / keyboard modifiers
« on: February 13, 2008, 12:42:03 am »
i'm trying to map KeyState to awt.KeyEvent with the following code piece:

Code: [Select]
                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

Support / wireframe mode per object/mesh
« on: September 29, 2007, 07:52:24 pm »

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

r a f t


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

Code: [Select]
// clamping mode is important here, as we dont want roundings at ends
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:

Code: [Select]
LEFT, RIGHT, // strafe
TURN_LEFT, TURN_RIGHT, // turn around

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

Support / scaling an object with animation
« on: May 27, 2007, 04:49:54 pm »

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 ?


Projects / jKilavuz: a guide in the polygon soup
« on: 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

r a f t

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

Support / strange ray casting behaviour
« on: May 05, 2007, 04:18:59 pm »

i'm experiencing some problems with ray casting:

Code: [Select]
        Config.collideSectorOffset = Object3D.COLLISION_NONE;
        Config.collideOffset = Float.MAX_VALUE;

        int objectId = world.checkCollision(topCenter, DOWN, Float.MAX_VALUE);
        if (objectId == Object3D.NO_OBJECT) {
            return NO_GROUND;
        Object3D object = world.getObject(objectId);
        float distance = object.calcMinDistance(topCenter, DOWN, Float.MAX_VALUE);
        assert (distance != Object3D.COLLISION_NONE);

surprisingly the assertion above fails  ??? is it a configuration issue or ? i suspected a rounding error so i tried second part Object3D.calcMinDistance from a little bit higher location but the result is the same  :-\

DOWN is a normalized vector pointing downwards: new SimpleVector(0, 1, 0);

any ideas ?

r a f t

Support / what happened to paradroidz ?
« on: April 06, 2007, 03:00:21 pm »
last thing i remember was Egon said there was some legal issues and game will not be available for a while. now it completely disappeared :o no forum topic, no entry in projects page  ??? i felt sad about it :(

i wondered what that legal issue was resulting in such a demolish  :-\

Support / does jPCT use BSP trees ?
« on: March 24, 2007, 03:51:53 am »
as BSP trees are commonly used for hidden surface removing algorithms i wonder if jPCT use them behind the scenes ? if so is it possible to retrieve that information ?

r a f t

Support / 3ds max tips
« on: August 17, 2006, 02:12:22 pm »
the problem below took me days to resolve, so i thought it may help others if it's documented in a thread.

-- o --

sometimes models arent loaded with 3dsLoader as they look in 3d max. i mean somehow their placement and rotation change when loaded into jPCT.

i first encountered this problem with the commercial village set i use in karga. the producer suggested to use XRef and it effectively solved the problem. this is done by either adding an XRef modifier to each object's stack or by using reset x-form utility in utilities panel (which indeed does the same for all selected objects)

however on some situations XRef doesnt solve the problem. the objects are still misplaced when loaded into jPCT. there seems to be a hidden translation or whatever which XRef doesnt clear, and which in turn confuses the jPCT's loader. here is the solution, it took me days to find it:

create a new object (say a box) and align its center by align tool with our object in question. convert the new object to editable mesh (or poly) and attach our object to it. now go to element sub object level, select new object and delete it. your object has now a brand new transform.

this is the document i found this workaround in:

note: maybe you may wish to add to this thread in time to build a list of helpful 3d max tips. Egon, maybe you may wish to open a new forum category for this purpose

hope this helps
Code: [Select]
r a f t

Support / hang during texture load
« on: May 17, 2006, 12:05:15 am »

sometimes program hangs during initial texture loads. this typically happens after running the program a couple of times. i dont think this has anything to do with jpct but with java's image loading mechanism or whatever :?:

by hang i mean a proper hang. it stops responding forever. this is particularly strange since i load such stuff in a background thread, not in awt thread.

furthermore if i try to kill program with control-c it continues at the point it hanged and then terminates.

i suspected a deadlock in awt thread so runned the program with debug option. here comes the most strange part: after a hang, program continues to run if i attach it with debugger :?: anyway, i use this as a local workaround and always start the program with debug option  :wink:

any ideas why this happens and how to solve it
Code: [Select]
r a f t

Pages: 1 ... 5 6 [7] 8