Tag Info

20

The attenuation function you've got, att = 1.0 / (1.0 + 0.1*dist + 0.01*dist*dist) is a fairly common one in computer graphics - or, more generally, 1.0 / (1.0 + a*dist + b*dist*dist)) for some tweakable parameters a and b. To understand how this curve works it's helpful to play with the parameters interactively. This curve is nice because it approaches ...

19

Put it wherever you can to make it work. Anything else is design paralysis and just going to slow down your progress. When you start seeing patterns emerge, refactor your code. Lots of people will give you advice about the One True Way to do something, but without a breadth of experience to draw from, you'll just be parroting ideas without a true ...

18

There are two possible causes for this type of problem, depending on exactly which problem it is. I'll list both: 1. You are seeing other colors from your texture along the edges of the tiles. This looks to me like the problem in this case, because all of the edge pixels are one of three colors which are plausibly in your texture: white, black, and brown. ...

17

You could use an algorithm that checks near blocks, and varies the probability depending on what is there - but I think it's largely the wrong approach. What you want to be looking at is fractal noise types - in this case, perlin or simplex noise. If you generate noise, you'll get values from -1 to 1. http://en.wikipedia.org/wiki/Perlin_noise You can then ...

15

What you have described is entirely adequate and appropriate to provide resolution independence. Anything you draw will indeed always take up the same proportion of your window. However, if you do nothing more than this, you will have aspect ratio problems. For example, given the numbers you wrote, if you draw a circle, it will be squashed — wider than it ...

14

You need to change the texture magnification type, like so: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); Read about glTexParameter.

13

This is from an old OpenGL-based game engine I was trying to write about seven years ago written in C++ so bare with me as I try to explain how I handled 3D world and 2D GUI rendering operations within it. I used four primary methods within my OpenGL renderer class (OGLRender) of which are: ready3D() for preparing OpenGL to render the 3D world scene. ...

11

One way to do this is to check the bounding box of the block against the bounding box of the current view (plus a bit for safety). If the block interacts with the view (either fully inside or clipped) then draw it. If it doesn't - i.e. is totally outside then don't draw. This check can be performed quite quickly - particularly in 2D. You don't have to know ...

11

There is no such directory; %APPDATA% is Windows-specific. You'll have to abstract it yourself: create your own GetSaveGameDirectory function that returns an appropriate path on whatever operating system you're running on. You can typically make this determination at compile time with preprocessor checks against the appropriate macros in C (and it's ilk). I'...

10

Pedantic note: There is no such thing in OpenGL as a "Vertex Buffer Object." There are simply Buffer Objects. A buffer object is simply a linear array of GPU memory that you can allocate, fill with data, read from, and use in a variety of ways. One of the things you can do with buffer objects is store vertex data in them and use them as source arrays for ...

10

The reason you're limited to power-of-two sizes is due to how video ram works. Note that what you should do is typically make the image the next highest power of two (.e. 512x256), and then just use a portion of that image for your graphics. You'd be setting your UV coordinates to only use a subsection of the image onto whatever triangles you're rendering. ...

8

The best way in my opinion is to write your own parser for .obj exported with Blender or your preferred 3D modeling software. It will really only take you a maximum of one hour and you won't have to worry about distribution/licence issues. Here is a video about this question: http://youtu.be/izKAvSV3qk0.

8

Look at your if statements. You set paused to true, then the next statement evaluates true (because there's no way to not press p for a short enough time and you just set paused to true), and it sets it to false. Try: if(Keyboard.isKeyDown(Keyboard.KEY_P) && !gamePaused) { gamePaused = true; } else if(Keyboard.isKeyDown(Keyboard.KEY_P) &&...

8

The reason you're not finding anything is probably because it's so exceedingly simple there's nothing to ask about and nothing much to talk about. Here's how a day/night cycle works: You have a sun and moon that travel overhead (maybe also stars, etc). Your game has a time of day. The position of the sun and moon, and appearance of the sky, depends on the ...

8

This will depend a lot on what you want to acomplish and the type of game you have. You would have a 'game world' time that advances based on the cpu clock. Generally at a much faster pace so it can be seen. And you will need to take into account pausing, alt-tabbing and so on. You can also advance it manually such as when the player sleeps, uses some kind ...

7

You'll want to use 3D picking. Here's some code I use in my game. First I cast a ray from my camera. I'm using the mouse, but if you're just using where the user is looking, you can just use the center of the window. This is that code from my camera class: public Ray GetPickRay() { int mouseX = Mouse.getX(); int mouseY = WORLD.Byte56Game.getHeight()...

7

These can be done using shadow mapping. Basically, place the camera at the light source and render the scene into a depth buffer; the resulting buffer identifies all the lit surfaces since they are just the surfaces the light can "see". This texture is then used in the pixel shaders in the main render to mask away light on surfaces behind the shadow map. ...

7

Instead of me just giving you the classes and you not knowing what is happening in them, I will provide you with an explanation and run down of what is happening and then you can give it a go yourself. I believe it's better to teach someone how to fish rather than catching the fish for them :) Ok so lets get into it! A camera is basically just an x and y ...

6

You can't. The nature of any kind of digital data is that once information has been removed it can never be put back, and likewise you can't fill in information that was never there in the first place - the best you can do is a rough approximation, which gives you blurriness. Using GL_NEAREST won't blur but it will become pixellated instead. The solution ...

6

What that code is doing is limiting motion to only if you're inside the screen. What you should instead do is something like this: //control code here if(player.getx() > 1024){ player.setx(1024); }else if(player.getx() < 0){ player.setx(0); } that way if the player exceeds the bounds of the screen the position will be set back to the bounds....

6

If you build your meshes more carefully, ensuring you are reusing vertices wherever possible, you should be fine: That is, you must not duplicate vertices per face as then the GPU rasteriser will see them as two discrete objects and sometimes fail to rasterise the in-between space (thus defaulting to the GL's clear colour) due to floating point limitations; ...

6

I had the same problem with a recent game I'm working on. I guess you are using one big texture with all the block textures in it (like Minecraft does it)? If so these white pixels appear because of rounding errors in the shader that lead to "empty" texture spots. This occurs even if you do not use texture interpolation (which is the case with your game ...

6

The library comes with examples of how to use it. All of the source code for the webstart examples comes with the library. There's also a tutorials section in the wiki page for jBullet. Further, most of the tutorials for the c++ version are applicable to the Java port. You will just need to modify the class and function names to work with the Java syntax ...

6

There are a couple things you can do. First, don't update every tile every tick of the game. Games like Terraria do periodic updates on only parts of the world at any time. Sub-divide your tile grid into chunk. Update one chunk each tick. You don't need to do it any more. You might even need to do it less. Things like growing grass and such are ...

6

The oscillation is a common thing. Likely from CPU scheduling and other processes on the system. The first frame being very long is an error in your code. Consider what lastFrame is set to when the application starts (likely 0), so for the first frame you're just setting deltaTime to the time/1000. You can add a check that if lastFrame is 0, the deltaTime ...

5

This is a common problem even on new GPUs when drivers are not installed. OpenGL version is 1.0 1.1 and is running in software mode. Install/update GPU drivers and add version query to your application. If returned OpenGL version is below 1.1 then it is definitely missing drivers.

5

A simple suggestion and something I recently put into my game. For all the horizontal upward faces, find if they are also the base of an adjacent horizontal face. For example, when I'm building my VBOs I run some code like this: Color[] colors = new Color[4]; Color faceColor = GetColorForFace(x, y, z, face); colors[0] = faceColor; //mpp ...

5

I'm using this code on my game right now: System.getProperty("user.home"); Simple and efficient. It's a user dependent directory, which is perfectly fine for storing save files. I'm using it to download and store assets, though.

5

Usually you would just leave this up to the user to decide or alternately run a small bench test and recommend settings to the user. If you want to bench test to recommend settings or just put it on regardless all you need to do is see how long it takes to complete your render call. If a frame is 25 milliseconds, for example, and all your draws are done in ...

5

This might be too late for you, but for the benefit of web searchers, I'll answer: Create an empty canvas (AWT). Set the size of the canvas to be equal to the LWJGL Display. Add the canvas to the Java Swing form. (There's a reason for this). Set the canvas as parent of the LWJGL Display using Display.setParent(canvasName);. (Remember you might also need to ...

Only top voted, non community-wiki answers of a minimum length are eligible