Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (653)
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] 2 3 ... 7
1  Games Center / WIP games, tools & toy projects / Re: OGServer -- A simple, easy to use, Game server framework/api. on: 2015-02-03 03:58:25
Your community forum is quite literally 99.9% spam.

http://ogserver.net/forum/forumdisplay.php?fid=8

I've been cleaning this forum up at-least once a day, and it just keeps getting nailed with spammers, I'm not at the point where I'm wanting to take this seriously right now, as I'm still working on some very important tasks.

I've purchased IP.Board and IP.Content, however I'm working on getting my forum set-up on another domain (My master-domain, if you will) in which the forum link is just going to redirect to a subforum on my master-domain.

I've disabled the (Currently useless) forum for the time being. 
2  Games Center / WIP games, tools & toy projects / Re: OGServer -- A simple, easy to use, Game server framework/api. on: 2015-01-31 04:27:20
Great project! What about the progress now?

Progress is still continuing, however I'm working on some much more important tasks right now.
3  Game Development / Newbie & Debugging Questions / Re: Textbook for Java NIO Networking. on: 2015-01-30 23:16:33
Thanks, I'll look through this, don't get me wrong, I use Netty too, and I understand it quite well, well,  how to use it, not how it works. I can write a server using Netty and have it perfectly functional, but it just doesn't satisfy my lack of understanding.
4  Game Development / Newbie & Debugging Questions / Textbook for Java NIO Networking. on: 2015-01-30 10:24:25
I've been using Netty for quite some time, which is built on the Java NIO framework, but as I enjoy tearing down into the core of things, I'm wanting to learn how to write my own applications using  the Java.NIO package.

I've been looking really hard for decent study material on this, but it seems like anything pertaining to is either low-quality, or very low in quantity. Most of the 'tutorials' I find online don't explain anything, and while I can write a basic server by now, I don't really understand how it all comes together.

My over-all goal is to move my server-api to NIO from Netty with the next major release, but to feel confident enough to do this, I will need to do a lot of studying. I don't want to degrade what I have, but I also don't like the feeling of relying on someone else to do all of the hard stuff for me.

Any suggestions are welcome, would prefer if it at-least uses Java7, but J8 is recommended.

Price doesn't matter, only quality. I'm willing to spend $250~ on a good NIO networking textbook.
5  Discussions / General Discussions / Re: Does web development count as programming experience? on: 2014-12-31 18:47:28
Don't you guys start leaving out HTML5 games on the canvas now. That's still considered web-development.
6  Discussions / General Discussions / Re: Most graphically polished (HD)3D games developed in Java? on: 2014-12-31 18:43:17
Gimme an engine in Java that can do this, and we will make it happen.

Cas Smiley

Curious, what in particular do you find to be lacking in Java tech?
I understand Basingstoke is in Unity, is it simply the ease of use compared to other 3D environments that makes it stand out?

I've used Unity for a long time, and I honestly don't feel like it's all that great. I mean, yeah It's much easier to use, but as far as that video shows, it was mainly just lighting changes. Unity makes things really simple for smaller games, but it also makes things fairly complicated for bigger ones. The moment you start to move outside of what's expected from MonoBehaviour and using regular C# in your code, things start going haywire really fast.
7  Games Center / WIP games, tools & toy projects / Re: LPM Online [3D Medieval Fantasy Sandbox MORPG] (Nearing Alpha?) on: 2014-12-31 18:24:10
I'm a big fan of the art in the background of the log in page, but not that big of a fan of the differing image quality in various objects in the game world. Consistency is a good thing, and making the ground such a low resolution image, and then the objects in the world much higher quality, is not consistent.

Also, I am interested in your "rambles about the design," as I have always wanted to implement a system similar to this, but have never really looked into how. If you ever decide to open source your code, I'd love to read that section of it.

What questions do you have? I've done a lot of discussing with OP about this game, as I was the one who wrote the networking framework for him; Obviously I can't hand out code to the game without his permission. (I also don't have an updated version of the client's source) but I can definately help you get an understanding of how things should be done since I've been helping him out with the entire networking related process.

You'd have to ask specific questions though if you want answers, don't flood the thread though, message me instead.
8  Discussions / General Discussions / Re: Most graphically polished (HD)3D games developed in Java? on: 2014-12-31 06:06:26
I think my Army Men game looks decent Smiley


this does look great.
9  Game Development / Newbie & Debugging Questions / Re: [LWJGL] So, are there any (up to date) UI libraries? I can't find them. on: 2014-12-30 10:16:12
For TWL, have a chat to MatthiasM in the LWJGL irc channel, he is normally very helpful.

There are quite a few libraries around which give you ui functionality, check out the LWJGL wiki page - "Game Engines and Libraries Using LWJGL". I'd normally post a link but I am typing on my phone at the moment.

Its also quite fun creating one yourself (I have done this) but it is not easy nor quick.

TWL Literally gives me a migraine, even the website hurts my head- I attempted to talk to MatthiasM however he just directed me to the demos, which also give me a headache. Everything about TWL literally gives me a massive, pounding, headache and I have no idea why. I can't even find the assets for the demos, and on-top of that I can't get it to render ontop of jPCT

It'd help heaps if I could find a decent tutorial for it, preferably in video format, but I've searched well over ten hours accumulative for one(over the last few years), and haven't found squat.
10  Game Development / Newbie & Debugging Questions / Re: [jPCT] Camera snaps to Object3D Rotation. on: 2014-12-30 07:49:58

The issue is that you are missing the www in the link. This is a mis-configuration in the DNS, because www should not matter and naked urls needs to be supported.

Oh jesus, I can't remember the last time I had to type "www" before a link, but it was back when I couldn't talk on the phone and browse the Internet at the same time.
11  Game Development / Newbie & Debugging Questions / [LWJGL] So, are there any (up to date) UI libraries? I can't find them. on: 2014-12-30 07:48:47
The only UI library I've ever been able to find for LWJGL is Feng which stopped development at the start of 2009, and  TWL which I've never been able to figure out, and have no idea when the last update was.

I'm looking for some very basic functionality so I can start learning from it; I've created my own "Text box" but it's not exactly a text box. It doesn't have click listening. I believe this is my problem for most things; I'm just struggling with the "basic" stuff that's always been done for me with other engines. I've managed to get a 3D game running (With the help of a friend) in Java using jPCT(Built on LWJGL) with multiplayer networking so far, but I'm trying to spice things up a bit with a decent UI.

If I can't find one I'll probably dedicate this next week to figuring out and writing an open sourced library for people to use.

12  Game Development / Newbie & Debugging Questions / Re: [jPCT] Camera snaps to Object3D Rotation. on: 2014-12-30 07:43:09
Link to the site is dead

Strange, link to the docs still seems to be up: http://www.jpct.net/doc/
13  Game Development / Newbie & Debugging Questions / [jPCT] Camera snaps to Object3D Rotation. on: 2014-12-30 04:31:04
I've been learning how to use the jPCT library over at http://www.jpct.net/ and I've run into an issue regarding the camera, if anyone is interested in the JDoc location, here's a link: www.jpct.net/doc/

The reasoning for me posting here, and not on the jPCT forums, is because the forums over there look a little more than abandoned.

Here's my issue:

Currently the camera automatically snaps to the rotation of my player, however instead I'm trying to allow the player to rotate inside of the camera, without the camera following it's rotation, only it's position, here's the code that I'm using for the camera.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
private Camera camera;

public Constructor() {
    camera = world.getCamera();
    camera.setFOV(3f);
    camera.moveCamera(Camera.CAMERA_MOVEOUT, 180);
}

public void tick(float delta) {
    camera.setPositionToCenter(this);
    camera.align(this);
    camera.rotateCameraX((float) Math.toRadians(50));
    camera.moveCamera(Camera.CAMERA_MOVEOUT, 150);
    camera.moveCamera(Camera.CAMERA_MOVEDOWN, 10);
}


"Constructor" is an subclass of Object3D and when I change it's rotation the rotation of the camera changes as-well, I've better with all of the camera.rotate options and I've come up short. Continuing development with the camera snapping like this is possible, and I'll come back to it later unless someone here has some solutions.
14  Discussions / General Discussions / Re: Most graphically polished (HD)3D games developed in Java? on: 2014-12-30 02:45:26
WURM looks great.
15  Discussions / General Discussions / Re: Most graphically polished games developed in Java? on: 2014-12-30 02:15:11
The following are some really big and really beautiful games made in Java:


Also, if Java is your favorite language, I'd say go with that. It's always hard to keep motivation to keep going on a project, but if you are programming it in a language you know well and enjoy programming in, then you 1) can focus on game development, instead of learning a language and 2) you will have less of a chance to get unmotivated.

I can't believe I frogot that Runescape was written in Java, considering when I first started taking programming seriously I was working on Runescape emulators.
16  Discussions / General Discussions / Re: Most graphically polished games developed in Java? on: 2014-12-30 02:13:38
This is a little hard to answer because most people don't advertise the fact that they use Java. Minecraft is the obvious go-to answer.

Java has JOGL and LWJGL which are just OpenGL wrappers, so anything you can do in OpenGL, you can do with Java. Jumping into that can be a bit daunting though, because 3D math is just sorta gross (imho). But you'll have to do that math no matter what flavor of OpenGL you use.

Unity is nice because it takes away a lot of that programming, which I guess is awesome if that's what you're looking for.

I've never heard of jPCT, but you might also want to look into libGDX: http://libgdx.badlogicgames.com/

Edit: You might also want to look into jMonkeyEngine: http://jmonkeyengine.org/

JME is gross, perhaps that's just my opinion, but everytime I've even attempted to use it, I lost my will to program for a week.

Minecraft is NOT the go-to option in my opinion, it's just a bunch of blocks with some... meh textures.
17  Discussions / General Discussions / Most graphically polished (HD)3D games developed in Java? on: 2014-12-30 02:02:27
I'm always on edge, wondering which direction I should take my project that I want to become serious. I have almost a year of planning put into it; but I honestly just don't know what I want to create it with. Java is by far my favorite language, and I know it far better than any other language out there, but I also still have heaps to learn. Sometimes I stumble on common logic way more than I should, but it's usually because I'm over-thinking things and making everything super complicated.

Currently I'm staring at Java and Unity3D for a multiplayer game; Either way I'm still going to use my server that's written in Java to handle the multiplayer, but I just can't decide on which direction to go.

Unity3D has a ridiculously large and active community, and people that are wanting to get started with game development all flock to it; This brings in a large amount of great talent for things such as art, level design etc. The drawbacks with Java is that I'd have to create my own level editors, etc.. which isn't a problem, definitely more time consuming but not a problem.

My main concern is my lack of knowledge in the rendering/graphics field- I have a friend that uses jPCT like stated before and he's written me a lovely example with everything I really need to get started, shading, camera snapping, movement, animations, coliision, etc; However even after rewriting it I don't understand the background behind it. There's a few tutorials I am thinking about following that are around 25-30 hours long where people create full 3D games using LWJGL as well, I believe this may give me some good knowledge.

---------

What are the most graphically polished games that you've seen in Java? It's hard to keep up with what the kids call "pretty" these days, and while I don't need anything that's off-the-wall high definition I would surely love to see some work that doesn't make me feel like I'm wasting my time; I know that art has a lot to do with the definition of display, however I've read (note: read) that when messing with Java games (Especially in OGL) that the code behind it makes a huge difference to the quality as-well.

 
18  Games Center / WIP games, tools & toy projects / Re: OGServer -- A simple, easy to use, Game server framework/api. on: 2014-12-30 00:53:24
Not exactly "simple and easy to use". Just from reading the docs there's a lot of stuff designed for certain kinds of games and not others. Such behaviour is good for single projects but not for libraries.

Also, "poorly written documentation" and closed-source don't go together. Nobody's really going to be able to use this.

Not to mention that a closed source networking library is not very trustworthy. There's no way for us to know if there are vulnerabilities, intentional or not.

The plan in the future is to either go with open-sourced development; or a closed structure such as SFS - http://www.smartfoxserver.com/

--

Currently the people using this are all following a Online RPG tutorial series that I'm creating, and I don't have any intention of creating vulnerabilities, considering that would put my name on the shame list. It's true that vulnerabilities could appear, but they can also be reported and patched; This isn't the only scenario in which there could be problems that you can't fix yourself due to it being closed source. I don't see how you say that nobody is going to be able to use it, either. It's designed for extreme ease of use, and after a tiny bit of fiddling everyone I've ever handed it to has had perfect understanding of how to use it.

"there's a lot of stuff designed for certain kinds of games and not others."

Currently you're correct; There's some stuff designed for games that hold inventory systems, or would like to have an easier time creating an online RPG, this is mainly because online RPGs are the starting point of the project, and what most of my following base will be using it for, this is not to say that systems for other games cannot be implemented ontop of it. You're not required to use any of the features that are offered, they're just there for you if you want them. I'm planning on adding more functionality for multiple game types in the future that can be built upon at any time.

I can personally say that I've used this in freelance work for multiple kinds of games. I've done a trading card game, a platforer, a 2d top-down shooter, and a multiplayer 3D RPG all with the same code that's available in the documentation. The idea isn't to give people something they can just download, set a few values and run, it's just a stepping stone to make things easier.

As stated before, smartfoxserver is not open sourced, and thousands of people use it. It's also fairly big named. It's also a pain in the ass for beginners, which is why I've taken the time to write this. If I'm able to teach people how to create multiplayer games that have no programming experience, then I would think that it's fairly simple to use. --- Even if it's only good for a single game type, which you seem to think? Could you elaborate on why?

"Such behaviour is good for single projects but not for libraries."

I don't exactly understand what you're trying to say here;
19  Games Center / WIP games, tools & toy projects / Re: OGServer -- A simple, easy to use, Game server framework/api. on: 2014-12-30 00:26:49
could you give some stats (num users connected, lag millisecs, type of application ran, size of packet, packet freq, etc.?)

The networking is built upon Netty, which you can find over at http://netty.io/ however I can't really give you any statistics on lag/users connected. The amount of users you can have connected completely depends on your hardware, and network connection as-well as the code you use in your game logic. The amount of 'lag' you will have greatly depends on the connection between the client and the server, as-well. If you're asking how long it takes to process logic, it depends on the amount of logic that's being processed. (For example, getting a players name is certainly faster than looping through all connected players and sending out packets).

As for you're questions about "Size of packets, and Packet frequency" - In my tests I was using minimalist packet sizes; However they were definitely optimal for my game. Packets such as movement should be sent over UDP (Depending on movement type) while other data is handled by TCP.

Consider the fact that the minimum Ethernet frame is 42 bytes, and a UDP packet's header is 8 bytes, and a TCP Header is anywhere from 20~60 bytes. Knowing this information can greatly lower the amount of packets that you send, by "Mashing" packets. Granted this is all at the hands of the developer, not the framework. With my test what I had done was created a basic game that handled animation states, and 3d positioning. (X, y, z, rotation) and around 2,000 remote bot clients. These clients would all run around at random. I then logged in locally to see the results, in which I saw numerous clients moving around the world smoothly. The of-course, was a few jumps here and there, due to not handling smoothing for lost UDP data, however it was functional all the same. All of the data relayed via TCP was all consistent as-well, such as health, player names, their identification numbers, and so forth.

Packets can be however large you want them to be; However I'd recommend being smart with it.

As for frequency, I was sending the movement updates every quarter seconds, then relaying information to |all| clients immediately. The packet size was as follows

(Opcode - Integer - 4 bytes, Float x - 4 bytes, Float y - 4 bytes, Float z - 4 bytes, Float r - 4 bytes, Segmentation Buffer - Integer - 4 Bytes)

This served for a total of 28 bytes of data in the packet; The operating system handled the extra 14 bytes (required to reach the Ethernet frame minimum) and we never have to worry about it.

Let's do some basic math,

(28bytes * 4) = 112bytes/second.
112bytes * 2000 = 224,000 bytes/second  (or 224 KB)

So the server is receiving 224kb/second in data (from a total of 2,000 clients moving around). **Granted this is only movement, not to mention the chat spam I had going on at the time**

Here's where things get interesting, for every client update, an update is sent to every other client. So there's 2,000 cleints sending an update to 1,999 clients each, 4 times a second.

2000*1999 = 3,998,000
3,998,000 * 4 = 15,992,000

So you're looking at almost 16million messages/second being sent to a total of 2,000 clients; With the target-traffic being around (447,776,000 bytes) or 447Mb per second.

So instead, what we do is we cache the updates, and send them all in parallel, instead of on-demand, this brings our total message/second count from 15,992,000 to a much more efficient and believable number: 8,000 messages/second. -- Which is effectively the same exact amount of messages the server is getting in (For movement).

This kept my processor at a lovely 70%, while running pandora, Unity3D, a Unity Game rendering 2,000 clients moving around, my Java IDE (Eclipse) and running the server. I don't have a king processor either, just an AMD A10-5800k APU 3.8GHz with a 10Gbit NIC.

20  Games Center / WIP games, tools & toy projects / OGServer -- A simple, easy to use, Game server framework/api. on: 2014-12-29 04:27:55
I guess it's time to come out from under the shade with my latest server project, which has been tested in numerous applications so far, recently I took the project and did a complete overhaul and added a ton more abstraction. The goal of OGServer is to allow people to easily create servers that can withstand a large number of connections; Of-course this will also be limited to the amount of logic the user is processing, how they're processing it, and the hardware of their machine; However I've used this framework in stability tests before and I was pleased with the results.

The project isn't exactly 'closed source', but it's not 'open-source' either, I don't use obfuscation; However I'm not providing the .java files for the time being. -- I'm thinking about rewriting this again, however this time built for extreme stability and ease of use and selling licenses, possibly. I have a fairly large game-developer network that follows me around like puppies and it could be an easy coin or two.

Here's an example of the "meh" packaging for the project:



Currently the server has the following features, with a lot of features planned; Consider it a game-server framework.

  • Entity System
  • Built in friends list and ignore systems.
  • Abstract classes for containers, for things such as inventories, to hold items
  • Stackable and single item support, uses an ID/Amount, can be built upon for more complex item systems
  • Basic region based logic support that can be extended upon
  • TCP and UDP Support, automatically links the UDP data to the proper user, all done in the background
  • Basic collections set up for all "mobs" for other nearby mobs, updates in real time.
  • Easy to use packet system, allows for sending global/single/broadcasts very easily.
  • Built in abstract login protocol, easy to use and build upon
  • A "default login protocol" which uses JSON format for saving accounts, great for testing
  • Uses reflection/annotations to find packets, just create the class and you're good to go.

Planned features include:

  • Remote Administration System(in dev)
  • Websocket networking support
  • Model loading, for authoritative collision
  • An Abstract A* Pathfinding implementation


Current Client API's
  • Java (Beta)
  • Unity3D (Beta)

Planned Client APIs
  • HTML5 (Javascript)
  • Flash



You can view my poorly written documentation over at http://ogserver.net/documentation/
21  Discussions / Miscellaneous Topics / Re: How alive is the forum? on: 2014-12-29 03:48:14
Run! Head for the hills! Don't trapped here like I di---*muffled screams*

...

...

*You hear a loud CLANG, like a shovel hitting something in the distance*

LOL. I literally just busted out laughing.
22  Games Center / WIP games, tools & toy projects / Re: 2D Tiling system on: 2014-12-29 02:32:30
I have always been very interested in hex-tiling, but I've never slowed down to look into it.
23  Game Development / Networking & Multiplayer / Re: Open World Multiplayer Game on: 2014-12-29 02:22:05
Since my entitys have to be rendered after the background but before the foreground, i just call the parts that need to be rendered... i digress the way im doing it is very anoying but it works for me currently

1  
2  
3  
4  
level.renderTiles(screen, xOffset, yOffset,player,1);//Background
level.renderTiles(screen, xOffset, yOffset,player,2);//Blocks entitys can hit
level.renderEntitys(screen);//entitys
level.renderTiles(screen, xOffset, yOffset,player,3);//forground


Hmm, thanks for help man Smiley And not to sound rude or anything, it's entities, not entitys Tongue (i used to write it like that too lol)

* Entity's - If you're talking in context of a property belonging to a specific entity.
* Entities - If you're talking about an entity plurally.

Sorry, just had to toss that.
24  Game Development / Networking & Multiplayer / Re: Multiplayer lag, where dose it come from and solutions on: 2014-12-29 02:13:26
One thing that has been on my mind today and was wondering what the community had to say is about multiplayer lag when the server is slowing down. I am currently working on a 'always online' game currently and have not experienced this yet but i know it can be a big issue for dev's and players alike, now this is my thoughts.

The lag we all experience in games when we get FPS drops or stuttering in your player movements seems to be when a your client sends data to the server to make the player move and the server replies to say there ok to move (this is to stop players moving to fast with hacked clients or wall hacking) and if the server gets too overloaded it begins to slow down this process causing jitters in the movement or full on player lag, but i may have a easy fix (not been done yet since i have not got there but its a brain teaser).

What if when the client detects lag and packets are getting lost then why not make a array for every packet is lost and then send the array and if the array is not sent keep building it up until it gets a ping back and when that has happend clear the array and continue as normal. and through all this allow the player to move freely (only using client based block collision so hackers could temp move through walls but now untill the data has been processed by the server).

Any thoughts on this? i understand that this is a head ach and there is a few holes in the idea that can be fixed but what are your thoughts?

Part of the problem that comes with using TCP Networking is going to be Jitter, however the last paragraph you stated is basically TCP functionality anyway. This is what causes the "fast-forward lag" that you see on a lot of games, Runescape used to be a great example of this. Things could freeze for 2-3 seconds, then all of a sudden everything is rediculous fast for the next few seconds, then everything goes back to normal, that's the client playing catch-up, which simulates fast-forwarding.

What you're describing when it comes to movement is usually referred to as "rubberbanding", and is hated with a passion by Aion players everywhere. Server lag should not effect your FPS at all, however, some people suggest Non-blocking IO solutions, while others suggest thread related solutions, I typically follow the second and handle all of my networking on a second thread. This is not feasible for some platforms (Mobile devices)*.

If you're doing server-authorized movement, I always do "lag calculations", basically there's an "allowed" latency limit that's accounted for based on vector math. Using basic math you can find out if the player is/should-be/or even could be somewhere in 500ms, easily. For example, if the player is at position 4, and they normally move 1 position per second, if they're randomly at position 12 a second later(on the client), that's not possible, even if they're lagging at the maximum allowance of 500ms. However if the client was at position 5.5, and the server expected position 5, it will take that 500ms into consideration and see that 5.5 is within the allowed range. Anything other than that should be rubberbanded, imo.
* Mobile devices may support multithreading now; However about three years ago when I was looking into it, they did not. 
25  Game Development / Newbie & Debugging Questions / [LibGDX] 3D Terrain tutorials? on: 2014-12-23 18:50:47
From the research that I've found while doing my googling over the last hour, LibGDX used to have an example called TerrainTest that was available; However after GL10 it wasn't updated anymore, and was removed. I'm having a hard time finding any information on terrains; considering my game is just going to have a flat terrain I've decided I'll just use a really thin cube as the ground, but I'm curious as to where I can find information on terrains for learning purposes.
26  Game Development / Newbie & Debugging Questions / Re: Starting with 3D in Java, Where should I begin? on: 2014-12-23 16:06:53
Thanks guys, I've got a decent grasp on what's going on so far; The only problem I'm having [LibGDX related] is finding models that will work, most of the .obj models I convert to g3db don't have texutres, and all of the FBX models I convert throw errors about missing Spec.png.
27  Game Development / Newbie & Debugging Questions / Re: NullPointer with basic LibGDX. Following examples. on: 2014-12-23 15:28:41
AH! I figured out what it was; The example was rendering an ArrayList<> of ModelInstances, and not just a single model instance; So when the array was empty, there wasn't any effect; However in my case since I am just rendering a single instance, I need to make sure that the model is completely loaded before rendering.
28  Game Development / Newbie & Debugging Questions / Re: NullPointer with basic LibGDX. Following examples. on: 2014-12-23 15:21:50
Well, when is the onAssetsLoaded() function called? Try adding print statements to find that out as well.

It seems like the problem is that

1  
assets.update()


is never being set to true, so the following code:

1  
2  
3  
if(preloading && assets.update()) {
         onAssetsLoaded();
      }


is never executed.
29  Game Development / Newbie & Debugging Questions / Re: NullPointer with basic LibGDX. Following examples. on: 2014-12-23 15:17:22
What are the values of playerModelInstance and environment when that line of code runs? Add print statements just before that line to find out.


Sorry, I should have posted that information I already had it.

1  
2  
Player Model Instance = null
Game Environment = com.badlogic.gdx.graphics.g3d.Environment@46212667


My confusion is why the instance is null when it's obviously set:

1  
2  
3  
4  
5  
6  
private void onAssetsLoaded() {
     
      playerModel = assets.get("models/characters/goku/ss2.g3db", Model.class);
      playerModelInstance = new ModelInstance(playerModel);
      preloading = false;
   }
30  Game Development / Newbie & Debugging Questions / [solved]NullPointer with basic LibGDX. Following examples. on: 2014-12-23 15:10:24
I'm following this tutorial for loading models using LibGDX: http://blog.xoppa.com/loading-models-using-libgdx/

I'm getting a nullpointer on this line:

1  
modelBatch.render( playerModelInstance, environment );


After some code reformatting, I saw that the

1  
modelBatch.render( 


was the cause of the error.

Here's my error

1  
2  
3  
4  
5  
Exception in thread "LWJGL Application" java.lang.NullPointerException
   at com.badlogic.gdx.graphics.g3d.ModelBatch.render(ModelBatch.java:265)
   at com.chris.rpg.Client.render(Client.java:74)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:207)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)


Here's my code:

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  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
package com.chris.rpg;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.g3d.Environment;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight;


public class Client implements ApplicationListener  {
   
   private PerspectiveCamera playerCamera;
   
   private AssetManager assets;
   
   private Model playerModel;
   private ModelBatch modelBatch;
   private ModelInstance playerModelInstance;
   
   private Environment environment;
   
   private int placeholder_cameraDegrees = 67;
   
   private boolean preloading = false;
   
   @Override
   public void create() {
     
      // Set up the environment
      environment = new Environment();
      environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
      environment.add(new DirectionalLight().set(0.8f, 0.8f,0.8f, -1f, -0.8f, -0.2f));
     
      // Set up the model batch
      modelBatch = new ModelBatch();

      // Set up the player camera
      playerCamera = new PerspectiveCamera(placeholder_cameraDegrees, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
      playerCamera.position.set(10f, 10f, 10f);
      playerCamera.lookAt(0, 0, 0);
      playerCamera.near = 1f;
      playerCamera.far = 300f;
      playerCamera.update();
     
      // Set up the assets manager
      assets = new AssetManager();
      assets.load("models/characters/goku/ss2.g3db", Model.class);
      preloading = true;
   }
   
   private void onAssetsLoaded() {
     
      playerModel = assets.get("models/characters/goku/ss2.g3db", Model.class);
      playerModelInstance = new ModelInstance(playerModel);
      preloading = false;
   }
   
   @Override
   public void render() {
      if(preloading && assets.update()) {
         onAssetsLoaded();
      }
     
      Gdx.gl.glViewport(0,  0,  Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
      Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT);
      modelBatch.begin(playerCamera);
         modelBatch.render( playerModelInstance, environment );
      modelBatch.end();
     
   }
   
   @Override
   public void dispose() {
      modelBatch.dispose();
      playerModel.dispose();
      assets.dispose();
   }
   
   @Override
   public void resume() {
     
   }
   
   @Override
   public void resize(int width, int height) {
     
   }
   
   @Override
   public void pause() {
     
   }
   
   public PerspectiveCamera getPlayerCamera() {
      return playerCamera;
   }
}


Pages: [1] 2 3 ... 7
 
SHC (27 views)
2015-08-01 03:58:20

Jesse (19 views)
2015-07-29 04:35:27

Riven (40 views)
2015-07-27 16:38:00

Riven (21 views)
2015-07-27 15:35:20

Riven (24 views)
2015-07-27 12:26:13

Riven (14 views)
2015-07-27 12:23:39

BurntPizza (36 views)
2015-07-25 00:14:37

BurntPizza (46 views)
2015-07-24 22:06:39

BurntPizza (30 views)
2015-07-24 06:06:53

NoxInc (37 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21
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!