Welcome, Guest. Please login or register. Did you miss your activation email?

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

Pages: [1] 2
1
SFML projects / Ray Tracer
« on: April 14, 2016, 07:45:15 pm »
For a class project I had to build a ray tracer from scratch, but we were allowed to use any program we wanted to display and manage things like color etc. So I use sfml to display and save the images, as well as sf::Color. I obviously had to make my own Vector and Geometry classes though.

It (can) use an Octree to speed up the ray tracing, but it only starts to pay off above a few hundred objects in the scene.

Features:
Octree
Soft and Hard Shadows
Antialiasing
Multijittering
Directional, Point, and Area Lights
Potentially Unlimited reflection recursion.
Any object can have varying levels of Reflection, Diffuse Shading, Specular Reflection, Object Color
Mesh Loading
Spheres
Triangles
Parallelograms
Infinite Planes
Camera (moves, pitches, yaws, rolls)

The camera actually moves all the objects in the scene by the inverse transformation.

I'll post the code when the class ends (to prevent other students from finding my code and potentially copying and getting me in trouble). In the mean time, here are some of the best images.

Click to enlarge:
1000x1000; 4 sample Multi-jitter; Unlimited reflective recursion; Area light with 36 samples (6x6); Various Diffuse,Specular,Reflective values for the spheres and planar floor. Took 4 minutes to render.


1601 Spheres.

A purple cow.

Purple Teapot.

2
General discussions / sf::Rect variable names
« on: April 13, 2016, 10:23:39 pm »
I understand why sf::Rect uses left and top as variables, but this causes, as I just experienced, significant confusion. I wanted to use it in a standard coordinate system, and that caused strange bugs as you can imagine.
What the class actually wants is minX and minY. And what coordinate system you are in shouldn't change how you think about a class. For example, even though the vector class is in sf::namespace, and intended for the screen coordinate system, the Vector class doesn't ask for down and right instead of x and y.

Edit to clarify the problem:
A constructor of sf::Rect takes (left, top, width, height), and that's how they are stored too.
So if you want a 2x2 square surrounding (0,0), you would just do (-1,1,2,2) right? Wrong (maybe).
The left and top in a standard coordinate system with a positive width and height would be minX (left) and maxY(top), but sf::Rect took into consideration that most users would be using window coordinates where Y is negative. So (left,top) isn't actually the top left coordinate in the standard coordinate system, it's the bottom left. This through me for a loop when trying to use the class in a standard coordinate system (for it's various other functions of intersecting and contains).

3
SFML projects / Stellar Reaction: Space Combat MOBA
« on: February 05, 2016, 08:36:38 pm »
I have been working on and off this project for over a year, and am now a Senior in Computer Science. I have to work on a nine person team on some project, and got mine approved! Here is a video of the current state of the project. Over the next few months, me and the team will work on this hopefully to completion.

I had to record this video in a hurry and wasn't able to find someone to play with in time. There will be another video showing multiplayer in the future.

Features so far:
Fully functional multiplayer and chat.
Customizable ship.
Money and capture points.
Ship destruction.
Module stats are controlled by json blueprints.
When modules are destroyed, they stop functioning.
Art by a friend.

In addition to SFML:
TGUI
Box2D
jsoncpp

Screenshots:

4
Audio / Many sounds for a game.
« on: February 22, 2015, 02:15:24 am »
I see that the max number of sounds is 256, but in the game i'm making, there are more than 256 things that can make noise. So i'm wondering if my solution would be a good approach:

Have a singleton class that holds around 20-30 sound instances, and also holds all sound buffers for the game.
When an object wants to make noise, that object calls a function on this class with the requested sound name, like Singleton.noise("Explosion1", myPosition). Then the singleton selects a sound instance not being used, sets it's buffer to the explosion1 buffer, and plays the sound at that location.

I don't see anything wrong with my approach, but I don't want to write this just to have it fail because I didn't realize something about the way sfml does things. So thank you for your input  :)

5
Network / Networked vs Local
« on: January 28, 2015, 03:12:24 am »
I am testing a game locally on my computer, by running two-three instances at once and telling them to connect to 127.0.0.1 with the appropriate port, and the game works perfectly. But if I connect over a network, in several instances I have gotten strange behavior, mainly having to do with receiving a packet with random garbage in it (or at least it is not in the format it should be, and gives values that should never have been sent through a packet, such as negative numbers when they are always supposed to be positive, or just too big). This usually results in the client program crashing, but in at least one instance it just received a tiny bit of garbage and carried on. Other than latency, what are the differences between locally connecting vs two computers over a VPN or LAN? Any hints as to what the source of the problem could be?

6
Network / Sending enum through a packet
« on: January 24, 2015, 07:58:07 am »
Is it safe to do this?
Packet packet;
packet << static_cast<int32_t>(Protocol::Control);//Protocol is an enum class
send(packet);
I am trying to send different types of commands through the network, and i'm not sure if this is reliable.

7
Network / Making Sure Special Command Arrived
« on: January 22, 2015, 07:12:33 pm »
In my game, when the Host hits "Launch", it sends data in a udp packet to each of the clients to let them know what level to load, and what entity they are in control of. How can I make sure they received it? Could I just send it several times? Is this where I would want to use TCP? Will packets ever be completely lost, or just delayed/out of order?

8
General / [Solved] Input tied to frame rate.
« on: November 10, 2014, 08:33:34 am »
I have my physics engine, which always updates at 60Hz.
Then I have my Window, which can be a variable FPS with setFrameRate.
As it stands, the game will reach the physics update and do a physics calculation as many times as it needs until it has reached the number of updates expected. (so if you are running at 30 fps, it will update 2 times, 20 fps, 3 times, ect.)
The problem is that player input, and the rest of my game loop, seems to be tied to frame rate. The physics input needs input from the keyboard each update, because if you press UP, you need to accelerate each update. If someone sets their frame rate to 30 fps, the physics engine is still at 60HZ, but now only half of those ticks are getting player input and accelerating the player.

Possible solutions I have thought of:
1. Ideally I can get player input independently of frame rate. This would be great!
2. Force the same rate for everything. This is bad if someones computer just can't keep up. Then that person couldn't play with someone else, cause their game would constantly be behind.
3. Record the players input, and keep it until we get new input, and have each physics tick act on whatever information was recorded. This is better than 2, but not better than 1.

The real problem is I don't understand how sf::event and sf::Keyboard are tied to the window. Do they only get updated each frame, or are they a continuous and independent from it?

9
Graphics / Techniques For Animating
« on: October 27, 2014, 11:24:55 pm »
Note: When I refer to animation, I only refer to the tiled position of the texture coordinates
So I have implemented large portions of my game, including Animation, and some new strange questions have arisen. I have completed my own solutions to these, but there are probably better solutions which is what I'm looking for. So, what are some common ways animation deals with these:

1. Should an animation complete before accepting another animation, or should it drop what it's doing and switch? A setting i'm guessing.
2. Should an animation, when done, repeat or revert to a default state.
3. Should the controlling object be constantly telling the animator device what state it should be in, or should it just send a signal once, and update each time the state switches?

I solved these in my own way, but I wasn't that happy with my choices, and rather than experimenting more, what does a good Animation process look like?

10
Graphics / Everything In Batches?
« on: October 27, 2014, 09:33:14 pm »
Mainly for fun I want to have a large number of square sprites, flying around the screen every which way. That would mean that there would be a graphics card draw call for each one of the sprites right? And this would effectively bottleneck me to a few thousand objects.

I have done stuff with the tilemap and vertex arrays in the past, so I was thinking I could just have these objects have a reference to a tilemap, and these objects can access their sf::Quads from the vertex array when it needs them, to update position and rotation and texture coordinates for animation. Then I would just draw the vertex array with no rotation or position changes. This way, all of these objects that use the same texture, just cause one draw call. I know then I couldn't draw one object before another in this case, but that doesn't matter. Is this a good way to draw a ton of separate squares?

Also, I have the angle of one of these objects, so when I compute the new positions of each vertex, is there any better way to find the 4 positions other than sin() and cos() or a lookup table? I have taken some Linear Algebra, but the only ways I know of don't avoid sin and cos.

11
General / Conflicting Libraries
« on: October 20, 2014, 09:28:23 pm »
I am working on a game that can be compiled on my machine, and run on most windows machine as long as you provide the .dll's with it.
I have been trying to get it to compile on my friends computer

The libraries we are using are:
Box2D
SFML
TGUI
JSONCPP

(These are the same steps that I did on my computer):
A friend wanted to join me, so we downloaded the source for each lib on his machine.
Built each set of libraries using CMake, release-shared, and debug-shared.
Tried to compile the project.
It compiles, but when it tries to run it crashes with one of two problems

1. If we don't include libgcc_s_sjlj-1.dll with the exe on his computer, the program crashes in the sfml graphics library (as indicated by the debugger).

2. If we try the libgcc_s_dw2-1.dll with the exe (instead of sjlj), the same crash happens as #1

3. If we include libgcc_s_sjlj-1.dll we get this:
The procedure entry point __gxx_personality_v0 could not be located in
the dynamic link library
(directory to the bin folder)\libBox2D.dll
I have seen this exact error before, but with libstdc++6, and that was due to not having the libstdc++6.dll built with the right exception model (DW2 vs SJLJ). Does anyone have any insight into why this would happen?

Other Details:
In C:\Program Files (x86)\CodeBlocks\MinGW\bin MY computer has libgcc_s_dw2-2.dll AND libgcc_s_sjlj-1.dll, where as HIS computer only has libgcc_s_dw2-1.dll

On my computer, the program requires the extra libraries (ones not created by the 4 I listed):
libgcc_s_sjlj-1.dll
libstdc++-6.dll
libsndfile-1.dll
openal32.dll
(Do I need to rebuild these also?)

We compiled and ran test code for Box2D and SFML separately. Both worked. So this isn't directly Box2D's or SFML's fault. Is there a way I can see which libraries are DW2 vs SJLJ? I'm confused as to how they could be different considering they were all built on his computer, but I was hoping to get some insight into how to fix this.

12
General / SFML_USE_STATIC_STD_LIBS
« on: October 08, 2014, 08:52:40 am »
I am using Code::Blocks MinGW, and I want to better understand what the implications are of enabling that command when generating my libraries.

Here is my understanding, please correct it, and hopefully add to my understanding.  :)

Dynamic Linking SFML
The option is not valid for this choice, so it is off.
If I link SFML dynamically, I will need libgcc_s_xxx-1.dll and or libstdc++-6.dll. But I just ran a simple test program and did not need either of those. Under what circumstances DO i need them when doing everything dynamically. Certain function calls/class instantiations?

Static Linking SFML
I turn the option off, so I am NOT statically linking the std libs.
If I link SFML statically, I will need libgcc_s_xxx-1.dll and or libstdc++-6.dll. But I just ran a simple test again, and did not need either of those while linking SFML statically. Under what circumstances DO i need them when doing SFML statically, but std non static. Are those conditions the same as Dynamic Linking SFML?

Extra Static Linking SFML
I turn the option on.
I link SFML statically, and tell those SFML libs that I will be linking the STD libs statically. But I just ran a simple test again, and did not link either of the std libs in the project, and it worked. Do I need to link them in the same conditions as the previous two?
In the situations where I do need to link them statically, do I need the libs from the SFML\SFML-2.1\extlibs\libs-mingw\x86 directory? My computer is x86. Which libraries would I need to link? All of them?


openal32 and libsndfile have .a and .dll versions. Is .a the static library version that I can link statically?
"If you are using the sfml-audio module (either statically or dynamically), you must also copy the DLLs of the external libraries needed by it, which are libsndfile-1.dll and OpenAL32.dll"
Everything could be linked statically, but I would still need these two dll files?

Thanks ;)

13
General / Larger Resolutions Give Players Advantages
« on: August 29, 2014, 11:06:41 pm »
In a multiplayer game, if one person has a larger resolution screen, and the game is being displayed in a Viewport with no zoom, then the player with the higher resolution can see more of the game world.
This has the potential to be unfair to players with lower resolutions.

The other problem that comes up is that monitors can have different aspect ratios, so it isn't just a simple matter of zooming one view or the other.

This would seem like a common issue in gaming. What are some good/popular resolutions to this problem?

Ideas I have had:
1. Zoom player views so they can all see approximately the same area of world.
Issue is that zooming views distorts the number of pixels a sprite SHOULD be taking up, so maybe a 256x256 sprite only takes up 200x200, or 400x400 pixels, depending on the zoom number. This looks weird.

2. Lock the Aspect Ratios and resolution by putting black space on top or bottom of screen so it is sized correctly.
Issue is that this would be really annoying to people who have nice monitors and can't use them. Plus, then I have to dictate the lowest common denominator of monitor. That would be stupid.

3. Decide on a max X and Y resolution, like 1920x1080, and anything above this gets black space to fit. AND Players have the option of deciding their viewport, so a player with a 800x640 screen (lol) could choose to display UP TO the 1920x1080 world viewing max. Then, they could decide whether they really cared about the advantage in viewing area, or the distortion caused by it. But I would allow them to type in their chosen viewport size, so this person would probably want to choose 1600x1280 to keep with their aspect ratio.

14
Graphics / Motion Blur with Shaders
« on: August 13, 2014, 05:55:21 am »
Here is my project in executable form in case you want to see it for yourself. It comes with a readme. The only shader that is used is test.frag, ignore the others. There are several main ways of implementing motion blur. I want to get one of them to work well. Right now, i'm looking at this method:

Blur the Texture for each object you draw.

I was going to post about the other method, but this post was getting too long, and I should address them one at a time.

Current Problems:
1. The blur effect cannot extend past the edge of the fragment/vertices/spritebox. Bounded Note that I would never need it to extend that far, it is just used to make the problem more apparent.
2. There is a strange coloration effect around some edges. Out of Game: Broken vs Normal In Game:Broken vs Normal
3. There is something wrong with the way the textures are being blurred, causing loss of color. BlendMode???

My Thoughts/Possible Solutions:
1a. Make the texture have a large amount of transparent space around it, and the sprite as large as it needs to be to extend the edge of it to allow blur to occur farther out. I don't like this because then I would have to add tons of transparent space between the tiles in a sprite sheet.
1b. I could draw the image onto a larger sprite that is only transparency. Then blur that, and then draw that. I tried this, but I was running into stranger problems. I will address this more if you think this looks like a good solution.
1c. Somehow use vertex Shaders (something I don't understand yet) to mess with the geometry of the fragment, and allow it to be enlarged, but still keep the texture the same size, and in the middle.
2. I have no idea why this is happening. The only way I was able to provide that messed up image was that I opened the image in Windows Media Player by accident with some sort of accidental keystroke (crazy coincidence), and you can see what it looks like there.
3. Is this caused by the blending mode? Notice the only place there is color is where ALL the skewed images overlap. Everywhere else there is no color.

Here is the fragment shader. test.frag The values added here are just so you can add it to a project to get an idea of what it looks like without having to use Shader::setParameter();
uniform sampler2D texture;

uniform vec2 velocity =(10,0);//the direction of travel and magnitude
uniform int samples = 2;//how many times should we create the effect(should be an even number)
uniform float strength = 0.1;//how intense should the effect be? 0.1 is large, just for testing
uniform float angle = 0;

void main()
{
        vec4 pixel = vec4(0,0,0,0);
        vec2 copy = velocity;

        copy.x = cos(-angle)*copy.x + sin(-angle)*copy.y;
        copy.y = -sin(-angle)*copy.x + cos(-angle)*copy.y;
 
        vec2 offset = vec2(copy.x*strength, -copy.y*strength);
        offset /= samples;//we divide so that by the time we have
       
        for(float i = 0; i < samples; ++i)//compute that many samples
        {
                pixel += texture2D(texture, gl_TexCoord[0].xy + offset*i);
                pixel += texture2D(texture, gl_TexCoord[0].xy - offset*i);
        }
        gl_FragColor = gl_Color*pixel/float(samples*2);
}

15
General / Strange bug with drawing sprites.
« on: August 10, 2014, 06:25:21 am »
I am getting a strange bug when I try and display sprites. It is 100% my fault somewhere in my code, and I have been trying to narrow it down. I'm just asking for more ways to narrow it down. I have a loop that loops over this line:
rWindow.draw( (**it_comp).getSprite() );

1. There are a total of 7 sprites, and I confirmed that the loop is calling that function 7 times, so it is definitely attempting to draw the sprites.
2. I have also confirmed that the 7 sprites all have acceptable values for these:
 color
 position
 texturerect
 scale
3. Because of position, I can look right at the spot the sprite should be, but it is not there. What other values of the sprites could I check to see if they are causing them to be invisible?
4. I know it's not hiding behind other sprites. Unless it can hide behind the background fill color of the window.


More detailed explanation(but not necessary to answer above question):
1. The bug disappears when I use a debugger (not my question): http://stackoverflow.com/questions/7112436/c-vs-2010-bugs-occur-only-when-running-without-a-debugger
2. The bug occurs somewhat randomly to certain sprites.
3. The bug only occurs if I initialize a new graphics component in a somewhat strange way, but that shouldn't be causing any problems.
4. Because the debugger never gives a warning(it does If i have seg faults or bad memory) I know it's not some sort of pointer problem (right?)

I have a graphics component factory which holds graphics components. Each graphics component holds a sprite. There is a loop that loops over these graphics components, gets a const reference to the sprite, and as you can see, uses the window to draw it.
The view never changes, and I have checked those 4 values for strange readings and they all come back normal. I'm not sure what else to check.

Pages: [1] 2
anything