“insert title”
Basically, am I able to use jMonkey’s shapes to make one or do I have to make my own mesh?
Also when I tried using the dome mesh the bottom face is always invisible for some reason
1 Like
what’s your goal? to make a shape like that image?
Once again I am at work and can’t play around much … but perhaps
//the three points that make up the triangle
Vector3f p1 = new Vector3f(0,1,0);
Vector3f p2 = new Vector3f(1,1,0);
Vector3f p3 = new Vector3f(0,1,1);
Triangle t = new Triangle(p1, p2, p3);
code from → Introduction to Mathematical Functionality
Ali_RS
July 15, 2022, 4:13am
3
Hi
Looks like some people created a prism mesh before.
Here is a snippet I decided to share. It makes n-sided prisms.
eg to create pentagonal prism: new Prism(radius, halfHeight, 5);
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer;
import com.jme3.util.BufferUtils;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
public class Prism extends Mesh {
public Prism(float radius, float halfHeight, int sides) {
this(Vector3f.ZERO, radius, halfHeight, sides);…
Hi everybody,
I have made a primitive mesh class for convex prisms wich are very useful in procedural generation of cities like mine
[image]
Uploaded with ImageShack.us ’/>
The class can easily be optimized because I use ArrayList and then tables, but the 15 000 buildings of the picture are generated in no time so I leave it like this for now.
The constructor needs only an ArrayList of Vector2f wich store a linear counter-clockwise ring of 2D coordinates, w…
2 Likes
Ali_RS, the top post answer works perfectly for me. Thank you!!
2 Likes
sgold
July 15, 2022, 4:47am
5
JMonkeyEngine supports custom meshes.
In custom meshes, invisible faces are usually caused by having an incorrect “winding order”.
In the case of a rectangular prism, there’s no need to create your own custom mesh, because the Heart library includes a class to generate prisms:
/**
* Instantiate a right prism, closed at both ends with regular polygons.
*
* The center is at (0,0,0). The end polygons lie parallel with the X-Z
* plane. All triangles face outward.
*
* @param numSides the desired number of sides for each end (≥3)
* @param radius the desired radius of each end (in mesh units, >0)
* @param yHeight the desired total height of the prism on the Y axis (in
* mesh units, >0)
* @param generateNormals true → generate normals, false → no
* normals
*/
public Prism(int numSides, float radius, float yHeight,
boolean generateNormals) {
Here is how you might invoke it to create a triangular prism:
import jme3utilities.mesh.Prism;
//...
Mesh prism = new Prism(3, 1f, 1f, true);
Here is how to add Heart to your project:
4 Likes
Thanks, that is really useful. Am I able to make a right angled triangle/wedge with a preset mesh generator from jMonkey/external library?
1 Like
sgold
July 15, 2022, 3:29pm
7
I don’t know of any, but I’ll take that as a suggestion for Heart v8.1 …
1 Like
sgold
July 23, 2022, 6:09am
8
Heart v8.1.0 was recently released. The Prism
class includes a new constructor for prisms capped with right triangles:
* Normals are no generated. If normals are needed, add them using
* {@link jme3utilities.MyMesh#generateNormals(com.jme3.scene.Mesh)}.
*
* @param x the desired length of the legs parallel to the X axis (in mesh
* units, >0)
* @param yHeight the desired total height of the prism on the Y axis (in
* mesh units, >0)
* @param z the desired length of the legs parallel to the Z axis (in mesh
* units, >0)
*/
public Prism(float x, float yHeight, float z) {
Validate.positive(x, "x length");
Validate.positive(yHeight, "height");
Validate.positive(z, "z length");
int numTriangles = 8;
int numFloats = numTriangles * MyMesh.vpt * numAxes;
FloatBuffer positionBuffer = BufferUtils.createFloatBuffer(numFloats);
setBuffer(VertexBuffer.Type.Position, numAxes, positionBuffer);
float y = yHeight / 2f;
4 Likes