#Spherical Coordinates (Splitting a sphere into eights)

163 messages · Page 1 of 1 (latest)

severe marsh
#

I've been trying to code a sphere mesh in gd script, but it's really difficult. The thing is I need it to be able to be split into eights so I need to print out each part separately, and that's proving to be quite difficult. The code is in the post if you want to see it.

upper pulsar
#

How many rings and segments are you thinking. (Easier if segments is a multiple of 8)

severe marsh
#

I might up it to 64 and 32 tho

#

But 32 and 16 seems to be good

upper pulsar
#

Do you need faces inside the sphere on either side of the segments?

severe marsh
#

Otherwise it'll be hollow

#

So like think of it more like sowing the missing parts

#

That's the big issue. Splitting is one thing, but adding the faces might also be tricky

#

I could probably just draw to spheres with cylindrical coordinates, convert it to rectangular coordinates, and use those. I would need three circles. The issue is then we need to remove extranious parts of the circles too. So we need to do it off a case by case basis

#

What I'm thinking is we calculate which octant we're in

#

while we're generating the mesh

#

and if we don't need it, we don't calculate it

#

Then we just need to figure out which quarter circles to add

#

and then it's done

rotund pilot
#

octogonal spheres are easier to cut up

upper pulsar
#

I just started writing the code to generate it and realized something do you need UVs because I'm terrible at setting up UVs

rotund pilot
#

let me find the exact math description

#

how far did you get

upper pulsar
#

I was about to declare the arrays

rotund pilot
#

Why do you need a sphere mesh? What purpose do you want it for

#

I'm assuming you want it

upper pulsar
#

I'm not the one asking I was trying to help

rotund pilot
#

ah

#

print out each part separately for an existing godot csg sphere or a https://docs.godotengine.org/en/4.4/classes/class_spheremesh.html sounds a lot easier than generating one and then printing one

#

So I was curious why was there a need to both generate and print

#

If all you needed was the sphere in blender, you can even export the current scene to gtlf2

rotund pilot
#

yeah

severe marsh
#

I'm making a program that makes custom 3d models in the anime style

#

think of vroid

rotund pilot
#

sure

#

what's stopping you?

severe marsh
rotund pilot
#

there's also the makehuman project

severe marsh
#

I know but I just want it as a challenge you know? Plus I want the full rights to the things created in it

rotund pilot
#

We've done a lot of those steps to make a godot engine character generator. ask me anything

upper pulsar
#

I'm thinking @iFire may be more helpful but if it doesn't work (and you don't need UVs) at me and I'll resume making the generation code I'm fairly quick at it because It's my go-to method

rotund pilot
#

previously godot engine only had a collada importer. So we added fbx and gltf2

severe marsh
rotund pilot
#

that looks like a lot like the make human blend shapes

severe marsh
#

Well anyhow, I got it partially working

#

except theirs this weird triangle?

#

It's like an artifact

rotund pilot
#

are you aware of the various godot engine axis conventions

#

it's ok to say no

severe marsh
#

Anyhow here's the weird triangle

rotund pilot
rotund pilot
#

Turn on wireframe mode

#

Godot Engine doesn't have n-gons (not even quads)

severe marsh
rotund pilot
#

you probably are using the wrong triangle order or forward axis

#

it's an editor viewport debug mode

severe marsh
rotund pilot
severe marsh
rotund pilot
#

hm, uh writing your wireframe shader is a bit annoying

severe marsh
rotund pilot
#

anyways as far as I can tell something is either cutting out the mesh or it's missing

severe marsh
#

Yeah

rotund pilot
#

like a camera clip plane

severe marsh
#

I'm thinking it's either one of two things

#

either my function for checking octants is wrong

#

or it's just in multiple octants at once, which defaults it to true

rotund pilot
#

can you do only one octant

#

it should be possible.

#

so standard tricks are divide and conquer and use the identity trick (make something that returns the input like 5 * 1 = 5)

severe marsh
#

Let me check

#

1 octant works

#

2 octants work

#

3 works

#

4 works

#

Wait nvm?

#

Octants can only print horizontally for some reason

rotund pilot
#

that might be it

severe marsh
#

So what do I do then?

#

Yeah not sure what to do

#

I've tried debugging it

#

but it's kinda hard to

rotund pilot
#

try doing only vertically

severe marsh
#

It get's the triangle issue then

rotund pilot
#

did divide conquer work

severe marsh
#

Wait now I'm confused

#

Okay so it works

#

so long as everything

#

is on the same hemisphere

#

otherwise it breaks

rotund pilot
#

sounds like backface culling

severe marsh
rotund pilot
#

you know when you have a mesh and go inside it and it turns transparent

rotund pilot
#

one common optimization is don't draw the back face because someone assumed the mesh is manifold so it will never show

severe marsh
#

How would backface culling fix this?

rotund pilot
#

it doesn't

#

I wanted to know if you flippd the triangles inside out

severe marsh
#

Correction: How does it relate to this

rotund pilot
#

if you reversed the winding order or whatever

severe marsh
#

I don't think so

#

I could send you a copy of the project

#

That way you can debug it in godot

rotund pilot
#

I'm a bit ragged so you can send it but I'll probably do more progress in this chat

foggy flicker
#

hi, dropping in from the math channel, the length of this conversation is intimidating...
this page from the doc ends with a simple code to generate a spherical mesh that you may want to take inspiration from : https://docs.godotengine.org/en/latest/tutorials/3d/procedural_geometry/arraymesh.html

severe marsh
#

I FIXED IT

#

I think

#

kinda

#

No more weird triangle thing

foggy flicker
#

I also have a few questions :

How to distribute points on the surface of a sphere as evenly as possibly is an incredibly important problem in maths, science and computing, and mapping the Fibonacci lattice onto the surface of a…

rotund pilot
#

there's no gdscript in the project

#

I recommend icosphere too

#

I forgot the name and the algorithm

severe marsh
severe marsh
foggy flicker
severe marsh
severe marsh
#

Yo @rotund pilot

#

I think I fixed it

#

Well not me...

#

Sadly I had to get help from Claude

#

It fixed it though

#

But I don't like using AI

#

What's your opinion on it?

rotund pilot
#

Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should.

rotund pilot
#

AI will magnify the power of the powerful and the individual. I can't predict the future.

severe marsh
#

Either way it's fixed

#

It was a kinda of easy yet complicated fix

rotund pilot
#

yay

severe marsh
#

Bassically we create a 2d grid, and fill it with -1

rotund pilot
#

To be honest I still would prefer the strategy of generating csg meshes then auto rigging them in godot engine.

rotund pilot
#

for character generation

#

I think you're trying to generate meshes via gdscript

rotund pilot
#

a flaw of this approach is you won't keep water tightness "manifold"

#

secondly it's kinda annoying and you can't get the engine to help you with skinning or morphing

#

but you've gone further than me, so don't let tell you what to do

severe marsh
#

I mean your right

rotund pilot
#

I'd detoured into making the avatars work in game

rotund pilot
#

Like character controllers.

#

We decided not to make a character generator and like directly import vrm from vroid etc or unity packages from booth.pm

severe marsh
#

I'm still a little confused on what your trying to say

rotund pilot
#

nevermind.

#

great work!

severe marsh
severe marsh
#

Turns out, it was broken

#

Just in disguise

severe marsh
#

I fixed it

#

Jeez this is a loop