I hope this is a very easy and common use case but I didn’t find any solution about it.
I have a mesh with a lot of triangles. This mesh was created by a 3D scanner and represents a human body. And I have a PNG(or any other type) file and now I want to project this image on a certain point on the mesh.
That’s what I need. Just the projection must be fixed. It’s like a label/sticker which is sticked on the model. I didn’t find a class with the ParallelProjection.
But to use a texture would be nice, too.
The mesh has no texture coordinates. The model was recontructed by a point cloud.
I have a hit point with this model and I want stick a label/sticker on this position of the model.
No, the model is created to the runtime and I have only the coordinates where the sticker must be located on the model. I cannot use blender because it’s in a program.
It is possible to calculate the UV coordinates of the mesh for a certain point?
BUT:
why not:
step 1 → scan model
step 2 → load scanned model into Blender
step 3 → UV this model in Blender
step 4 → export from blender to use in JME
step 5 → add sticker based on UV coords.
done.
Thanks for your hint and I’m willing to write code but I’m unable to this. I’m not 3D expert, I’m proud of me to show the model on a canvas and that I can rotate it. But there, my skills end.
What do you mean with tris?
I have the coordinates and the normals. It is not possible to says:
That’s my coordinate on the model and this it’s start point of image which should be draw on the this part of the model.
“tris” is the word that mean triangle in mesh, mesh(geometry shape) is constructed from triangles.
also one “face”(quad) = 2 trangles.
normals refer to quads(face direction) [if i good remember not tris, but quads.]
Tris have position, correct, each verticle of tris have position, but please note UV is 2d coords, while verticle have 3d coords. its just about how you want map your model triangles to match 2d coords in UV.
what i said was that some “tris” what is almost not visible in viewport, while doing his projecting solution it would have “too small area in 2d UV coords”, for color it would be ok, but if you would want to perfectly texture model, then you need better UV than a projected one.
An alternate approach I just thought of would be to import the mesh into Blender 3D and generate the texture coordinates there.
I’m also willing to walk you through the coding process in more detail. In JMonkeyEngine, a mesh is composed mostly of buffers. Have you worked with buffers in Java before?
An alternate approach I just thought of would be to import the mesh into Blender 3D and generate the texture coordinates there.
he said he cant, because it change each time in runtime. or maybe you mean some automatic solution? like running via console “.blender -generate-uv .someFileWithMesh.obj” ? kind of?
@homerj
anyway what @sgold said would be quite easy and will work for color + circle.
step 1) read each quad(2 triangles) from mesh
step 2) for each verticle of quad, check position in viewport(monitor window)
step 3) based on position in viewport, set same position in some UV list(but can be scaled)
step 4) update mesh UV buffer with new coords.
step 5) apply image with circle you want as image for UV where circle will be in position where UV match place you want to have this circle
public static void calcUVCoords(Mesh mesh) {
List<Triangle> tris = new ArrayList<>();
for(int i=0;i<mesh.getTriangleCount();i++) {
Triangle tri = new Triangle();
mesh.getTriangle(i, tri );
tris.add(tri);
}
List<Quad> quads = new ArrayList<>();
for(Triangle tri:tris) {
// triangle to quads????
}
}
What do you mean with check each verticle of quad in viewport?