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

Pages: [1] 2 3 4
1
Support / Countering visual y-offset from depth
« on: April 11, 2013, 04:53:59 pm »
I recall seeing a thread about this, but wasn't able to find it (and I apologize for using the wrong terminology).  I am looking for a way to counter the effect of the 2D y-position of an object changing the further away it is from the camera.  I drew up a simple diagram of where I'll be using this (this is an overhead view):



Note that this represents just one screen -- the full world will be longer, and the camera will move horizontally to follow the character.  The idea is to have a simulated 2D world with 3D characters and 2D billboarded objects in the background.  The visual y-offset with this setup causes the trees to float up off the ground the further away they are (which would be the desired behavior in a fully 3D world but not in a 2D world).  A couple of ways I could counter this:

- Apply a formula to modify an object's y position based on it's distance (I'm not sure what formula to use)

- Use reproject2D3DWS to calculate the furthest two corners of a "ground polygon", and snap the background objects to it

Any thoughts on the best route to go?

2
Feedback / Using jPCT-AE in my app training course
« on: October 11, 2012, 05:07:18 am »
Hello, everyone, I haven't posted on here in a while (been busy with my other projects).  My latest project is to create a training course on how to write Android apps. It will be a complete training course with a course book, exercises, quizzes, test booklet, and answer key, as well as a companion website and support forum. It will be geared toward anyone who is interested in learning how to write professional Android apps, whether they have prior programming experience or not.

Each new topic will first be related to real-world concepts, so they can be understood more easily. Then those concepts will be applied to create a practical, interesting demo app for each subject. By the end of the course, the student will have created several of these demo apps, that they can show off to their friends or potential employers.

What I want to do for the final chapter of the course book (the ultimate goal of the course, if you will), is to teach the student how to write a simple 3D demo game, using jPCT-AE.  With that in mind, does anyone have any suggestions on what that demo game should be, and any suggestions of important points to make for the student in this chapter?

I've also set up a kickstarter campaign to help fund the project, to cover the printing costs and compensate for the time I put into it.  Feel free to comment on there as well, if you have useful suggestions for the project.

(BTW, I don't mean this post to be a kickstarter ad -- I'll remove the above link if it is breaking the forum rules)

3
Projects / OpenAL for Android
« on: August 10, 2011, 02:06:31 am »
I am still working out the kinks with the Android version of my 3D Sound System.  In the mean time, I thought some folks might find this part of the library useful by itself.  This is my port of native OpenAL to Android with a simple Java interface.  It will basically allow you to add OpenAL to your projects without having to play around with c/c++ and JNI.  If optimization is a big concern for your project but you still need 3D sound, removing the overhead of SoundSystem and accessing OpenAL directly could be a good option.  This library should work on all Android versions back to 1.5 (although I've only actually tested it on my own phone).

The Java interface for this port is probably closer to JOAL rather than LWJGL's interface.  There are a few differences from JOAL, however (mainly in the methods that take array/ buffer parameters, the way the context is created and destroyed, and the lack of a direct interface to ALC with device and context objects Java-side).  That being said, code written for JOAL or LWJGL is pretty simple to make work with my interface (it's all OpenAL when you get right down to the nuts and bolts, after all).

Everything is accessed statically through the class paulscode.android.sound.ALAN.  Before creating any sources and what-not, first connect with the Android audio device and create an AL context by calling:
Code: [Select]
ALAN.create();
From there, you can access whatever AL functions you need through ALAN.  For example:
Code: [Select]
        int[] ALBufferIDs = new int[BUFFER_COUNT];
        int[] source = new int[1];
        int[] state = new int[1];
        ALAN.alGenSources( 1, source );
        ALAN.alGenBuffers( BUFFER_COUNT, ALBufferIDs );
        ALAN.alBufferData( ALBufferIDs[i], format, buffer, buffer.length, rate );
        ALAN.alSourceQueueBuffers( source[0], c, ALBufferIDs );
        ALAN.alSourceQueueBuffers( source[0], c, ALBufferIDs );
        ALAN.alSourcePlay( source[0] );
        ALAN.alGetSourcei( source[0], ALAN.AL_SOURCE_STATE, state );
        if( state[0] != ALAN.AL_PLAYING )
            whatever();

And when you're finished, destroy the AL context and disconnect from the Android audio device by calling:
Code: [Select]
ALAN.destroy();
In case you haven't caught on, ALAN isn't a personal name like some AI alias - it's just an abbreviated form of  "OpenAL for Android" (fewer keystrokes than OpenALAndroid).  On a humorous note, I was actually forced to rename a hundred or so references to my project's original title "Android OpenAL", which I was horrified to realize became "ANAL" when abbreviated.  THAT was a real pain in the butt ;D

Anyway, here is a very basic app to demonstrate streaming an .ogg file:
ALAN Demo    (source code)

I normally drop in the source code to my projects, but you should be able to just unzip the above APK file, grab the contents of the "lib" folder, and paste them into your own project's "lib" folder.  If you prefer to compile the source code yourself, you can unzip the source code archive above and either run the following commands from the terminal/command prompt:
Code: [Select]
ndk-build
ant debug
ant install
Or you can "create a new project from source" in Eclipse (requires the Android SDK and NDK to be installed, as well as the ADT plug-in and Sequoyah Android Native Code plugin from the update site plug-ins).  Once you've created the Eclipse project, just right-click on it in the left panel and navigate to "Android Tools->Add Native Support".

The above demo utilizes the Tremolo library for decoding the .ogg file.  It is a popular library for use on Android because it is extra light-weight and optimized for the ARM architecture, but there are plenty of other decoder libraries out there you could use if you have problems with that one.  In theory, you could even use any of a number of pure-Java audio decoders as well, including the ones included with my SoundSystem library.  I do not recommend copying the code from this demo - it very inefficient and meant only as a proof of concept.

One final note: OpenAL Android is licensed by the LGPL (since that is what OpenAL and Tremolo are licensed under).  While I normally shy away from this license, it actually meshes really well with Android apps, because the end user can use any of a number of free backup programs (such as ASTRO) to create a backup APK of your app.  From there, he can plug in a different version of the library into the APK, and simply reinstall it.  All you have to do is mention somewhere in your documentation where they can acquire the sourcecode for OpenAL Android (feel free to mention my website if you don't want to host the files yourself). Please let me know if you encounter any bugs (logcat output is always helpful).

4
Support / Comic book appearance
« on: January 04, 2011, 05:15:18 pm »
I am thinking about making some children's educational games, and one effect I'd like to achieve is for each frame to look like a 2D drawing in a comic or colloring book.  I've been playing around with various settings and textures, and so far I get the closest to my goal if I use only ambient lighting and texture a black "outline" on the edge of each component (for example around the waist and ankles of a pair of pants).  The main problem is somehow drawing an outline around the visible edges of each object.  I'm thinking I could duplicate each object and texture one completely black and scale it up a tad, then use a pseudo-billboarding effect to always have it behind to other object.  I thought I'd see if anyone here has some additional ideas I could try to improve the effect I'm after.

5
Projects / Archar
« on: October 22, 2010, 02:55:05 am »
Background

I have been playing around with an AI concept for years (one of several "cool idea" projects I'm working on).  It is a text-based contextual learning engine which is capable of picking up grammatical sentence structures very quickly, and using that information to generate random grammatically-correct sentences in response to input sentences.  The context of the sentences it produces is randomly related to the words contained in the input sentence (so if a user types a sentence about cats, the engine might respond with a sentence about cats, animals, fur, etc).  I've decided the engine has reached a high enough level of stability that I can start using it in projects.


Project Concept

Archar (an acronym for Artificial Character) will be my first project utilizing the engine.  It will be an applet consisting of a 3D character which you can talk to through the microphone and it will talk back to you through the speakers.  I will accomplish this through speech recognition to convert what the user says into text, and then speech synthesis to convert the engine's output into audio.  This audio will need to be synced with the facial animations of the head.  jPCT is perfect for the 3D applet piece, and I've written some synchronization methods into my sound system which should be useful for this project as well.

6
Support / Camera space to world space?
« on: September 29, 2010, 03:45:41 am »
What is the correct method for converting from camera space into world space?  I thought it was this:
Code: [Select]
vector.matMul( camera.getBack().invert3x3() );
vector.add( camera.getPosition() );

I am getting an unexpected result with this.  In the case where I set the camera position and orientation as:
Code: [Select]
        camera.setPosition( 0, 50, 0 );
        camera.setOrientation( new SimpleVector( 0, -1, 0 ), new SimpleVector( 0, 0, -1 ) );

Then try to convert the following vector:
Code: [Select]
SimpleVector vector = new SimpleVector( 50, 0, 0 );
vector.matMul( camera.getBack().invert3x3() );
vector.add( camera.getPosition() );

I get a resulting vector of (-50.0, 50.0, 0.0).  But shouldn't it be (50.0, 50.0, 0.0)?  Am I incorrect about what the result should be, or am I doing the conversion incorrectly?

To visualize the problem, this is the result I am expecting to see:

7
Currently, there is no method for creating an empty/black texture of a specified size with alpha, something like this:

Code: [Select]
myTexture = new Texture( width, height, true );
This would be useful for cases where a texture's contents are generated entirely through an ITextureEffect implementation where alpha is used (i.e. if there is no "initial" frame to use when instantiating the Texture).  This is not high-priority for me, though.  I came up with a workaround that seems to function the same way:

Code: [Select]
BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_4BYTE_ABGR );
myTexture = new Texture( image, true );

8
Support / Changing u/v coordinates on the fly
« on: September 12, 2010, 05:37:01 am »
I have several quads for which I want to change their textures' u/v coordinates periodically.  What is the proper way to do this in jPCT-AE?

Currently, I am calling build( false ) on the Object3D, then to change the u/v coordinates:

Code: [Select]
                tex1 = new TextureInfo(
                          TextureManager.getInstance().getTextureID( "Front" ),
                          quadUVs.u1, quadUVs.v1, quadUVs.u2, quadUVs.v2,
                          quadUVs.u3, quadUVs.v3 );
                tex2 = new TextureInfo(
                          TextureManager.getInstance().getTextureID( "Front" ),
                          quadUVs.u3, quadUVs.v3, quadUVs.u4, quadUVs.v4,
                          quadUVs.u1, quadUVs.v1 );
                gifBox.getPolygonManager().setPolygonTexture( polyIdOffset,
                                                              tex1 );
                gifBox.getPolygonManager().setPolygonTexture( polyIdOffset + 1,
                                                              tex2 );
quadUVs is just a simple class that holds 8 floats to represent the u/v coordinates of the four corners of a rectangle.  These values are changed periodically.  I pulled the code out of a previous normal jPCT project, so I'm pretty sure I'm using the correct u/v values.  However, if there is nothing obvious you can think of that I need to do to make u/v changes work, I'll try and create a simpler test-case to look at.

9
Support / Anyone use Netbeans?
« on: September 12, 2010, 01:51:09 am »
For no other reason than I really hate to learn a new IDE, I've been using Netbeans to develop for Android (using the NBAndroid plug-in) rather than Eclipse.  There was one issue with audio that I noticed, caused by Netbeans zipping the contents of the res/raw directory rather than leaving them uncompressed.  This was easily fixed by adding a few lines to the build.xml file.  I have compiled a number of simple non jPCT-AE programs and successfully run them on my emulator's Droid X AVD (Android 2.1 update 1, WVGA8554, 16GB virtual sdcard).

Unfortunately, I am not having any luck with jPCT-AE.  I've tried both the Hello World from the wiki as well as the Demo.  When I run either of them, with or without the build.xml changes, the emulator's screen goes black for a split second then returns to the home screen.  Anyone have some suggestions for me to try? (I may have to give in and switch to Eclipse..).  Is there a log file for the emulator that gets generated or some other way to see if errors occurred (nothing appears in the Netbeans output window, because the program builds successfully and gets sent to the emulator without problems)

10
Feedback / Writing my own software audio mixer
« on: August 23, 2010, 03:14:44 am »
Hello, all.  My next big project is to write my own software audio mixer, so that I can play multiple audio inputs on a single output line.  This will not only solve the latency and mixer-compatibility issues with Java Sound, but I could potentially use the same algorithms to write a sound library for the Android.  I thought I'd post here in case anyone has some knowledge about these topics.

I would need to be able to do the following things with PCM audio data:

1) Mixing multiple inputs into one 2-channel (left/right) output, maintaining synchronization between the channels
2) Converting between (or mixing directly) various audio formats (different sample rates/sample sizes/channels)
3) Changing frequency (pitch)
4) Changing gain (volume) independently on each channel

I want to be able to do this in pure Java, completely programatically (i.e. no linking with 3rd-party libraries except to initially acquire the PCM data and then to actually play the output).  I'm looking for all tips, source code, tutorials, that kind of thing.  I am proficient in several programming languages, so references don't necessarily have to be written specifically for Java.  I've googled up a few promising things already, but the more information I can get, the easier my job will be.

11
Feedback / Quantum Land
« on: January 27, 2010, 10:04:39 pm »
Anyone here interested in quantum physics?  I'm considering making a game called "Quantum Land", in which you control a qubit in a world at the quantum level.  It would be more comedy in nature than seriously educational, while still dealing with some of the interesting oddities of quantum physics.

Thoughts?

12
Feedback / New motherboard and processor
« on: January 16, 2010, 11:20:49 pm »
I just finished installing a new intel motherboard and quad core processor.  jPCT is running better than ever - my old machine was a bit of a bottleneck.
faster processor + more of RAM + sweet graphics card = more awesomeness   ;D

13
Projects / Simple Animated Texture Interface
« on: September 08, 2009, 10:43:14 pm »
-- This slot is reserved for the most recent working releases --




Downloads:

Texture Animator  Version date:  October 22, 2010
This includes the I2DAnimationController interface and the TextureAnimator helper class.

Example Implementations of I2DAnimationController:

GIF Controller  Version date:  September 12, 2009
Implementation of I2DAnimationController for playing GIF animations.

JMF Video Controller  Version date:  September 12, 2009
Implementation of I2DAnimationController for playing AVI, MOV, and MPEG videos via JMF.  Note: the pure-java version of JMF (which doesn't require user to install a native library) is compatible with only a very limited number of codecs (MOV H.263 encoding is about the best it can handle).

Manual 2D Manipulation Controller  Version date:  September 12, 2009
Implementation of I2DAnimationController to demonstrate manual 2D manipulation.  This example simulates the classic "mystify" screensaver.


Demos:

Animation Cube  (download the Source Code)
Demonstrates all three of the above I2DAnimationController example implementations - GIF, JMF video, and manual 2D.


Documentation:

Currently having a problem generating the JavaDoc for TextureAnimator.  Will post after I resolve the issue.

14
Support / ITextureEffect Sync Problem
« on: September 05, 2009, 03:24:22 am »
I have been playing around with ITextureEffect, and I keep coming across the same problem.  It seems that at random points in time, the texture effect is sometimes not fully drawn before a frame gets rendered.  The result is light-blue shapes randomly showing up for a split second on the texture.  It seems to happen in both hardware and software rendering modes, and it occurs more frequently during heavy processing.

I assume the problem is that I am somehow not synchronizing things correctly, but I can't figure out what I need to change.  I created a simple test case to demonstrate.  Because this applet is so simple (i.e. no heavy processing going on), the problem doesn't show up very frequently (especially if you have a fast computer), but you can simulate the problem by dragging the browser window around, which seems to create a strain on the rendering, resulting in the behavior described above.  I made it so you can switch between software and hardware rendering modes by right-clicking on the applet.

Test Case

Here is the source code for the above test case.  Hopefully you can see what I am doing wrong:
Code: [Select]
import java.awt.Canvas;
import java.awt.Color;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.awt.image.PixelGrabber;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

// From the jPCT API (http://www.jpct.net):
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.IRenderer;
import com.threed.jpct.ITextureEffect;
import com.threed.jpct.Lights;
import com.threed.jpct.Matrix;
import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;

/**  IMPORT THIS FOR AN APPLET: **/
/**/
import javax.swing.JApplet;
/**/
/*********************************/

/**  IMPORT THESE FOR AN APPLICATION: **/
/*
 import java.awt.Insets;
 import javax.swing.JFrame;
*/
/***************************************/

/**  EXTEND JApplet FOR AN APPLET **/
/**  EXTEND JFrame FOR AN APPLICATION **/
public class ITextureEffectSyncProblem extends /*JFrame*/ /**/JApplet/**/
                         implements MouseListener, MouseMotionListener, Runnable
{
    // JApplet/JFrame dimensions:
    private int width = 640;
    private int height = 480;
    // top and left insets (both zero for an applet)
    private int titleBarHeight = 0;
    private int leftBorderWidth = 0;

    private Canvas myCanvas = null;

    private final Object jPCTSync = new Object();
    private FrameBuffer buffer = null;
    private World world = null;
    private Object3D object = null;
    private Texture texture = null;
    private Image blankImage = null;

    private boolean alive = true;
    private boolean initialized = false;


/**  USE THIS FOR AN APPLICATION  **/
/*
    public static void main( String[] args )
    {
        new ITextureEffectSyncProblem();
    }

    public ITextureEffectSyncProblem()
    {
        setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        setTitle( "ITextureEffect Sync Problem" );
        pack();
        Insets insets = getInsets();
        titleBarHeight = insets.top - 1;
        leftBorderWidth = insets.left - 1;
        setSize( width + leftBorderWidth + insets.right - 1,
                 height + titleBarHeight + insets.bottom - 1 );
        setResizable( false );
        setLocationRelativeTo( null );
        setVisible( true );

        init();
    }
*/
/***********************************/

/**  USE Override FOR AN APPLET  **/
/**/
    @Override
/**/
/***********************************/
/**
 * Shuts down the main game-loop thread, and cleans up.
 */
    public void destroy()
    {
    alive = false;
    }


/**  USE Override FOR AN APPLET  **/
/**/
    @Override
/**/
/***********************************/
/**
 * Initializes all components of the program.
 */
    public void init()
    {
        synchronized( jPCTSync )
        {
            // sign the applet up to receive mouse messages:
            world = new World();  // create a new world

            World.setDefaultThread( Thread.currentThread() );

            // create a new buffer to draw on:
            buffer = new FrameBuffer( width, height, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY );
            buffer.disableRenderer( IRenderer.RENDERER_SOFTWARE );

            myCanvas = buffer.enableGLCanvasRenderer();

            add( myCanvas, BorderLayout.CENTER);
            myCanvas.setVisible( true );

            texture = new Texture( 512, 512, Color.BLACK );
            TextureManager.getInstance().addTexture( "TextureEffect", texture );
            texture.setEffect( new BlankTextureEffect() );
            blankImage = new BufferedImage( 512, 512,
                                            BufferedImage.TYPE_4BYTE_ABGR );
            Graphics g = blankImage.getGraphics();
            g.setColor( new Color( 25, 25, 25 ) );
            g.fillRect( 0, 0, 512, 512 );
            object = createQuad( 50, 0, "TextureEffect" );
            object.setAdditionalColor( Color.WHITE );
            world.addObject( object );
            object.translate( new SimpleVector( 0, 0, 100 ) );

            world.buildAllObjects();

            letThereBeLight();  // create light sources for the scene

            // receive mouse input from the main applet:
            addMouseListener( this );
            addMouseMotionListener( this );

            // also get mouse input picked up by the canvas:
            myCanvas.addMouseListener( this );
            myCanvas.addMouseMotionListener( this );
        }

        initialized = true;

        new Thread(this).start();
    }

    @Override
    public void run()
    {
        while( alive )
        {
            synchronized( jPCTSync )
            {
                texture.applyEffect();
            }
            this.repaint();
            try
            {
                Thread.sleep(10);
            }
            catch(Exception e)
            {}
        }
    }

    // Draw the scene
    @Override
    public void paint( Graphics g )
    {
        if( !initialized )
            return;

        synchronized( jPCTSync )
        {
            buffer.clear();   // erase the previous frame

            // render the world onto the buffer:
            world.renderScene( buffer );
            world.draw( buffer );
            buffer.update();

            if( buffer.usesRenderer( IRenderer.RENDERER_SOFTWARE ) )
            {
                // Paint this frame onto the applet/frame (software mode)
                buffer.display( g, leftBorderWidth, titleBarHeight );
            }
            else
            {
                // Repaint the canvas (hardware mode)
                buffer.displayGLOnly();
                myCanvas.repaint();
            }
        }
    }

    // create light sources for the scene
    private void letThereBeLight()
    {
        world.getLights().setOverbrightLighting (
            Lights.OVERBRIGHT_LIGHTING_DISABLED );
        world.getLights().setRGBScale( Lights.RGB_SCALE_2X );

        // Set the overall brightness of the world:
        world.setAmbientLight( 50, 50, 50 );

        // Create a main light-source:
        world.addLight( new SimpleVector( 50, -50, -300 ), 20, 20, 20 );
    }

/**
 * Creates a billboarded quad with a z-offset (handles like a cube rather than
 * a plane).
 * @param width Quad width.
 * @param zoffset Z-offset (toward the camera).
 * @param texture Name of the texture to use on the quad.
 * @return Handle to the billboarded quad.
 */
    public static Object3D createQuad( float width, float zoffset,
                                       String texture )
    {
        float offset = width / 2.0f;
        Object3D obj = new Object3D( 2 );

        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( texture ) );
        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( texture ) );
        // Make it billboard:
        obj.setBillboarding( Object3D.BILLBOARDING_ENABLED );
        // Set up the transparency:
        obj.setTransparency( 0 );
        obj.setTransparencyMode( Object3D.TRANSPARENCY_MODE_ADD );
        obj.setLighting( Object3D.LIGHTING_NO_LIGHTS );
        obj.build();

        SimpleVector o = new SimpleVector( 0, 0, -zoffset );
        Matrix m = obj.getTranslationMatrix();
        obj.setTranslationMatrix( new Matrix() );
        obj.translate( o );
        obj.translateMesh();
        obj.setTranslationMatrix( m );

        return obj;
    }

    @Override
    public void mouseClicked( MouseEvent e )
    {
        if( (e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0 )
        {
            synchronized( jPCTSync )
            {
                if( buffer.usesRenderer( IRenderer.RENDERER_SOFTWARE ) )
                {
                    // Switch to hardware mode
                    buffer.disableRenderer( IRenderer.RENDERER_SOFTWARE );
                    myCanvas = buffer.enableGLCanvasRenderer();

                    this.add( myCanvas, BorderLayout.CENTER);
                    this.validate();
                    myCanvas.setVisible( true );
                    myCanvas.validate();
                    // get mouse input picked up by the canvas:
                    myCanvas.addMouseListener( this );
                    myCanvas.addMouseMotionListener( this );
                }
                else
                {
                    // Switch to software mode
                    buffer.disableRenderer( IRenderer.RENDERER_OPENGL );
                    buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE );
                    this.remove( myCanvas );
                    this.validate();
                }
            }
        }
    }

    @Override
    public void mouseDragged( MouseEvent e )
    {}

    @Override
    public void mouseEntered( MouseEvent e )
    {}

    @Override
    public void mouseExited( MouseEvent e )
    {}

    @Override
    public void mouseMoved( MouseEvent e )
    {}

    @Override
    public void mousePressed( MouseEvent e )
    {}

    @Override
    public void mouseReleased( MouseEvent e )
    {}

/**
 * The BlankTextureEffect class copies a solid color image onto the texture.
 */
    private class BlankTextureEffect implements ITextureEffect
    {
        /**
         * Ignored by BlankTextureEffect.
         * @param tex The video texture.
        */
        @Override
        public void init( Texture tex)
        {}

        /**
         * Copies the solid color image onto the texture.
         * @param dest Pixels to change.
         * @param dest Current pixels.
        */
        @Override
        public void apply(int[] dest, int[] source)
        {
            synchronized( jPCTSync )
            {
                if( blankImage != null )
                {
                    PixelGrabber pg = new PixelGrabber( blankImage, 0, 0, 512,
                                                        512, dest, 0, 512 );
                    try
                    {
                        pg.grabPixels();
                    }
                    catch( InterruptedException e )
                    {
                        System.err.println( "interrupted waiting for pixels!" );
                        return;
                    }
                    if( ( pg.getStatus() & ImageObserver.ABORT ) != 0 )
                    {
                        System.err.println( "image fetch aborted or errored" );
                        return;
                    }
                }
            }
        }

        /**
         * Whether the texture contains alpha information (true for
         * BlankTextureEffect).
         * @return True.
        */
        @Override
        public boolean containsAlpha()
        {
            return true;
        }
    }
}

15
Projects / Helicopter Balls (new and improved)
« on: August 09, 2009, 09:38:06 pm »
I finally got around to working on the new and improved Helicopter Balls applet today.  I've got pretty much everything working the way I want it to, except that I have that darn random lag problem again when using LWJGL OpenAL + OpenGL.  This prevents me from using OpenAL for sound while doing hardware rendering for graphics, until I can figure out what is causing this.  The problem is most apparent when there are large numbers of polygons and numerous simultaneous sources playing.

At any rate, here is the applet (using JavaSound for audio):

Helicopter Balls

The source code is a little ugly at the moment, so I'll post it after I clean it up a bit.

Pages: [1] 2 3 4