Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research howto implement voxels collisions demo #122

Open
acs opened this issue Jul 15, 2020 · 11 comments
Open

Research howto implement voxels collisions demo #122

acs opened this issue Jul 15, 2020 · 11 comments
Labels
demo research Research a Topic

Comments

@acs
Copy link
Contributor

acs commented Jul 15, 2020

The model can be created in MV but we need an engine in which to program the physics which describe the voxels behaviour in collision. My personal goal is to have something like:

68747470733a2f2f692e696d6775722e636f6d2f7230457748464f2e676966

@acs acs added research Research a Topic demo labels Jul 15, 2020
@acs
Copy link
Contributor Author

acs commented Jul 15, 2020

@acs
Copy link
Contributor Author

acs commented Jul 15, 2020

Related to #102

@acs
Copy link
Contributor Author

acs commented Jul 16, 2020

Ok, let's implement it from a simple scenario and evolve it: there are two cubes. A cube is motionless (still, stopped) and B cube is moving along a line shared with A. At some point B hits A and after the hit, B changes its direction.

The speed of B is fixed in this initial scenario. No friction is modelled that can stop it. B can also hit the start of the line. When B hits C, the start of the line, it changes the direction. We can consider C another cube. So in this scenario we have:

A-------B----------------C

B moves between A and C. When B hits A or C, it changes the direction. And the speed of B is always the same.

To make it more real, we can model the 3 cubes in a shared line in MagicaVoxel. And the implement the animation of B using some voxel engine. Is it possible to do it in MagicaVoxel? Maybe with a shader that redraws the scene could be an option. We can draw it with McThings in Minecraft and do there the animation. We can also import the vox file in Blender and do the animation there. Or we can use Unity or Unreal4. Or we can use some way to visualize 3D, like Three.js. Or use some voxel engine with physics support.

I will try to do it as simple as possible and without using complex engines, in order to understand the key topics.

An pretty on topic article: https://sites.google.com/site/letsmakeavoxelengine/home/physics And it has some demos doing exactly what we want:

https://www.youtube.com/watch?v=O5YOPgYRKQI&feature=youtu.be

And the engine implemented with all of that: https://github.com/AlwaysGeeky/Vox

Our goal is to implement the animation in 1 dimension, then 2 dimensions and finally, in 3D. And increasy the physics details making it more realistic: adding friction, changing the rebound speed depending on the hit speed, chaning directions depending on hit angles, adding gravity ... and at some point. moving to a engine that has implemented physics for us :)

@acs
Copy link
Contributor Author

acs commented Jul 16, 2020

https://twitter.com/ephtracy/status/787232375298109440?lang=en

So as expected, animations can be done with shaders in MagicaVoxel. So let's explore this direction.

After some research, it seems to be pretty basic. You just create individual frames that can be combined into an animation. With shaders, you can fill the frames easily, as the tweet above shows. Some discussion about it:

https://www.reddit.com/r/VoxelGameDev/comments/7qxecn/how_do_i_do_frame_by_frame_animation_on/

and some people getting it working:

http://drinkdecaf.com/magicavoxel_animate

This feature was removed in 0.99: «Version 0.99 (the latest) has frame-based animation removed, though it is supposed to come back in the future» So end of this travel here with in MagicaVoxel animations.

@acs
Copy link
Contributor Author

acs commented Jul 16, 2020

Three.js

Maybe it is a good moment to try to load our model in Three.js and do the animation there:

https://luciopaiva.com/magicavoxel-threejs-howto/

But the problem here is that there is no VOX format library for JS, to it is using the export to OBJ and we want to work directly always in voxels, avoiding the conversion to polygs until the end.

https://discourse.threejs.org/t/best-way-to-add-physics-to-a-voxel-terrain/15037

@acs
Copy link
Contributor Author

acs commented Jul 16, 2020

Blender

This is cute, but not the kind of animation we want now: https://www.youtube.com/watch?v=3Hmhtwq8Fpc

@acs
Copy link
Contributor Author

acs commented Jul 16, 2020

OpenGL Canvas

Ok, let's try to do it directly in OpenGL. Let's start with Python.

https://github.com/acs/opengl-samples

Another 3D engine: https://www.pygame.org/project/3865

Just playing around with pygame and pyglet and PyOpenGL. Learning. pygame uses PyOpenGL (auto cstrings version for OpenGL API) and pyglet has its own OpenGL API.

http://pyopengl.sourceforge.net/documentation/index.html -> to learn OpenGL #123

http://nehe.gamedev.net/tutorial/lessons_26__30/29002/ Collision detection in OpenGL

Physical simulations:

@acs acs mentioned this issue Jul 18, 2020
@acs
Copy link
Contributor Author

acs commented Jul 24, 2020

@acs
Copy link
Contributor Author

acs commented Jul 24, 2020

@acs
Copy link
Contributor Author

acs commented Jul 25, 2020

@acs
Copy link
Contributor Author

acs commented Aug 12, 2020

A pretty interesting plugin for MineTest which shows collision also:

https://forum.minetest.net/viewtopic.php?t=22164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demo research Research a Topic
Projects
None yet
Development

No branches or pull requests

1 participant