Structurize & Shapes

in #utopian-io7 years ago (edited)

Hey everyone, I posted a few days ago about our minecolonies extension structurize [here].

The last days we've worked hard to extend this with a new part of the mod.

Thanks to @asherslab for preparing the GUI and the tool for me on which I created the following functionality:

Shapes

The shape tool will allow players to render certain shapes into the world.

For now, I added the following functionality:

1: Prerender

Prerender shapes with the shape tool:

  • Bowl
  • Half-sphere
  • Sphere
  • Wave
  • 3D Wave
  • Cube

2: Adjust

For the above shapes, we allow them to be hollow or not and we allow the player to choose the block they want it to be as well as the size specifications.

3: Paste

Paste these shapes into the world.

How it's done

To achieve this I had to rewrite a bunch of our paste code and I had to write the creation of the shapes.

First of all, I created an enum which contains all shapes and is easily extendable.

Then, I created a message to request a shape to the server.

Which requires a bunch of variables to be able to cope with the different shapes.

Afterward, I created the message which serializes this and sends it back to the client.

And then loads it into a structure to display it.

The server receives these shapes and delegates them to the right generator.

Then, for each of the shapes, we have to do a calc to display them.

The usual approach here is to go through all coordinates within the given height, width and length and check if the coordinates match the formula and if so, add them to the template.

Which is quite easy for the cube, but gets harder for the other shapes.

The sphere, for example, is optimized since each quarter of the sphere is basically the same, so we have to go only through half of the size and save a huge number of iterations.

Depending if we want the full sphere, half sphere or want it hollow we will just adjust the calc and restrict the amount we put in.

For the wave, I used a classical sine wave and adjusted its frequency and height depending on the input parameters. I used length to fix how long it runs.

We offer two types of waves, one which is 3d as in the image above and one which is just a flat wave without z adjustment.

To be able to paste this, I had to adjust our structure classes which expect more detailed templates.
To optimize the templates and since we will have empty space (We don't want to scan in all air blocks) I adjusted the block state and blockInfo methods to return a placeholder if no block was found.

And I had to adjust the structure classes to load a template directly and not only from disk.

Since the server loading code loads the template to a place, temporarily, we can use this to load it directly into a structure wrapper.

To make the replace block work in the GUI I had to adjust our Replace-block-window to be able to replace a block or to return a block (just like a block picker). And then, I had to adjust the window to class to:

a) Call the Block-picker
b) Rotate and save the rotation
c) Send the changes to the server on input only if the input was really changed
d) Load the enum shapes and send the new shape request to the server on change.
e) Make the hollow toggle work.
and
f) Make it work that the shape stays there even when the window is reopened.

Since we're still in the setup phase we didn't start working with pull requests yet (To improve efficiency while the app is not live yet).

You can see my commits with the changes here:

https://github.com/ldtteam/Structurize/commits/release

Starting with: Add crazy structure handling code for asher to handle
Ending with: Fix setup

I hope you liked this new structure handling.
If you want to take a closer look check out the short videos:

https://drive.google.com/open?id=1Am27wq8ZqTj3qT_Ogad3ggBz_ZLVEWkj

If you have some nice ideas about some shapes, feel free to pr them to Structurize [here]!

Planned extensions:

  • Try to move more complexity of structure creation to client side.
  • Diamond and Pyramid shapes
  • Random shapes with equations input
  • Cylinder shapes
  • Minecolonies builder integration

I will see you the next time with more exciting updates!

Sort:  

Thank you for your contribution. A great contribution and a lot of work gone into it.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

@raycoms Your post was selected and voted by the curator @pataty69 project looking for excelent rewards on great content posts that can be followed on my trail at Steemauto.

Hey @raycoms
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.13
TRX 0.35
JST 0.034
BTC 114993.80
ETH 4514.37
SBD 0.89