Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (511)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Networking & Multiplayer / Re: NIO Object Streams on: 2003-04-25 21:50:25
Aha - it turns out that creating the ObjectInputStream before the ObjectOutputStream can cause programs to hang. I just changed the order, and it worked.
2  Game Development / Networking & Multiplayer / Re: NIO Object Streams on: 2003-04-25 21:21:39
Yeah, I figured as much  :-/  But here's a whole NEW thing; I just tried using the traditional Socket and ServerSocket, and the connection itself again worked fine. BUT, when I tried instantiating object input/output streams using the socket's streams, the program stopped dead! I tried wrapping a BufferedReader and PrintWriter around the streams, just to see what'd happen - and it worked perfectly.  Huh It's beginning to look like I'll have to communicate using Strings and such, which is exactly what I wanted to avoid in the first place.  Sad

Does anyone see what might be causing the problem here?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
Socket sChannel;
ServerSocket servChannel;

ObjectInputStream in;
ObjectOutputStream out;

public void setupConnection(boolean client)
{
      try
      {      if(!client)
            {      servChannel = new ServerSocket(4096);
                  sChannel = servChannel.accept();
            }
            else
                  sChannel = new Socket(hostName, 4096);

            in = new ObjectInputStream(sChannel.getInputStream());
            out = new ObjectOutputStream(sChannel.getOutputStream());                        
      }
      catch(Exception e)
      {      System.err.println("Error while establishing connection. Terminating... \n" + e.getMessage());
            System.exit(-1);
      }
}
3  Game Development / Networking & Multiplayer / NIO Object Streams on: 2003-04-25 19:11:20
Hey all!

I'm writing a 3D tennis game at the moment for my final-year college project, and I'm trying to get it to work over a network. To be honest, I was unaware of NIO until quite recently, but it seemed very straightforward and was exactly what I was looking for, so I went ahead and started writing the network code using it. Unfortunately, I've hit a problem.

Basically, I have a Message class which encapsulates all the data I need to send for each event - message ID, player/ball positions and directions, etc. I want to create an Object stream across the socket channel, so I can serialise instances of this class and transmit them back and forth. Whenever I try to set up the stream, however, I get an IllegalBlockingModeException. I've checked through the code, and found that the connection is set up correctly and no exceptions are thrown UNTIL I attempt to create an Object Stream on the channel. I had assumed that the ObjectStream would behave exactly as it would when created on a regular Socket, but would return immediately with null if there was no incoming data. From this exception, however, it seems that Object streams are blocking-specific.

My question is - how can I set up object input/output streams on a non-blocking channel? Are there some permission issues to take into account that I'm not aware of, or are there updated Object stream classes which are designed specifically for NIO? Any help would be much appreciated!

Thanks,
Reynard.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
SocketChannel sChannel;

public void setupConnection(boolean client)
{      ServerSocketChannel servChannel;

      try
      {      if(!client)
            {      servChannel = ServerSocketChannel.open();
                  servChannel.configureBlocking(true);
                  servChannel.socket().bind(new InetSocketAddress(4096));

                  sChannel = servChannel.accept();
                  sChannel.configureBlocking(false);

                  servChannel.close();
            }
            else
            {      sChannel = SocketChannel.open();
                  sChannel.configureBlocking(false);
                  sChannel.connect(new InetSocketAddress(hostName, 4096));

                  while(!sChannel.finishConnect())
                        Thread.sleep(25);
            }

            in = new ObjectInputStream(Channels.newInputStream(sChannel));
            out = new ObjectOutputStream(Channels.newOutputStream(sChannel));                        
      }
      catch(Exception e)
      {      System.err.println("Error while establishing connection. Terminating... \n" + e.getMessage());
            System.exit(-1);
      }
}


I should also mention that the ServerSocketChannel in the above example is discarded because this is a straightforward 2-player game - once the first connection is accepted, there is no need to listen for any more. As such, I configured the ServerSocketChannel to block intentionally - I assumed that this wouldn't cause any problems, since I could just set the resulting SocketChannel to non-blocking.
4  Java Game APIs & Engines / Java 3D / 3DS Animation Loaders... on: 2003-03-12 17:45:34
Me, yet again. Wink At the moment, I'm trying to put together the character animations for my 3D tennis game. I've got both MilkShape and 3D Studio Max, and a very good Java3D loader for MS3D-format files (the Java3D Game SDK, from SourceForge). Ideally, I'd like to be able to create my character animations using 3D Studio, but I can't find a 3DS loader that supports animation. I had considered creating the animations in Max, then bringing them into MilkShape and converting them to MS3D format, but MilkShape doesn't seem capable of importing animation tracks from 3DS.

Does anyone know of any good Java3D loaders that DO support 3DS animation tracks? Otherwise I'll just have to plough ahead with MilkShape...

Thanks!
5  Java Game APIs & Engines / Java 3D / Re: Tennis Game Models.... on: 2003-03-12 17:40:15
Yeah, I was afraid of that.  Wink I've got both MilkShape and 3D Studio Max, and a very good Java3D loader for MS3D-format files... ideally, I'd like to be able to create my character animations using 3DStudio, but I can't find a 3DS loader that supports animation. I had considered creating the animations in 3DSMax, then bringing them into MilkShape and converting them to MS3D format, but MilkShape doesn't seem capable of importing animation tracks from 3DS.

I don't suppose you know of any Java3D loaders that DO support 3DS animation tracks? Otherwise I'll just have to plough ahead with MilkShape...

Thanks for the info!
6  Java Game APIs & Engines / Java 3D / Tennis Game Models.... on: 2003-03-06 23:11:44
Hey all!

I'm writing a tennis game for my final year college project, and I'm trying to find some decent models to use. Ideally, I'd like an animated, low-to-medium poly, pre-textured tennis player model - it'd just make my life so much easier - but I'll take what I can get. Wink I've looked around various sites (3DCafe, etc) and found a few basic humanoids I can probably use, but I'm hoping there's better out there.

Anyone know where I can find what I'm looking for?

Thanks!
7  Java Game APIs & Engines / Java 3D / Re: Java 3D Quirks on: 2003-02-14 13:22:58
Herkules: that's the only other thing I could think of. I updated my GeForce drivers from the nVidia website, and it seems to have fixed the problem (at least, I've run it about a dozen time now without it happening). I can only assume that's where the problem originated, even though my "old" drivers were pretty goddamn new.

Thanks for the help, guys!
8  Java Game APIs & Engines / Java 3D / Re: Java 3D Quirks on: 2003-02-13 17:36:02
Tried it, but it didn't have any effect. The tennis game still ran at an incredibly slow framerate, and the window artefacts were still popping up  Huh

I should probably mention that the game is currently running in an undecorated 800x600 JFrame, with setIgnoreRepaint enabled.
9  Java Game APIs & Engines / Java 3D / Java 3D Quirks on: 2003-02-13 17:06:26
Hey all! Just started using Java3D for a college project; I'm planning to do a 3D tennis game. I've got the basics in place - a court, with the ball bouncing around in it - but I've come across a problem. Basically, I can run the program several times, and it works perfectly and very fast each time. But then, I'll try it again and it'll start running at something in the region of 1 FPS for no apparent reason. Furthermore, it'll perform in this way every time I run it from then on, until I restart my computer.

I've tried writing it in immediate, retained and mixed modes, and the same thing happens in each. I'm stumped as to why this might be happening; the only thing I can think of is that I haven't performed a proper cleanup when terminating the program, even though I did write code to do so. Does anyone have any idea what might be causing this? As you can imagine, it's kind of annoying to have to restart my computer every twenty minutes just so I can keep testing.

Edited to add: it also seems to have the effect of slightly interfering with Windows - after this happens, dragging windows etc. sometimes leaves artefacts behind in their previous positions.

Thanks, and expect many more pointless questions in the near future!  Wink
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (42 views)
2014-10-16 15:22:06

Norakomi (32 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (85 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!