Jump to content
  • Advertisement

Dawoodoz

Member
  • Content Count

    550
  • Joined

  • Last visited

Community Reputation

466 Neutral

About Dawoodoz

  • Rank
    Advanced Member

Personal Information

  1. 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. 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. 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.
  4. Dawoodoz

    Help choosing an engine

    If you're ready to learn advanced C++ with XLib/WinApi/SDL/SFML, then consider writing your own software rasterization using portable SIMD vectors and multi-threading, to increase performance by a factor of up to 112 times on OctaCore CPUs (16 SIMD lanes * (8 cores - 1)), unless you're doing something simple being bound by cache speeds. It's actually fun once you have templates for creating your own CPU shaders without any GPU limitations to deal with. If you're shooting yourself in the foot using pointers, then replace pointers with a template class that has the same operations but with debug time bound checks, to get helpful error messages instead of a mysterious crash. Hard sprites can be drawn using memcpy one row at a time using pre-stored start-end line intervals for each sprite. It will be more than enough performance for realtime 1080p resolution and your game logic. If you want nice graphics instead of a high resolution, you can pre-bake highly detailed isometric 2D tiles with diffuse, depth and normal maps and have realtime 3D light using deferred rendering. Your game will work on Linux even when when the user didn't bother to install GPU drivers, but don't count on getting full screen in Linux no matter what the framework promises.
  5. 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. 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.
  7. 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.
  8. 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.
  9. 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
  10. Dawoodoz

    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.
  11. 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
  12. 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. Dawoodoz

    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.
  14. Dawoodoz

    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.
  15. Dawoodoz

    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.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!