[DONE] Torus command

Fixed bugs, solved problems, and old reports.
Locked
M1_Abrams
Offline
Posts: 44
Joined: July 3rd, 2011, 8:19 pm

[DONE] Torus command

Post by M1_Abrams »

Would it be possible to make a command that draws a torus (doughnut shape)?

Answer:
Image
Last edited by M1_Abrams on September 3rd, 2011, 9:20 pm, edited 1 time in total.
"A ship in a harbor is safe, but that’s not what ships are for."
--William Shedd

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Torus commands

Post by fragmer »

I don't know the equations for torus voxelization. If you find some, let me know, I'll implement it.

User avatar
Hit-Girl
Trustee
Offline
Posts: 482
Joined: May 23rd, 2011, 11:42 pm

Re: Torus commands

Post by Hit-Girl »

So, uh, I googled ''equations for torus voxelization'' I have no idea if this is of help or not, but I'ma share it none-the-less. :?

Code: Select all

S (u, v) = ( f (u, v), g(u, v), h(u, v)), where − π ≤ u ≤ π, −π ≤ v ≤ π, a > 0
<SMB> pen23: Hit you are so mean and pathetic and a liar and you're ugly and fat

User avatar
boblol0909
SupOP
Offline
Posts: 314
Joined: June 24th, 2011, 10:27 pm

Re: Torus commands

Post by boblol0909 »

I found this code online, might help idk
Show

User avatar
Bloody_Llama
Trustee
Offline
Posts: 324
Joined: May 26th, 2011, 6:35 pm

Re: Torus commands

Post by Bloody_Llama »

Personally, I get a lot of satisfaction building one myself. However, the enormous amount of time it takes certainly would justify a command. How you could actually implement it with less complexity than piloting a fighter jet, I don't know.
<FCB2> trevbev94: who made the perimid out of saind cause that is ausom
<FCB2> Pemalite+: druffin. 'cmere big boy for some lovin'

M1_Abrams
Offline
Posts: 44
Joined: July 3rd, 2011, 8:19 pm

Re: Torus commands

Post by M1_Abrams »

Fragmer I have an idea.

The user places two blocks just like cuboid, and the command does this:

1. uses ellipsoid command to make a circle along the xy-plane from x1,y1,(z1+z2)/2 to x2,y2,(z1+z2)/2

2. draws spheres from EVERY point on the circle with radius z1-[(z1+z2)/2]

3. This should approximate a torus pretty well, I'm going to test it :happycreeper:


EDIT: And Bloody_Llama, I would love to build a torus myself using this method, but the lame builders spamming spheres took sphere away from all builders. :(
Last edited by M1_Abrams on September 1st, 2011, 3:07 am, edited 1 time in total.
"A ship in a harbor is safe, but that’s not what ships are for."
--William Shedd

User avatar
Bloody_Llama
Trustee
Offline
Posts: 324
Joined: May 26th, 2011, 6:35 pm

Re: Torus commands

Post by Bloody_Llama »

Good luck making a hollow one like that :twisted:
Also, don't you have to define how big the center is, and how steep (I'm sure there is a better word for that)?

And if we're going to call it a torus, shouldn't it allow more irregular shapes? Torus's aren't all perfectly circular. (LOL @ circles in a game made of cubes)

edit: M1_Abrams if you want to test out this shit, download fCraft and start up a local server on your machine, where you can use any command to your hearts content.
Last edited by Bloody_Llama on September 1st, 2011, 3:11 am, edited 1 time in total.
<FCB2> trevbev94: who made the perimid out of saind cause that is ausom
<FCB2> Pemalite+: druffin. 'cmere big boy for some lovin'

M1_Abrams
Offline
Posts: 44
Joined: July 3rd, 2011, 8:19 pm

Re: Torus commands

Post by M1_Abrams »

Hold on I'll have a screenie in a few minutes.

And I was just wanting a ring, but this method might work for non-circle ellipses
"A ship in a harbor is safe, but that’s not what ships are for."
--William Shedd

M1_Abrams
Offline
Posts: 44
Joined: July 3rd, 2011, 8:19 pm

Re: Torus commands

Post by M1_Abrams »

This isn't EVERY point cuz I don't have much time, but an idea:
Image
"A ship in a harbor is safe, but that’s not what ships are for."
--William Shedd

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Torus commands

Post by fragmer »

Rotating a sphere around an axis would work, BUT there are a couple performance constraints to overcome before this will be practical:
  • All draw operations are applied incrementally, and must preserve their state between batches. This is optimally solved with a state machine such as the current /ehx implementation. If that ends up being too difficult (as it very well might), I'd have to fall back to creating an iterator block. That adds some overhead though.
  • All draw operations must touch any given coordinate at least once. If a block is touched twice, /undo information will be lost for that coordinate. It would also be extremely inefficient to revisit each block dozens or even hundreds of times with consecutive sphere commands. I've dealt with this limitation so far by making all drawing operations work linearly. Another solution would be to keep a list of modified coordinates, like a HashSet of resolved block array indices. But that would add a lot of memory and CPU overhead, and would not scale well - checking for duplicate coordinates will become O(n^2).

M1_Abrams
Offline
Posts: 44
Joined: July 3rd, 2011, 8:19 pm

Re: Torus commands

Post by M1_Abrams »

Well another method would be to draw that axis in the picture above, then draw two perpendicular rings around it, and then draw a bunch of circles (not as many as the sphere idea!) parallel to the axis that contain the points on the two rings.

EDIT: Nevermind, I failed.
"A ship in a harbor is safe, but that’s not what ships are for."
--William Shedd

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Torus commands

Post by fragmer »

I would suggest an implementation that goes in slices along the z axis (top-down) like so:

Image

Each slice will have blocks between two circles - inner and outer. The radius of those circles can be figured out with a simple equation. Now all you have to do is go through each voxel within a slice and check if it's contained between those circles. Tada.

Like I said earlier, I don't plan on implementing this myself. But if someone else wants to volunteer, go ahead, I'll include your code when you're done.

M1_Abrams
Offline
Posts: 44
Joined: July 3rd, 2011, 8:19 pm

Re: Torus commands

Post by M1_Abrams »

IT WORKS FRAGMER IT WORKS!!! :lol: :happyskeleton: :happycreeper:

EDIT:
Image
Now I just have to finish making the callback and figure out where the user should set the blocks and it's good to go! (Hopefully)
Also I have to program the Logger and the undo-er thing. Woohoo!
"A ship in a harbor is safe, but that’s not what ships are for."
--William Shedd

User avatar
KingCrab
Offline
Posts: 1058
Joined: May 24th, 2011, 4:42 pm

Re: Torus commands

Post by KingCrab »

Win
<+FCB1> 05+Pemalite: all the fcraft chicks reject me except element

13:04 + FCB2 │ +Pemalite: craaaaab
13:04 + FCB1 │ +Pemalite: no
13:04 + FCB1 │ +Pemalite: ill give yout the best loving ou ever ad crab

User avatar
Fehzor
Trustee
Offline
Posts: 533
Joined: May 24th, 2011, 12:03 am
Location: Battery City
Contact:

Re: Torus commands

Post by Fehzor »

Can we make an alias be /donut?

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Torus commands

Post by fragmer »

Consider it done, Fehzor.

User avatar
cdferg
Trustee
Offline
Posts: 484
Joined: May 24th, 2011, 2:11 am

Re: Torus commands

Post by cdferg »

Fehzor wrote:Can we make an alias be /donut?
And /bagel?
doberman411: I now know that I feel a bit of relief every time the landing gear of my plane lifts off of the runway knowing that I'm one step closer to freedom.

tomsplz3
SupOP
Offline
Posts: 183
Joined: May 24th, 2011, 3:42 am

Re: Torus commands

Post by tomsplz3 »

cdferg wrote:
Fehzor wrote:Can we make an alias be /donut?
And /bagel?

how about krispy kreme lol

Locked