Game Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesGame Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #31  
Old March 1st, 2008, 03:09 PM
paulscode paulscode is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Fort Meade, MD
Posts: 43 paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 30 m 17 sec
Reputation Power: 9
Menus and Wiring

Today I finished writing the code for a class called "ComponentConnection", which connects two pins together and draws a circuit path between them. It changes color depending on whether or not the connection is "hot" (electricity flowing through). It's orientation can be changed by dragging it with the mouse or moving the two pins it is connecting. I have also begun writing the framework needed to incorporate this class into the Robot Builder game (you never realize the amount of work you have to do on something until you start doing it, seems like). I needed a menu system for the toolkit, the chip editor, and the robot circuitry components of the game, so that is something else I have been working on for the past few days. You may have noticed a few little changes if you've visited the link. I've been trying to re-upload the game each time I finish and test something new, so people can see the progress I'm slowly making on it.

Reply With Quote
  #32  
Old March 5th, 2008, 09:02 PM
paulscode paulscode is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Fort Meade, MD
Posts: 43 paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 30 m 17 sec
Reputation Power: 9
Arrow Sound Effects

I was getting a little bored with the chip editor, so I decided to work on sound for a while. I will be using the JOAL library, because it plays sounds in 3D (which I will be needing when I get back to the 3D stuff). This library is really complicated, but the flexibility it offers is awesome. I purchased a book by Andrew Davison, called Pro Java 6 3D Game Development (a very good book, btw). There is a chapter in the book dedicated to JOAL, and it goes into creating a class to simplify loading, playing, and moving sounds in 3D. I followed the guide in the book to create a SoundManager class.

-- EDIT: The previously posted source code contained errors, so I removed it --

There are some functions for 3D sounds (which I have not yet tested, so there are probably bugs). Initial tests of loading sounds and playing them (looping and non-looping) seem to work. Next I will look into putting sound into Robot Builder (perhaps a bump sound when the robot hits the wall).

Last edited by paulscode : March 8th, 2008 at 02:05 PM.

Reply With Quote
  #33  
Old March 6th, 2008, 07:07 PM
paulscode paulscode is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Fort Meade, MD
Posts: 43 paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 30 m 17 sec
Reputation Power: 9
lwjgl vs. JOAL

Well, I discovered that lwjgl has its own Java binding of the OpenAL sound library, and that it is incompatible with the JOAL binding I mentioned in my last post. I actually embarrassed myself a little yesterday by posting a JOAL question on an lwjgl forum -doh!

ANYWAY... since the applet loader program that I am using to load my game is written for lwjgl, I am already loading those libraries. Therefore, it seems logical to switch over to this other binding. They are actually quite similar, and I didn't have any trouble accomplishing the switch. I also have begun running more thorough tests on the code. Sounds are loading, and playing without any problem. However, tests of the 3D functions of the Sound Manager indicate that there is a problem (perhaps a simple typo - not sure yet). For example, a source that moves away from you should be getting quieter, but it is not. I will look into this problem further to see if I can solve it. This is kind of an important issue when you are talking about a 3D game.

I will post the working code for the Sound Manager, when I am finished working out all the kinks. It is designed to SIGNIFICANTLY simplify sound in 3D, so I am sure a few programmers will find it very helpful.

Reply With Quote
  #34  
Old March 8th, 2008, 02:07 PM
paulscode paulscode is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Fort Meade, MD
Posts: 43 paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 30 m 17 sec
Reputation Power: 9
Cool Robot Builder with Sound

Robot Builder now has a couple of sound effects! I used the lwjgl binding of OpenAL. My Sound Manager still looks pretty rough, so I won't post the source code just yet. There are also still a few more 3D-related features I want to add to the class before releasing it.

Reply With Quote
  #35  
Old March 17th, 2008, 02:30 PM
paulscode paulscode is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Fort Meade, MD
Posts: 43 paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 30 m 17 sec
Reputation Power: 9
The "Sound Manager"

I have been doing a lot of work on the Sound Manager, and I finally feel like it is in a form that I can release. You can get the source code here:
http://www.paulscode.com/source/Sou...nagerSource.zip
Or if you just prefer to download the JAR:
http://www.paulscode.com/source/Sou...oundManager.jar

I made a simple test applet using the Sound Manager:
http://www.paulscode.com/source/Sou...oundApplet.html
And here the source code for the test applet:
http://www.paulscode.com/source/Sou...ppletSource.zip

I also wrote a really basic guide:
Code:
Guide to the SoundManager class

The simplest way to use SoundManager in your jPCT project:
Create the SoundManager object when you initialize things:
    soundManager = new SoundManager();
Bind the listener to the Camera after creating one:
    soundManager.bindListener( camera );
Create some sound sources:
    soundManager.newStreamingSource( "music", "deckthehalls.ogg", true );
    soundManager.newSource( "meow", "cat.wav", false );
    soundManager.newSource( "purr", "motor.wav", true );
Bind sound sources to Object3D's:
    soundManager.bindSource( "meow", my3DCat );
    soundManager.bindSource( "purr", my3DCat );
Call tick() in your main game loop:
    soundManager.tick();
Play the sounds any time you like:
    soundManager.play( "music" );
    soundManager.play( "meow" );
Call cleanup() at the end of your project:
    soundManager.cleanup();


Common Terms:
ATTENUATION:  How a sound "fades" with distance.
    If there is no attenuation, a sound will play at constant volume regardless of distance
FADE DISTANCE:  The distance at which a sound volume will become completely silent
    Used in Linear Attenuation
    (works for both mono and stereo sounds)
LINEAR ATTENUATION:  A sound's volume is inverse to it's distance
    A sound half fade-distance away will play at half volume
LOGRITHMIC ATTENUATION:  A sound's volume is a logrithmic function of it's distance
    A more realistic attenuation model - uses a rolloff factor
    (only works for mono sounds)
ROLLOFF:  A value used in logrithmic attenuation.
    Smaller values for rolloff fade away at longer distances
    If rolloff is 0, then the sound will not fade
STREAMING:  Using multiple buffers to break long sound files, (like background music) up
     into smaller pieces, so you can start playing immediately, rather than waiting to load.


Global References:
Attenuation models:
    public int ATTENUATION_NONE    = 0;  // no attenuation
    public int ATTENUATION_ROLLOFF = 1;  // logrithmic attenuation
    public int ATTENUATION_LINEAR  = 2;  // linear attenuation

Global Varriables (can be changed to fit your preference):
Package where the sound files are located:
    public String SOUNDFILES_LOCATION = "Sounds/";    
Attenuation model to use if not specified (one of the references listed above):
    public int DEFAULT_ATTENUATION_MODEL = ATTENUATION_ROLLOFF;
Default value to use for rolloff model when value isn't specified:
    public float DEFAULT_ROLLOFF_FACTOR = 0.03f;
Default fade distance for linear model if value isn't specified:
    public float DEFAULT_FADE_DISTANCE = 500.0f;    
Number of bytes to load at a time when streaming:
    public int STREAMING_BUFFER_SIZE = 4096*16;
The number of buffers used for each streaming sorce:
    public int STREAMING_NUM_BUFFERS = 2;    
The approximate size of a normal .ogg file:
    private int OGG_NORMAL_SIZE = 1048575;


Easy Interfacing with jPCT
When using these methods, don't forget to call tick() in the main game loop:
    bindListener( Camera c )
        Listener will automatically follow and align with the Camera object

   bindSource( Object3D o )
       A source will automatically follow an Object3D



Method Descriptions:

public void cleanUp()
    Stops all sounds and clears up any used resources

public boolean bindListener( Camera c )
    Orientates the listener to match the Camera orientation

public boolean bindSource( String sourcename, Object3D obj )
    Associates a sound source with an Object3D to follow

Releases a source from it's associated Object3D
    public void releaseSource( String sourcename )

public void releaseAllSources( Object3D obj )
    Releases all sources bound to this Object3D
    (Usually called before deleting an Object3D with sources attached to it, but not required)

public void tick()
    Re-aligns the listner to the camera, and keeps sources folowing the Object3D's they are bound to
    Should be called within the game loop
    (only required if you are using bindListener or bindSource)

public boolean load( String filename )
    Load the specified file (only used for non-streaming sources).
    It is not necessary for you to call this method in your program, but you can if you want to.
    (For example, you could load all the sounds at once and show a progress bar)
    SoundManager will automatically call this method if necessary when creating a source
    If "filename" is a url, it must begin with "http://"
    Returns "true" if there were no problems loading the file
    
public boolean newSource( String sourcename, String filename, boolean toLoop )
public boolean newSource( String sourcename, String filename, boolean toLoop, int attmodel )
public boolean newSource( String sourcename, String filename, boolean toLoop, int attmodel, float distORroll )
public boolean newSource( String sourcename, String filename, boolean toLoop, float x, float y, float z, int attmodel )
public boolean newSource( String sourcename, String filename, boolean toLoop, float x, float y, float z, int attmodel, float distORroll )
public boolean newStreamingSource( String sourcename, String filename, boolean toLoop )
public boolean newStreamingSource( String sourcename, String filename, boolean toLoop, int attmodel )
public boolean newStreamingSource( String sourcename, String filename, boolean toLoop, int attmodel, float distORroll )
public boolean newStreamingSource( String sourcename, String filename, boolean toLoop, float x, float y, float z, int attmodel )
public boolean newStreamingSource( String sourcename, String filename, boolean toLoop, float x, float y, float z, int attmodel, float distORroll )
    Create a new normal or streaming source.  A streaming source differs from a normal source, in that it has multiple, dynamic buffers.
    SoundManager will use default values for any value you don't specify when creating your source.
    sourcename: A unique identifier for this source (two sources may not use the same sourcename)
    filename: The name of the sound file to play at this source.  If "filename" is a url, it must begin with "http://"
        (if the sound file has not been loaded yet, then SoundManager will load it for you)
    toLoop: Should this source loop, or play the sound only once
    (x, y, z):  Location in 3D space for this source.  Default location is the origin ( 0, 0, 0 )
    attmodel:   Attenuation model to use.  Default is the value in DEFAULT_ATTENUATION_MODEL
    distORroll: Either the fading distance or rolloff factor, depending on the value of "attmodel".

public boolean deleteSource( String sourcename )
    Deletes the specified source

public boolean setPos( String sourcename, SimpleVector pos )
public boolean setPos( String sourcename, float x, float y, float z )
    Moves the named sound to the specified location.

public boolean play( String sourcename )
public boolean stop( String sourcename )
public boolean pause( String sourcename )
public boolean rewind( String sourcename )
    Controls for playing, stopping, pausing, and rewinding a source

public boolean playing( String sourcename )
    Returns true if the source is playing

public void moveListener( float xStep, float zStep )
public void moveListener( SimpleVector step )
public void moveListener( float xStep, float yStep, float zStep )
    Moves the listener, relative to their current position.

public void setListenerPos( float xNew, float zNew )
public void setListenerPos( SimpleVector posNew )
public void setListenerPos( float xNew, float yNew, float zNew )
    Positions the listener at the coordinates provided.

public void turnListener( float angle )
    Turns the listener counterclockwise by "angle" radians, relative to their current orientation.

public void setListenerOrientation( float angle )
    Sets the listener's orientation (counterclockwise rotation in radians along the y-axis)

public void setListenerOrientation( SimpleVector look, SimpleVector up )
public void setListenerOrientation( float lookX, float lookY, float lookZ, float upX, float upY, float upZ )
    Sets the listener's orientation based on a look-at point and an up-direction

public void recalculateDistances()
    Recalculates the distances between each source and the listener, and recalculates the gain if a
    source is using linear attenuation.  It is not necessary for you to use this method.
    SoundManager will automatically call this method when the listener moves or rotates, or a source moves.


One potential bug I am looking into is the fading between left and right speakers only seems to work when the source is really close to the listener. I haven't determined if it is a limitation with my soundcard, or a bug in the code. I am looking into this further. It would be helpful if a few people could run the above applet and see if they experience the same thing. Thanks in advance!

Reply With Quote
  #36  
Old March 17th, 2008, 10:50 PM
0CIRCLE0 0CIRCLE0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 59 0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 18 h 48 m 59 sec
Reputation Power: 84
Your robot going in circles nets 126FPS
Comp Specs

C2D 6750 @ 2.6Ghz
6800 GS 256MB x2 (SLI)
2 GB 8500 DDR2

My other comp which is much slower nets 48 FPS
Celeron D 3.3Ghz
7300 GS 256 MB
2 GB 6400 DDR2

Your demo is very CPU intensive.

Last edited by 0CIRCLE0 : March 17th, 2008 at 10:56 PM.

Reply With Quote
  #37  
Old March 19th, 2008, 06:24 PM
paulscode paulscode is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Fort Meade, MD
Posts: 43 paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 30 m 17 sec
Reputation Power: 9
Talking CPU Intensiveness

Quote:
Originally Posted by 0CIRCLE0
Your robot going in circles nets 126FPS
Comp Specs

C2D 6750 @ 2.6Ghz
6800 GS 256MB x2 (SLI)
2 GB 8500 DDR2

My other comp which is much slower nets 48 FPS
Celeron D 3.3Ghz
7300 GS 256 MB
2 GB 6400 DDR2

Your demo is very CPU intensive.


Yes, I have been getting a few comments like this from various people. Even on my machine, I would expect to have a considerably higher FPS than I am getting, considering how simple this applet is.

Believe it or not, I think the issue is with the 2D components, not the 3D. I have to say -Java Swing is intuitive and easy to use, but I think it is the source of the speed issue - all my pure 3D applets run quite fast, and if I comment out the 2D rendering components of Robot Builder, it more than quadruples the speed. Instead of the Swing functions for mixing 2D with the 3D, I am looking into using direct bit-blitting, which takes away the BufferedImage overhead. EgonOlsen has added some brand new features into the latest compile of jPCT, which will make this much easier. I believe the new methods work the same for either software or hardware mode, so I am probably going to end up using hardware-accelleration after all. I plan to allow the player to choose whichever works better for their machine.

Thanks for the feedback!

BTW, those of you interested in seeing Robot Builder completed, you may have a little while to wait before I get back to working on it. Besides the blitting issue, I am also doing an extensive overhaul of the SoundManager class. One thing you may have noticed if you've tried to create a lot of sources (depending on your sound card), at some point the sources will just not play - ie there is a maximum number of sources that can be played at one time. Unfortunately, it seems that a source's distance from the listener has no bearing on which sources OpenAL decides to play when you have too many. This would pose a serious problem in a 3D game where you could potentially have hundreds or thousands of sound sources.

So what I've decided to do, is make SoundManager smart enough to cull unnecessary sources. Basically, there would be a "maximum source number". Sources will have a priority based on their distance from the listener, closer sources having priority over further away sources. Sources will be culled down to the maximum source number based on their priority. Which sources are culled will change dynamically as the listener or sources move, or when non-looping sounds stop playing.

I will keep everyone posted on how progress goes for both of these projects.

Reply With Quote
  #38  
Old March 19th, 2008, 09:16 PM
0CIRCLE0 0CIRCLE0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 59 0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level)0CIRCLE0 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 18 h 48 m 59 sec
Reputation Power: 84
4x the performace if you use 3d instead of 2d. Use 3d :P Anyways looking foward to seeing what you come up with and how this all comes together.

Reply With Quote
  #39  
Old March 20th, 2008, 02:24 PM
paulscode paulscode is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Location: Fort Meade, MD
Posts: 43 paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level)paulscode User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 30 m 17 sec
Reputation Power: 9
Talking 2D and 3D

Quote:
Originally Posted by 0CIRCLE0
4x the performace if you use 3d instead of 2d. Use 3d :P Anyways looking foward to seeing what you come up with and how this all comes together.


LOL, yeh. Unfortunately Robot Builder is a 2D game..

As for my 3D game Universe Storage, I will need to be able to mix 2D and 3D for a "heads up" style display for things like stats, etc. So I've got my fingers crossed that the blitting idea will improve performance.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesGame Development > 3D Browser-based Game Development


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |