Code Monkey home page Code Monkey logo

voxeliq's Introduction

voxeliq Build status

voxeliq is an open source block-based game engine implementation developed with C#. It uses XNA or the Monogame as the basis. It can be compiled with Microsoft .NET or Mono, which means you can run it on Windows, MacOS, and Linux. Please see the file LICENSE for licensing details.

Code

The last working version resides in contrib/old-codebase

Why?

We would like to develop an open-source and 100% moddable blocky-game which will run on any platform that Mono can. Though we are still far away from being complete which means you are more then welcome to contribute!

Retake?

The project initially started as a hack & slash project and growth un-intendedly. The old-code was quite un-maintainable and buggy (the famous meshing bug!)

  • We decided to re-code it from strach with clean comments and tests for all major functionality.
  • Dropped support for XNA, the new version will be just use MonoGame as it was quite hard to maintain all platforms together.
  • The old code resides in contrib/old-codebase.

Stay awhile and listen

  • Read the FAQ and check the wiki before asking!

Screenshots

Screenshot Screenshot

voxeliq's People

Contributors

bonesoul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voxeliq's Issues

Block picking is offset

pickingOffset1
pickingOffset2

As you can see in the images I have attached your picking is not quite accurate. I haven't dug into the code yet so I can't suggest a fix at the moment.

MOD Support

As suggested by Delwin9999#7, the engine needs mod support.

  • All the interfaces and subsystems provided by the engine should be overridable which will probably require huge refactoring.

RenderAimedBlock BlendState changed

bug2
After render AimedBlock, BlendState has changed to BlendState.NonPremultiplied
that made incorrect to other Draw method
way to solved this issue is keep old state and restore before end this method.

Engine is a singleton without the protections thereof.

Engine has the private static _instance attribute and assignment to this of a singleton but the constructor is public. This means someone could instantiate it twice thinking they'd get the same instance (as you would with a real singleton) but in fact they'd overwrite the first one's _instance with the second one and the game state would be unrecoverable.

This should be a real singleton pattern. The only reason it isn't right now is that the unit tests fail when I tried to do the conversion on my branch. When I become more familiar with the unit test harness I will be able to untangle that and I can throw a pull request for the fix at you.

development tool details

http://create.msdn.com/en-US/education/catalog/utility/graphics_profile_checker

The XNA Framework GraphicsAdapter.IsProfileSupported API enables you to check whether the current hardware supports the Reach or HiDef graphics profiles, but this only returns a simple boolean, with no details of why a failing profile isn't supported.

This utility provides more information about hardware capabilities, by performing the same checks that are used internally by the XNA Framework and by displaying their results as a detailed failure report. This can be useful for investigating driver compatibility problems, and also to see exactly what hardware capabilities are required for each profile.

Unlike most XNA samples, which are written in C#, this utility is written in C++/CLI (the .NET version of C++). This allows it to call directly into the native Direct3D API, thus obtaining more detailed caps information than is available through the XNA Framework graphics API. You'll need to install three things before you can build this utility:

Fix the engine architecture

We have major issues in engine architecture.

  • Delwin9999#3 - Entire architecture is tightly coupled. Decouple it
  • #46 - Engine itself should be free of Camera and Player.
  • #43 - Engine is a singleton without the protections thereof.

Content Tools

Idea originally by Delwin9999#15;

  • tools to create new inventory items
  • tools to create new block types simply
  • particle system generation tools (effects)

For sure we need to work out the block-system to allow game itself to define them. Inventory and particle system needs to worked from scratch.

Refactor out the Logger configuration.

As this isn't any kind of server-like software, I don't think we need configurable loggers. So I'll be refactoring out logger configuration functionality -- and will bind the console and file log will be just statically.

Engine itself should be free of Camera and Player.

As of right now, these exist in the Engine code itself but it should be free of them and Camera related the values should be provided by the game itself as configuration to Engine. So that anyone could just use it for FPS, RTS or some other kind of game.

Camera issues;

Player issues;

  • Delwin9999#4 - Find aimed block is not finding the most intuitive choice for a block.
  • #72 - Block picking is offset

Fix/Improve Chunk Mesh Building

Voxeliq currently uses an advanced optimization to improve rendering performance, in simple worlds while building the mesh for a chunk, instead of building the complete mesh for the chunk, it only builds it partially (basically it doesn't include blocks in the mesh where user can't seem them).

Check this graphic;
chunk-meshes

So lets say that a chunk may had landscape generated around y=50 ~ y=55.

  • So with out the optimization, the mesh would contain all the blocks from y=0 to to y=55
  • which means more blocks in the mesh = more polygons in the mesh = lower rendering performance.

So the ideas is that, user will not able to see blocks below the lowest-solid-block-index(y) in chunk.

chunk-meshes

As in the screenshot above, users will not be able to see blocks below the [chunk's lowest block index - 1](marked with purple).

And the optimization arrives here, where we only build the mesh between [chunks highest block index + 1] to [chunks lowest block index -1].

This optimization is all good and improves the rendering performance a lot but with a given drawback; with every set-block operation, chunk's highest block index and lowest block index values have to be updated.

In the current state of the engine, this is done in landscape-generation after every block-set operation;

air (empty) blocks
                    BlockStorage.Blocks[offset + y] = new Block(BlockType.None);
                    if (chunk.LowestEmptyBlockOffset > y) chunk.LowestEmptyBlockOffset = (byte)y;

---
(solid blocks)
                    BlockStorage.Blocks[offset + y] = new Block(BlockType.Dirt);
                    if (y > chunk.HighestSolidBlockOffset) chunk.HighestSolidBlockOffset = (byte)y;

The problem is that this is an engine and forcing game-developers for so, will increase the entry barrier of engine higher and will make things complex.

A solution is that using the available SetBlock methods which can find the chunk block belongs to and do the calculation on it's own.

        public static void SetBlockAt(int x, int y, int z, Block block)

The problem is that setting blocks in a block-engine is an operation used millions of times. The current method we use in first code snippet is automatic (or close enough being atomic at least in our context - as it just sets a byte value in our Flatten Block Storage array).

The latter solution in second snippet means calling that SetBlockAt() functions over and over millions of times, which for sure will decrease the performance a lot - here's a proof of concept test; http://www.dotnetperls.com/inline-optimization

So I've been looking for possible solutions and here's what I've came up with;

Statement Lamdas
As I've discussed it here and they maybe a solution but I'm not sure yet, will check it further & profile.

Conventional way:
-----------------
L_0000: nop 
L_0001: ldarg.0 
L_0002: ldarg.1 
L_0003: ldarg.2 
L_0004: ldarg.3 
L_0005: call int32 VolumetricStudios.VoxeliqGame.Chunks.BlockCache::BlockIndexByRelativePosition(class VolumetricStudios.VoxeliqGame.Chunks.Chunk,
 uint8, uint8, uint8)

Statement Lambdas:
------------------
L_0000: nop 
L_0001: ldsfld class [mscorlib]System.Func5<class VolumetricStudios.VoxeliqGame.Chunks.Chunk, uint8, uint8, uint8,
 int32> VolumetricStudios.VoxeliqGame.Chunks.BlockCache::BlockIndexByRelativePosition3
L_0006: ldarg.0 
L_0007: ldarg.1 
L_0008: ldarg.2 
L_0009: ldarg.3 
L_000a: callvirt instance !4 [mscorlib]System.Func`5<class VolumetricStudios.VoxeliqGame.Chunks.Chunk, uint8, uint8, uint8, int32>::Invoke(!0, !1, !2, !3)

The second solution is MethodImplOptions.AggressiveInlining that was introduced with .net framework 4.5. But I'm not sure if we'll be able to change our engine projects framework version to 4.5. Will also try that.

I'm looking for other possible solutions.

Interesting reads on the topic;

Networking Support

We need networking support as suggested by Delwin9999#10 and a server project which I've some ideas;

  • We could use a service based implementation just as in Diablo III with google protocol buffers and bit-buffer based packets for ingame-data.
  • Run-lenght encoding and diffing chunk blocks is another good idea.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.