Stephen Andrews Posted November 26, 2014 Share Posted November 26, 2014 CEWBS - Fast Voxels in MotionGithub/Download: https://github.com/TriBlade9/CEWBSDemo: http://triblade9.wc.lt/CEWBS [Middle-click: grab/release mouse (Click in the center), F: fly/walk, Left-click: break voxel, Right-click: place voxel]CEWBS is a MIT-Licensed library for BabylonJS which provides a VoxelMesh object for creating optimized (greedy) voxel meshes.It currently provides methods to create, update, poll, color, and pick voxels. (See README.md) The goal is to separate voxel meshes from the world 'grid' by allowing them to be rotated, scaled, moved, affected by collisions, physics, and generally treated as normal meshes. while still letting them be manipulated and accessed easily. (In the demo, the voxel mesh you are standing on is rotating, along with it's children.) The speed of the mesher is such that you can create a fast animation (Changing the blocks every frame) in a 16x16x16 mesh with almost no impact on FPS. (Demonstrated in the demo) Textures, Ambient Occlusion, and per-voxel lighting are currently not supported due to the difficulty of implementing them alongside the meshers. Feel free to help out with those. Projects Using CEWBS:None, yet. Enjoy! Sorry for the rushed post, I'll flesh it out more later. Xeonzinc 1 Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted November 26, 2014 Author Share Posted November 26, 2014 Update 0.2.1:Added utility functions to convert from Hex to RGB and back (Useful for using colors as ids)Added Zoxel importing and exportingBegan working on proper examples Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 27, 2014 Share Posted November 27, 2014 That kicks ass!!!! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 27, 2014 Share Posted November 27, 2014 Are you interested in being part of babylon.js extensions? (or even better add it to the core?) Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted November 27, 2014 Author Share Posted November 27, 2014 Are you interested in being part of babylon.js extensions? (or even better add it to the core?)Glad you like it! Perhaps it would fit as part of BabylonJS extensions, but not part of the core. I don't use/know how to use TypeScript, and the code quality is admittedly terrible, though that will change in the future once everything is nailed down. EDIT: Update 0.2.2:Removed monotone mesher, as it is generally slower and too complex for the slight benefits it gives. (Especially with more vertices available for use now in BabylonJS.)Added (buggy) support for non-integer types as voxel ids. Arrays (so long as they don't contain objects), Strings, and Integers work for now. This may be reverted if it affects performance too much. This is buggy (and slower for non-ints) because Arrays and Strings are converted to Integers for a necessarry part of the comparison process, which may result in them accidentally becoming equal.Should the method above not be decent for comparison, then a more reliable way would be to use an id to compare voxel types, while adding an extra argument for additional metadata. (Any type.) GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted November 28, 2014 Author Share Posted November 28, 2014 Update 0.2.3:Reverted non-integer types change and added support for custom metadata in a separate argument, from which a numerical id can be inferred. This is probably the best way to go about it.Added partial support for transparency, colors can either be a 3-length array of RGB values, or a 4-length array of RGBA values. Mesh must have the hasVertexAlpha property set to true. (Transparency is not meshed differently yet, so it still clips through the mesh)Added a few utility functions.Zoxel importer-exporter now has support for transparency. Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted December 1, 2014 Author Share Posted December 1, 2014 Update 0.2.4:Minor changes to Zoxel import.Supports voxel transparency properly (through use of a custom evaluateFunction), except for a bug in BabylonJS itself. (So far as I can tell anyways)Example #1 is kind of usable, though quite buggy.Update 0.2.42:Proper transparency now, using a child mesh. evaluateFunction fixed.Example #1 now has transparency and shouldn't break every few times loading it. Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted March 17, 2015 Author Share Posted March 17, 2015 Update 0.2.5:Compute normals in the meshing function as suggested by fenomasSlightly speed up position calculation by using a flat array instead of an array of arrays. Quote Link to comment Share on other sites More sharing options...
fenomas Posted March 17, 2015 Share Posted March 17, 2015 Slightly speed up position calculation by using a flat array instead of an array of arrays. Hey, if you ever do more with this, consider using a library called ndarray, gettable from npm. It simulates an n-dimensional array using a flat array underneath, and lets you easily get dynamic views into the data (a transposed version, say) without the data changing. There's also a bunch of ops libraries for doing stuff to the contents of an ndarray (filling, sorting, etc.) while minimizing cache misses. Stephen Andrews 1 Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted March 17, 2015 Author Share Posted March 17, 2015 Hey, if you ever do more with this, consider using a library called ndarray, gettable from npm. It simulates an n-dimensional array using a flat array underneath, and lets you easily get dynamic views into the data (a transposed version, say) without the data changing. There's also a bunch of ops libraries for doing stuff to the contents of an ndarray (filling, sorting, etc.) while minimizing cache misses.I've looked into it, but for some reason it never really caught on for me. I might try using a modified version of your mesher in the next version btw, AO would be quite nice. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.