Creating 3D shapes

Discussion in 'Spigot Plugin Development' started by Kilian544, Jul 23, 2018.

1. Kilian544

Hi!

I am creating a plugin which generates actual viens of ore, so obviously I need a way of "generating" a vien. I was thinking maybe generating a 3D shape, ellipsoid or hexagonal bipyramid, but how do a go about this? I want to be able to choose the two "tips" of the shape and the width.

Please let me know if you know how to do this of if maybe you can come up with an alternative and (semi-)realistic way of generating veins.

On a side note:
I am clearing a chunk of ores and generating a vein in it on a chance basis, only downfall I run into is needing to limit my generation to a chunk-by-chunk basis (because of populating and/or ungenerated chunks). How would I solve this? Is there maybe a way that I can remove the ore populators from the worldgeneration and make sure every chunk I manually "populate" is generated, "depopulated" and available for changes?

Kind regards,
Kilian Legters

2. CKitty

You can look for the shapes' formulas and then you'll be one step ahead.

(in a loop, check if the block is inside the area)

3. Kilian544

This was my first guess, but how do I know if it is inside the shape? Or is this something insanely obvious?

4. CKitty

No, it's not obvious. Every shape has a formula that tells you if you're in or out of the volume. The trick is finding the formula on the internet. Example: A sphere: if the distance between the center and point x is lower or equal than the radius, the point is inside the sphere.

#4
Last edited: Jul 23, 2018
5. Kilian544

Ahh yes I see, you can create a new formula derived from the formula of the shape. Using this you can calculate if the outcome is -1, 0 or 1, and based on that you know if the point is inside or outside of the shape! thanks.

Do you also have any advise for the problem with the chunks populating?

6. CKitty

I don't understand the problem. Is it something like the veins are generating outside of the chunk?

7. Kilian544

Are you familiar with world generation? If not you wouldn't really know.

Basicly I am generating ores, something the worldpopulators also do. When a chunk gets created for the first time, I clear all the ores generated by the populator. Then generate my own ores. The simplest option is staying within the generated chunk, something I really dislike.

The problem is can I change blocks in an ungenerated chunk? And how does it behave? Does the chunk get generated at that moment, do the populators also fire at the same time as the generation of the chunk? Depending on this I might have to disable the default ore-populator, this prevents me having to clear a chunk from generated ores, and possible also the ores generated by myself. If so how do I do this? Or I can do this without fancy saving of ores that are yet to be generated in a chunk, or else I might end up in a infinite loop or lose the ores I generated on a restart.

8. CKitty

...I think you don't need my help anymore xd

9. Kilian544

Hahaha, Thanks for your help so far! Anyone more familliar with world generation?