Curved Surface (Surface Section of a Sphere)

Blitz3D Forums/Blitz3D Programming/Curved Surface (Surface Section of a Sphere)

Davros(Posted 2015) [#1]
Hi Guys

I am having a real b**** of a problem with this. Basically I am trying to create mesh that will act as a curved billboard with which I will use to texture a shield hit effect when the beam makes contact. Essentially I can't figure out the logic to create the triangles from my vertexes I have made in my 'grid of points' (by which I mean connecting them all together in the correct order to form the whole surface.

What I am looking to do is create a function that takes a 2 parameters of how many squares will make up the grid of points that will construct the mesh and connect all the vertexes into triangles in the correct order.

Ignore the fact for the moment that the mesh will be curved, as it would be the same problem if it was flat.

Can anyone point me in the right direction?


Floyd(Posted 2015) [#2]
Here is how to search the Code Archives. Paste the following into your browser address bar.


create grid mesh site:blitzbasic.com/codearcs


Davros(Posted 2015) [#3]
Thanks Floyd. I just found: Mesh Plane by Neo Genesis10 a few minutes before you posted that.

I like his example as the code is easy to follow yet when i run it i get nothing appearing at all lol

The function is definitely running, the entity is created etc etc, but even in wireframe mode there is nothing appearing (i am also rotating it just to make certain i'm not seeing it from behind or anything)

Just plain weird.


Floyd(Posted 2015) [#4]
That mesh has all y values equal to zero making it horizontal.

So place the camera above, pointing down.

Or change the mesh so all z values are zero. i.e. in AddVertex change x,0,z to x,z,0.


Davros(Posted 2015) [#5]
it turned out the entity was being textured in a different section of the code so even in wireframe it didn't show up. I altered the Neo Genesis code to create a mesh plane in either XY or XZ planes and made it centered from the origin of 0.

Now I have to figure out how to curve the mesh as if it was a section of the outside of a sphere. I know there must be an elegant solution using cos/sin/tan and the radius etc etc


Kryzon(Posted 2015) [#6]
https://github.com/si-design/minib3d/blob/master/inc/TMesh.bmx#L388