Comments (30)
I want to rotate the Schematics. For example, in https://github.com/juntosdesdecasa/mcthings/blob/develop/scenes/scene0_20.ipynb the entry door for "schematics/chateau-fairmont.schematic" is at the back of the castle!
from mcthings.
Ok, let's start with this one. I have thought about its implementation and my plan is to rotate things in x,z (y is the height). The rotation will be based on a central column which won't rotate. The thing will be seem as lines that goes from this central column to the border of the Thing. And the idea is to rotate those lines.Let's see how far we go with this approach.
In my first step my idea is to rotate a two joined blocks Thing. The evolution could be something like:
--
**
--
*
*
--
*
*
--
*
*
--
**
--
*
*
--
*
*
--
*
*
--
**
--
8 different positions (the last one is the same than the first one): 0, 45. 90, 135, 180, 225, 270, 315, 360 (== 0).
Let's play with that and then we can add 3 blocks. And after that, use a two height cuboid with different materials in the blocks to see that it is rotated correctly.
from mcthings.
After playing a bit, the idea with the lines is clear. Remove the current line and create a new one with the same start point (the center of the rotation) and with a new end point (which depends in the rotation). So we need to implement a new Line Thing which joins two points. And after that, we just need to compute the end point for each rotation. Easy? Probably not, but it is getting clearer.
from mcthings.
Drawing a line is already support by https://github.com/martinohanlon/minecraft-stuff/blob/master/minecraftstuff/minecraftstuff.py#L159 so probably we can just reuse it.
from mcthings.
I am not sure we can rotate using lines. Maybe we need to do it block by block. Apply a common transformation to move the position of a block depending on the rotation. But, is there a function to compute the new position for any block depending on the rotation?
Probably it depends on the degrees to rotate and also, on the radius from the rotation in which the block is positioned.
from mcthings.
Ok, there are some references that can be useful to check we are going in the right way: https://www.khanacademy.org/computing/computer-programming/programming-games-visualizations/programming-3d-shapes/a/rotating-3d-shapes
x′=x*cos(β)−z*sin(β)
z′=z*cos(β)+x*sin(β)
But we are working with blocks! But it must be valid in this case also. β must be in radians.
math.degrees(x)
Convert angle x from radians to degrees.
math.radians(x)
Convert angle x from degrees to radians.
from mcthings.
We need to define also with respect to which we are rotating. To the center of the Thing? To one of the corners? Let's try to cover the simplest case first.
from mcthings.
So let's focus in rotating 45ºC:
>>> math.sin(math.radians(45))
0.7071067811865475
>>> math.cos(math.radians(45))
0.7071067811865476
Let's use 0.71 for both. In our simple two blocks like in positions (x,z): (0,0), (1,0). The result is:
x' = x * 0.71 - z * 0.71
z' = z * 0.71 + x * 0.71
- First block: (0, 0)
- Second block: (0.71, 1.42) which rounding is (1, 1). Which is the right position. Let's play a bit to see what Minecraft do when we position things using decimals. Probably it does the rounding to a concrete tile.
from mcthings.
Ok, we have a first version that would work in a float world. But with integers and blocks ... let's see how far we can go!
from mcthings.
Using a 5 blocks like, when it is rotated 45 degrees one block is lost because the rounded position is the same than a previous one. So we need to review the process. Probably inspired in the real solution with floats, but fixing it for our blocks case.
The plan is to implement the rotation for 90 degress. In this case we can support 90, 90+90 and 90+90+90 rotations. And if we implement it, the let's try the 45 degrees step!
from mcthings.
The 90ºC rotations works mostly:
from mcthings.
Good feelings with the 90 rotation. We need to fix this bug that make some blocks disappear in the up border of the rotated figure, but it the same bug always (the width of the cuboid rotated), so probably we can find a common solution.
Let's play a with the a Schematic to check the results.
from mcthings.
Great results, the process is slow, but for example, if we need a rotated schematics for an scene, we can generate it, save it to a new schematic, and then use the rotated schematic. The possibilities are huge.
from mcthings.
And as expected, the 90, 180 and 270 rotations works nicely!
from mcthings.
The next step is to fix tthe bug found and we have it. Let's do a quick test with Zanabot.
from mcthings.
Zanabot being reconstructed with in its rotated version and it final version:
from mcthings.
In order to improve the performance, probably the approach is to do the full rotation process in memory, and once it has finished, draw the results.
from mcthings.
Next steps:
- Fix bug
- Improve peformance
- Create the scene with the castle in the right position: the main entry in the side of the town.
from mcthings.
Bug fixed:
And also now the performace is much better (get all blocks in one call, clean all blocks in one call, rotate each block one by one).
from mcthings.
Bug fixed and now the performance for rotating a Schematic is the same than loading it.
from mcthings.
Last steps:
- Check that the rotation is 90, 180 or 270 ok
- Update the bouding box ok
- Create the scene with the castle in the right position: the main entry in the side of the town ok
- Create an animation with rotation ok (done in the animation plugin)
- Create a new version, video for it and dissemination
from mcthings.
Let's finish this issue!
Also another performance idea:
-
If a Thing is not build already, you can build it rotated directly? You could build it in memory (without showing it) and rotate from data in memory. With that, we avoid one build of the things, important if it is large, and also, because we don't need to remove it. so we avoid two expensive operations and we go directly to showing the rotated version.
-
In Schematics it is pretty relevant. If we start using rotations in Schematics intensively, we must improve it in this way. But something to be done in the future. DONE
from mcthings.
It is going to be nice to rotate a Thing 180ºC and leave it in the same position than the original one. This is the requirement for our Scene 0.41.0! First try:
The castle is moved because of the rotation over the rest of the scene!!! So the issues we have:
- The rotation losses the data from the blocks, so we are loosing colors (like the ones in the flags).
- The removal of the castle leaves trash: this is because the reaming blocks are like the sand, they go down if the supporting box is removed. So when you try to remove them, they have moved. In this case, it is easier to just remove the cuboid for the castle.
- The final position of the castle is over our scene. Why? Let' s draw it:
FFFFFFF
BBBBBBB BBBBBBB
FFFFFFF
So let's work step by step in fixing this issues if possible. At least, let's fix the position one. The fix is to create the castle having in mind the rotation. So the position for the castle must be:
pos.x = pos.x - castle.width
pos.z = pos.z - castle.length
Let's play with that!
from mcthings.
Implemented the rotation in memory for Schematics. During the testing, a nice finding:
from mcthings.
Yes, the entry to the castle is now pretty close to the sphere
from mcthings.
All done for the scene with the castle 180 rotated, and including the correct data for all the blocks! The best scenario :)
from mcthings.
- Create a new version, video for it and dissemination
We have the 0.42.0 version. Now it is time to show in screenshots (the circle of boats) and with a video this new cool feature!
from mcthings.
https://twitter.com/acstw/status/1269042569683533833
All done! Closing!
from mcthings.
MCEdit 2.0 has a free rotation feature:
https://www.youtube.com/watch?v=FgaxGaTm_NY
In WorldEdit they support the 90, 180, 270 approach:
No it can do also free rotating:
https://www.youtube.com/watch?v=XYlg3vAjzLc
So in the future we should add this free rotating feature to McThings!
from mcthings.
https://minecraft.gamepedia.com/Structure_Block
Rotation (0, 90, 180, 270)
Sets the rotation of the structure to 0° (no rotation), 90° clockwise, 180° clockwise, and 270° clockwise (or 90° counter-clockwise).
from mcthings.
Related Issues (20)
- Learn Vulcan API HOT 3
- Research Open Source Physics engines HOT 5
- Learn Computer Graphics HOT 1
- Research Ray Tracing HOT 11
- Explore the Cyrille Rossant Python Ray Tracer HOT 4
- Implement a Ray Cast renderer for McThings
- Test that McThings works with MC 1.16.1 HOT 2
- Create a Blender renderer for McThings
- Remove McDrawing reimplementing the Sphere
- Research resources pack in Minecraft HOT 4
- Research shaders in Minecraft HOT 1
- Research the use of textures inside Blender
- Research the use of shaders inside Blender
- Implement voxels collisions in Godot physics testbed HOT 14
- Create a Godot renderer for McThings
- vox2schematic - TypeError: to_nbt() takes 3 positional arguments but 4 were given HOT 1
- Test McThings with the last version of Minecraft HOT 2
- Research the migration from TravisCI to GitHub Actions HOT 1
- vox2schematic not working
- Implement McThings over Godot
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcthings.