How to make "Rounded" custom meshes like Sphere/Skydome, etc

Hello all,

I am basically looking to how to create a quarter “pie” aka half of a sky dome. I tried messing around with a skydome, but it seems to only work as a half circle, and a sphere as a full circle.

Is there a way I could either split the dome in half, or would it be better to create my own custom mesh, and how do I exactly work radialsamples into that?

I meant to say Skydome only works as half a sphere(unless you make it a cone or pyramid but that’s still "half), and then there is the full sphere… (I know someone was going to try to correct me on that :P).

@KonradZuse said: Hello all,

I am basically looking to how to create a quarter “pie” aka half of a sky dome. I tried messing around with a skydome, but it seems to only work as a half circle, and a sphere as a full circle.

Is there a way I could either split the dome in half, or would it be better to create my own custom mesh, and how do I exactly work radialsamples into that?

If it was me, I’d likely use the Dome mesh provided in JME.
Dump the buffers to text (System.out.println… etc)
Determine which part (should be the first fourth of each buffer) makes up the quarter dome.
Then use the Dome class as a template for creating the custom shape.

If you need the faces shown in the picture, you’ll need to add a single vert and then stitch the indexes to create the faces needed

@t0neg0d said: If it was me, I'd likely use the Dome mesh provided in JME. Dump the buffers to text (System.out.println... etc) Determine which part (should be the first fourth of each buffer) makes up the quarter dome. Then use the Dome class as a template for creating the custom shape.

If you need the faces shown in the picture, you’ll need to add a single vert and then stitch the indexes to create the faces needed

Thanks T0neG0d, a few things.

  1. I’m assuming we are looking at all of the buffers?

  2. Would it be the first fourth or half(since the dome is half)?

  3. I’m not sure what you meant by your last sentence. I’m not using that exact quarter dome(the textures of it or w/e) but that shape yes.

I’m not that strong with custom meshes, there seems to be a lot of terminology that I’m still lacking, and the documentation is vague. Would you happen to have any good resources that you would recommend on this topic?

Thanks for the help as always!

  1. Yep, yep.
    2, Dome is it’s own class, so the first fourth.
  2. In the picture, there are faces going to the center point of the quarter dome. If you actually need those faces, you’ll have to add them, as the Dome class is hollow.

Don’t worry about how comfortable you are with custom meshes. Just use the Dome class as a template for building your own. It has everything you need in it, you’re just limiting how much of the mesh it is going to produce.

Texture coords are a different matter. I don’t believe the default setup is going to be what you want… but when you get this far, I’m sure we (me or someone else) can help you fix that.

One sec on the good resources. Actually… the custom mesh tutorial is the best (simplest) example I know of.

SkyControl contains a class which can generate meshes for segments of a dome. It could certainly generate a quarter-sphere or an eighth of a sphere.

@sgold said: SkyControl contains a class which can generate meshes for segments of a dome. It could certainly generate a quarter-sphere or an eighth of a sphere.

Even better!

@sgold said: SkyControl contains a class which can generate meshes for segments of a dome. It could certainly generate a quarter-sphere or an eighth of a sphere.

Out of curiosity, why didn’t you use the Dome class in JME?

Okay, i understand now what you meant t0neg0d, I forgot it’s hollow.

SkyControl So even though it’s for making skies we can make geometries with it?

As for the custom mesh tutorial it’s good, but limited, it doesn’t explain a lot of things which iw what I was metioing before.

Thanks both!

@KonradZuse said: Okay, i understand now what you meant t0neg0d, I forgot it's hollow.

SkyControl So even though it’s for making skies we can make geometries with it?

As for the custom mesh tutorial it’s good, but limited, it doesn’t explain a lot of things which iw what I was metioing before.

Thanks both!

If you have any specific questions, I’ll try and answer them as best I can.

@t0neg0d said: If you have any specific questions, I'll try and answer them as best I can.

I actually do have a question pertaining to custom meshes.

Now I want users to be able to design rooms in my world, but I also want to be able to use textures on the ceiling/floor.

Is there a simple way of working texture coordinates with a custom mesh you don’t know details about?

I figured since the scale is 0-1 that all I need to do is count the smallest as 0, and the largest as 1, and divide the other points to see where they fit so I could use them as the texture coords.

Here is an example http://hub.jmonkeyengine.org/forum/topic/custom-mesh-hex-and-texture-problem/

I’m not sure if this is the best approach for my idea, but I figured it would work.

Assuming that the areas of the floor are defined in segments that are known size, that might look like:


|_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_|
    |_|_|_|_|_|_|
    |_|_|_|_|_|_|

You can handle texture coords in 1 of 2 ways:

1f/8 (segments) for width & height - this way, the above would use 0.0 -1.0 width wise & 0.0-0.5 height wise

Or, if the texture repeats, you can assign the texcoords 0.0,1.0,2.0,3.0 etc, just make sure the wrap mode is set properly.

If you were to remove extra verts from the middle of the above, you could still use the outer texCoords in the same fashion.

If the shape is odd, like the hex example, you should be able to use the same method you use for placing the verts properly to define the tex coords. The hex fits over a rectangle and therefore has know coords. Even in the case where they are laid out interlinked, you are still down to 2 variations and can set up texCoord templates to use when defining them in the buffer.

Here is an example of a template you could use for a grid:
[java]
short[] indices = new short[] {
(short)0,
(short)2,
(short)3,
(short)3,
(short)1,
(short)0
}
[/java]

These are the two faces used to define a single quad. When using the template, you would increment the loop by 6 every pass and offset 3 & 2 by the number quads in a single row.

Similar templates can be set up for almost any custom mesh.

@t0neg0d said: Out of curiosity, why didn't you use the Dome class in JME?

Because I wanted to do things that the Dome class doesn’t do, such as custom UVs, segments of domes, and domes that cover more than half the sky.

@KonradZuse said: SkyControl So even though it's for making skies we can make geometries with it?

SkyControl needs to create dome meshes, so it comes with its own mesh generator, called DomeMesh. DomeMesh is very general and can be used for other purposes besides skies.

@t0neg0d said: Assuming that the areas of the floor are defined in segments that are known size, that might look like:

|_|_|_|_|_|_|_|_|
|_|_|_|_|_|_|_|_|
    |_|_|_|_|_|_|
    |_|_|_|_|_|_|

You can handle texture coords in 1 of 2 ways:

1f/8 (segments) for width & height - this way, the above would use 0.0 -1.0 width wise & 0.0-0.5 height wise

Or, if the texture repeats, you can assign the texcoords 0.0,1.0,2.0,3.0 etc, just make sure the wrap mode is set properly.

I’ve been seeing this 1/8 business a lot, would you be able to explain it further? I’ve seen it other times when people wanted to change textcoords on a box or multifacebox.

I never really understood why exactly we are splitting up the floor(is it so we get EXACT measurements of where each thing should be)? Your drawing makes a bit more sense, than what I’ve seen in the past, but I’m curious about it.

You can go past 1 with texcoords? I thought they were 0.0-1.0(or does the repeat count as +1)?

Basically the data I am given is an outline of the walls of the level. it could be 60 wu left, then 20 wu down, then 30 right, 20 up, then 30 right. from there I create my floor.

@t0neg0d said: If you were to remove extra verts from the middle of the above, you could still use the outer texCoords in the same fashion.

If the shape is odd, like the hex example, you should be able to use the same method you use for placing the verts properly to define the tex coords. The hex fits over a rectangle and therefore has know coords. Even in the case where they are laid out interlinked, you are still down to 2 variations and can set up texCoord templates to use when defining them in the buffer.

Here is an example of a template you could use for a grid:
[java]

These are the two faces used to define a single quad. When using the template, you would increment the loop by 6 every pass and offset 3 & 2 by the number quads in a single row.

Similar templates can be set up for almost any custom mesh.

hmm interesting about outer texcoords, but again I;m not sure about this whole “grid” layout you’re using.

Thanks.

Down with the flu today… so bear with me.

0.0 - 1.0 this is the full width or height of whatever image you are using as a texture.

1f/8f would give you 0.125f or an 8th of the image’s width or height

If you have 9 verts across your grid… the texCoords .x would look like:

x coords:
0.0,
0.125,
0.25,
0.375,
0.5,
0.625,
0.75,
0.875,
1.0

Each vert increases by 0.125f (i.e. 1/8th of the image’s width)

If you want to know what a single pixel of your image represented in texCoords would be, you would do the following:

x = 1f/imageWidth;
y = 1f/imageHeight;

As for splitting up the floor (or have multiple verts through the mesh), this will help with more accurate lighting if you use Vertex Lighting.

For you example, where you are unsure of the config of the mesh, you’ll likely want to break it into the smallest component. In your case it would seem like wu would be the thing. So 1 world unit = 0.0 - 1.0 texCoords (if you are using tiling… which you likely will as the other option will just distort your texture).

As for texCoords going over 1.0… they can, but you have to set the wrap mode of the texture to repeat… Example using 5 verts across a grid tiling the image:

x coords:
0.0,
1.0,
2.0,
3.0,
4.0

This would tile the image 4 times across the grid.

All the examples above are only using x… same applies to the y coords as well.

@t0neg0d said: Down with the flu today... so bear with me.

0.0 - 1.0 this is the full width or height of whatever image you are using as a texture.

1f/8f would give you 0.125f or an 8th of the image’s width or height

If you have 9 verts across your grid… the texCoords .x would look like:

x coords:
0.0,
0.125,
0.25,
0.375,
0.5,
0.625,
0.75,
0.875,
1.0

Each vert increases by 0.125f (i.e. 1/8th of the image’s width)

If you want to know what a single pixel of your image represented in texCoords would be, you would do the following:

x = 1f/imageWidth;
y = 1f/imageHeight;

As for splitting up the floor (or have multiple verts through the mesh), this will help with more accurate lighting if you use Vertex Lighting.

For you example, where you are unsure of the config of the mesh, you’ll likely want to break it into the smallest component. In your case it would seem like wu would be the thing. So 1 world unit = 0.0 - 1.0 texCoords (if you are using tiling… which you likely will as the other option will just distort your texture).

As for texCoords going over 1.0… they can, but you have to set the wrap mode of the texture to repeat… Example using 5 verts across a grid tiling the image:

x coords:
0.0,
1.0,
2.0,
3.0,
4.0

This would tile the image 4 times across the grid.

All the examples above are only using x… same applies to the y coords as well.

Lmao I JUST looked at this thread, saw no reply, went to the bathroom, and herro reply :P.

Please go rest, I appreciate the help, and I will get back to you on this tomorrow or whenever you feel better. This isn’t’ a priority that I need it done right away, but I do appreciate your time and patience as always.

It seems like this only is for images you want to work in a grid, i.e., a specific part of the image at a specific part of the world, but it seems that a texture wrap gets rid of all that jazz if you don’t need specific parts of the “world/grid” to be specific?

Will read the rest and reply later.

Don’t reply to me, go rest!!! :slight_smile: