# Dawoodoz

Member

550

1. ## Is it worth it for me to try to use a physics engine?

The best is to convert your level geometry into a set of convex polyhedrons using a convex decomposition algorithm (for items) or construct solid geometry from boolean geometry operations (typical level design). Let each plane shrink along it's normal to compensate for the tolerance radius being added to convex hulls in Bullet. Thin faces will cause small items under pressure to penetrate the surface or get stuck inside. Height maps in Bullet are using thin surfaces, but in that case you can force the center of each tiny item to be kept above the ground level by sampling the height yourself.
2. ## Is it worth it for me to try to use a physics engine?

You'll usually not use faces, because they have no volume, but that's essentially the idea. Just a set of functions responding to how shapes interact. If it doesn't fit your exact needs, you can always copy the source code and modify using class inheritance.
3. ## Is it worth it for me to try to use a physics engine?

The Bullet physics engine can be used as a collision detection library directly. Unless you're making a strategy game, I wouldn't worry about the performance cost of using the whole engine, but there are many benefits to writing custom physics for each game. It's what makes the gameplay feel truly unique compared to generic games. A simple start for learning the basics of game physics would be a non-rotating capsule actor on a height map with voxel buildings. Get the mid-point position for collision detection by adding half a fixed step of velocity movement on the current position. This will represent the average position during the journey from start to end of the step to remain stable. Heightmaps can get away with just a few height interpolations along the feet and an obstacle map telling where it's impossible to climb. A capsule against a box without rotation can be simplified as a sphere colliding with a higher box. A sphere against a box finds the contact point by clamping the center of the sphere to within the box and comparing the distance with the sphere radius. Then you combine the contact points from multiple boxes and reduce the ones that are too close in angle. Then apply some of the impact to the velocity and some directly to the position as spill energy. Apply the physics in fixed steps for determinism and interpolate linearly using position and velocity to get the displayed location. When walking with legs, make sure to adjust the relative velocity within the friction to adjust for walking motion. You don't want to feel like you're dragged against the floor pulled by a rocket. More advanced collision detection can use convex decomposition into convex polyhedrons. A convex polyhedron is defined as a set of infinite planes cutting away matter from an infinite initial set. The direction of each plane can be represented using exact integers by not forcing it to length one.

5. ## 3d Physics Engine for DirectX 11 C++ Application

I also use Bullet for my engine, because it's free and relatively easy to integrate without any dynamic linking, just a bit of a header mess when you include internal things for modification, but that's more to blame on C++ legacy. Bullet is not as soft as Newton, but it's required to use continuous collision detection and catch small fast objects. I only use rigid collisions when the car hits something on the metal, because I implemented my own Stribeck friction model for wheels.
6. ## Blend pixel data without leaking memory

Is there a way to blend pixels directly to Raster in a BufferedImage with custom blending using own pixel loops instead of cloning the source pixels with getDataElements? I tried inheriting from Composite and CompositeContext but the permanent memory leak causes crashes when the memory runs out. I need custom blending for light effects so AlphaComposite is not enough for my project. In the worst case, I just make my own image type using arrays as I usually do in C.
7. ## Blend pixel data without leaking memory

It seems like Java is leaking because it creates an intermediate image for interpolation so when I first draw to an image that I recycle myself using AlphaComposite.Src and drawRenderedImage, I can then use my custom composite in a 1:1 scale ratio without leaking memory. The wasted time is acceptable because the operation is only performed when the level is loaded.
8. ## Building jar with resources without IDE

I have created a manifest file for my desktop Java game that is used to create a jar file automatically from my shell script and now I need to add resources into the jar file.  :) Is there a simple way to specify a folder in the manifest file without depending on additional tools? All guides point to the obvious way to just point and click in Netbeans but I want to know how the build process works so that I can fix things when they break using only the JDK tools. Shell script for building the jar: chmod +x ./compile.sh ./compile.sh cp ./manifest.txt ./../output (cd ./../output; jar cfm Game.jar manifest.txt * chmod +x ./Game.jar java -jar Game.jar ./../source/media/ )  I am currently giving the path of the media folder as a command line argument since it might be useful later for mods. The manifest only contains the main class name for now and I haven't figured out a good namespace for Main yet. Main-Class: Main
9. ## Building jar with resources without IDE

chmod +x ./compile.sh ./compile.sh cp ./MANIFEST.MF ./../output (cd ./../output; jar cfm Game.jar MANIFEST.MF * ./../source/resources/*.png chmod +x ./Game.jar java -jar Game.jar ./../source/media/ ) Thanks! Seems to work now after just adding the resource files in the jar command. :)   BufferedImage image = null; try { image = ImageIO.read(new File(this.externalMediaPath + fileName)); } catch(IOException e) { try { image = ImageIO.read(Class.class.getResourceAsStream("/source/resources/" + fileName)); } catch(IOException f) { f.printStackTrace(); System.out.println("Image not found at " + fileName + "!"); return -1; } } When the selected mod folder does not contain the image, it will now fall back on the built in resources. I should probably check if the files exist before trying to load from one location at a time but I can fix that later.
10. ## Need an article/info/study/algorithm/idea about managing economic resources for a real time game like The Settlers

University courses in AI teaches many methods to solve factory production problems so you can find it in most course books about AI. You might want to separate the AI into multiple systems doing their own things before you complicate it further. * Diplomacy (When to start a war) * Warfare (Who to attack when at war) * Resources (How to reach the number of wanted soldiers) Each state of a resource has a counter and a whole set of those make a world state. Rather than storing a list of hammers with different properties, you have a counter for each possible combination of properties that matters to the AI. NumberOfBrokenHammers, NumberOfNewHammers... Each action consumes or borrows resources/workers, takes a certain time to complete and produces resources/workers/buildings when completed. In each tick of the production schedule, calculate a number of possible scenarios with simplified game logic a few minutes into the future and use heuristics on the final results to estimate a score based on available resources. Remember the best solution for the next tick and refine it by consuming the time that passed and filling with new random guesses at the end. Each random guess may use as much as they want from the previously optimal plan but may only randomize the plan after the point of change since reuse of actions after a change makes no sense. Within a random walk, add random actions until no more actions can be added, step over time to let actions in the list be completed and return the investments. The generation of random actions should be constrained by a primitive reflex system that prevents doing things that can easily be proven to be suboptimal like not producing wood when the stockpile is full. This is inspired by the Monte Carlo method that is easy to implement as long as you keep things simple. https://en.wikipedia.org/wiki/Monte_Carlo_method
11. ## Getting back into C++

JetBrains CLion is an IDE for C++ that works directly on Linux and other systems. I use it at work and do not miss being limited to Windows. It has free student/hobby licenses but you have to renew them yearly and there is no express version. Since it builds on CMake, you can just keep programming with another editor if the free license runs out or if you just don't want to subscribe anymore. + Intuitive debugger. + Built in static analysis. - The settings are overly complex since it is still in development. - Editing text may feel weird until you configure it right.
12. ## Making games on Linux that regular people can actually install?

I will just stick to Java then and live without userdefined value types. Regarding OpenGL, it is a work damage from having seen it malfunction hundreds of times in the real world. Lobotomy might cure me from what I have seen buggy OpenGL drivers do to correct code. My daytime job as a firmware developer for hardware producers is mostly to go around bugs in OpenGL drivers so I would prefer not to deal with that when I get home. Even if I would test my games on 20 different OpenGL drivers which is beyond my budget, the next driver version would still break anything slightly complex and require further maintenance. I guarantee you that all your OpenGL games are broken on some driver even if you manage to follow convention to 100%.
13. ## Making games on Linux that regular people can actually install?

I don't need a huge pile of fancy features that I can easily write myself. I just need something minimal that works for retro graphics. I am prepared to use some kind of OpenCL wrapper from Java or write my own software 3D renderer from scratch in C++14 to get rid of as many bad dependencies as possible. Both SDL and SFML may randomly crash during install because of broken dependencies on Ubuntu. I cannot expect the end user to compile dependencies from source or fix broken OpenGL drivers in Linux which is the current praxis for Linux installations. I do not trust OpenGL nor anything built on top of OpenGL because it is not a real standard when there is no driver certification. Vulkan is not ready yet as the drivers are few and buggy.   Is there any other platform than Java that has decent performance and can be installed easily on Linux?
14. ## Seamless map Integration

You can optimize 3D graphics by dividing the world into one model per 20x20 meter tile. All static items in the same tile have their triangles merged into the tile model. This reduces the number of draw calls when you have thousands of low detailed static items. The tiles are also useful for distance culling by not drawing distant tiles. Do not try to shift the world coordinates according to the screen since it will make it hard to refer to places in the AI. Define one system for the world and write conversion functions between world and screen space. If something changes in the tile model, delete it and show the separate instances to trade render speed for rebuild speed until changes are done and a new model has been generated for the tile. This system can allow fluent high resolution voxel carving in .NET when compressing the voxels in each tile using axis aligned integer boxes. If using sprites in 2D, the same can be done with multiple layers of image buffers or depth buffers in each tile. When a static sprite changes, redraw the affected tile images. If adding sprites on top, just keep drawing on the tiles.
15. ## SDL2 and Box2D Nothing Shows Up

I would try to assert that the ground is where it is expected to be by visualizing and making ray intersections. If you can make primitive line drawing of the physical world for debugging then it can help a lot when figuring these things out. A lot of physics engines provide some kind of line drawing callback to visualize with any graphics engine.
16. ## SDL2 and Box2D Nothing Shows Up

Maybe your should start with SDL and get some basic movement working before using a physics engine. Using a physics engine require lots of understanding in order to integrate the game logic in a fluent way so trying to make your own physics first will give you a better understanding of what the engine does by stepping in a debugger or even calculating examples on paper. Reading about euler forward and midpoint is a good start. I do not see any code for either dynamic timestep nor interpolated fixed timesteps. You can make a button that slows everything down with a delay or heavy calculation to see what happens when your game scales up or someone plays it on a slower computer. The easy way is to run the physics 300 steps per second and run as many as required for the time spent rendering one frame and save the remainder time accumulated for the next frame. All physics and game logic can then run the same way independent of rendering speed. Everything that is just visual and can be directly derived from the world state (animations, GUI,...) should be updated as needed before rendering to avoid getting more fixed amount of workload than the computer can handle.
17. ## whats the simplest game I could make with the easiest engine?

I agree with pong being simplest. After that, it can be extended to a block busting game.   Javas built in 2D graphics can be used for retro strategy games and has no hassle with linking or cross compiling. The libraries that are native to a language usually have a longer lifetime before it has to be ported or maintained. I can still play the games that I made for Windows 3.1 because I only used the default components in Visual Basic. Newer games with advanced stuff did not survive from Windows2K to XP or Windows7 to 8 before I had to fix new bugs. It sounds a bit boring but the first games made is like the first drawings that you will want to play 50 years later.
18. ## Is there any reason to use SDL2?

Arguably is a key word in that sentence.  Arguably, libSDL2 is easier to use, so you qualify for only a vague response on that. libSDL2 is still useful, because it's widely used, well known, has plenty of tutorials and example code, and it works well.  It's easily available on all popular desktop platforms, mobile devices, and consoles (which is certainly not true of GLFW and SFML) including modern display servers on Linux (also not true of GLFW and SFML, and they have no plans to port to Wayland or Mir), and supports GL and GL|ES contexts and Vulkan is in the pipe.  libSDL2 is also actively maintained full time by its original developers and is a commercial product with corporate backing, not a hobby project at the whim of some individuals' spare time. libSDL2 does not need to hijack main.  On Microsoft Windows a wrapper for main() is provided as a convenience since neither WinMain() nor _tmain() are portable or standard, but there's nothing from stopping you from implementing the necessary stuff in your own Windows-specific main() code if portability is not your concern.     Well, that's a property of your Linux distribution.  I work with libSDL2 all the time (on Ubuntu), and members of my team are regular upstream contributors so I test their work, and I have never had difficulty installing it or crashes related to dependencies.  I would not use a broken Linux package management system as a criticism of an upstream package.     The player who buys a game for Linux does not care whos fault it is, the game will be blamed if it does not go around the bugs in the system. It either works from the start or leads to a refund.
19. ## Is there any reason to use SDL2?

SDL2 is for those that otherwise would write their own window frameworks just to lower the overhead. It does not do much abstraction since many things behave differently on different computers. The only thing I really dislike about SDL2 is the broken Linux installation system that will always crash with dependency problems if you installed any program before SDL and that is something that end users who dont know programming has to live with.
20. ## Why do you use Linux for dev over Windows?

Last time I developed something on Windows, I got screwed by a hidden c++ dependency (MFC activeX) that could only be compiled on visual studio professional that I was trying for free as a student. Then Windows 10 came with built in spyware and tried to replace my installation of Windows 7 against my will with a UI nightmare. Now Microsoft has fired lots of people that used to fix their bugs so the system will slowly become more unsafe and unstable. I cannot develop another product that is tied up to a system that microsoft has on life support and spies on the users.   Now I try to develop games on Linux which means that OpenGL is a new dialect on each computer even if they have the same linux distro. I tried Vulkan but it was too verbose and everything was specialized for certain GPU models. I am desperate enough to write a software rasterizer since OpenGL cannot even draw a quad straight without weird half pixel offsets that depend on how broken the drivers are. I have not played any game since I abandoned Windows since all the linux games on GoG have broken installations with missing dependencies.
21. ## Commercial vs. "Other" Engine Productivity for a Single Developer

Big engine - "You are not a big enough customer to get support about the missing documentation." Free engine - "Don't bitch if it's free!" Write your own - "What was it that I was supposed to do now that the engine is done?"   Pick your poison. :)
22. ## How to find niche on Google Play Store?

Since even the top 10 most played Android games usually have spyware, count on being treated with the same suspicion as white painted russian tanks near the white house.   This is even worse for the Windows store since they would end up with an empty store if they removed all the malware. http://www.howtogeek.com/194993/the-windows-store-is-a-cesspool-of-scams-why-doesnt-microsoft-care/
23. ## SSAO slow when geometry is near camera

Cache misses are not a concern on the GPU as long as it fits into VRAM since the GPU has very good memory bandwidth made to sample textures. Where the texture is sampled does not matter to performance as long as they are not random noise causing anisotropic filtering to peak at maximum samples. It is likely that you are doing the advanced calculation in a too high resolution or using a sampler state that does unwanted interpolation, mipmap blending or anisotropic filtering that is not really needed. Most post effects are done in a low resolution and then merged into the final image while upscaling the result because per pixel calculations are expensive. You may get some ugly artifacts along the edges from upscaling that has to be covered with some extra post processing to avoid using an ambient occlusion intensity from a far away depth.
24. ## Stepping through a height map to find intersection

A cache miss from storing 32 bit floats would be much worse than some cycles spent on unpacking and if you solve the puzzle well, you might get an advantage from using small types in your calculations. On ARM NEON, the math operations would be easier to distribute on more lanes but SSE has the advanced memory loads that you can take advantage of.
25. ## Framebuffer is black while trying to write depth value to it

The fragment shader returns black "vec4(0, 0, 0, 1.0f)" so it might be hard to see the result. Try displaying a green color and then sample a texture or show the vertex colors. Clearing the target color to blue while clearing the depth buffer usually makes it easier to debug when everything you see is black.