I am having trouble implementing the Polygon-Soup Collision detection on this page. I have implemented the methods presented in that paper but I am not sure how to get the values for the CollisionPacket class. Can anyone help me in getting the values for the CollisionPacket class?
EDIT: I have implemented that, but how can get the triangles of the mesh from its vertices for the checkTriangle() method?
I found the answer. It was to obtain the vertex positions while loading the .obj files and store it in the RawModel class in my game. Thanks for any help.
Related
I created a model in Blender of a block with a hole in it:
I export it as an .obj file, and import it in ThreeJS with the OBJLoader add-on.
When I use it in my app, it appears to draw a face over the sides of the hole:
Is there a setting I need to use in ThreeJS to avoid having it close over gaps like this? Or is the problem in how I'm creating the model? I'm totally lost here, any guidance appreciated.
EDIT: I discovered through trial-and-error that the problem is having irregularly-shaped faces, like the ones adjacent to the hole. I "solved" my problem by triangulating the model; while this changes its shape slightly, it ensures that every vertex in the hole is part of a triangle face, which seems to be the magic answer.
I'm still very curious about why this is, especially since the triangulation has made the corners of the box a bit weird.
EDIT 2: Sorry for the delay. Here's the blender file: https://gofile.io/?c=EoxH1r
The problem you are having is because of ngons (polygons with more than 4 sides).
Modelling for three.js is just like modelling for games, so it is best to avoid polygons with more than 4 sides because when the renderer (or video card, I dunno) tries to render the model, it has to apply triangulation and may do it in an unexpected way.
As you said, applying triangulation to the model fixed the issue, but automatically applying triangulation in your modelling app may also yield unexpected results. So your best bet is to alter the model so you get the results you expect.
Here is a youtube video I found that seems to explain a lot about ngons.
https://www.youtube.com/watch?v=BjnCV2PIkKA
(though I only watched the first minute or so)
Here is an example of how I would do it, red lines representing added edges. Remember to do it all the way around on both sides and apply your smoothing groups before exporting.
I am new in forge. How we can get the coordinates or the threejs Vector of the object by its ID like "getBoundingBox"? e.g. I want to get the coordinates of the wall of the house.
Mesh.geometry
Geometry.computeBoundingBox()
Geometry.center()
Hope helpful.
This sample code shows how to draw a bounding box around an element. The coordinate of an element may vary according to the inser or reference point that you consider for each one.
What you need in your case is getting coordinates on the vertices rather than the bounding box, which may be quite approximative in some cases. Take a look at this article for pointers on how to get started:
Accessing mesh information with the Viewer
I have a set of points(x,y,z) in space and from them i need to create a surface and triangulate it. In theory it should be something like parametric-generated surface.
I have tried projecting points on 2d, triangulate it and put it back in 3D, but this doesn't work for me, also tried few algoritms but main problem, that i have is all of them gives back polyhedron-shaped object, but my goal surface-shaped triangulated object. I need some help with algorithms/different approach to problem
You need to implement BallPivoting, give a look to: http://www.research.ibm.com/vistechnology/pdf/bpa_tvcg.pdf
I've been fighting with a three.js issue for a few 12 hour days trying to determine why some outward pointed object faces are missing. It only seems to happen if I've modified the mesh model, extruded a plane, or knife projected a hole into a mesh.
I've found a few solutions online that don't seem to be working for me: I've added in the double-sided hack for all materials and this does allow me to see into objects with holes so it is partially working. I've fiddled with different importers (JSONLoader, OBJLoader) which all seem to have the same issues as listed above, so it leads me to believe it is indeed the model itself.
The research I've seen online says that modifying a mesh can leave the normals screwed up so any faces I CAN'T see on my model viewer I just flip and do the UV Map again, but this doesn't fix it.
I'm hoping someone who knows Blender and three.js will know what the problem is. I know it's simple and I'm just missing a step because I'm new.
Here's a link to the demo site and code: http://guitar.dodgestat.com/objloader/
It seems that OBJMTLLoader can handle only triangles and quadrangles, but obj files can describe faces with any number of vertices, but the faces should be convex.
If you check your model with http://3dviewer.net, you can see that every face exists, but there are some issues with non-convex faces.
So I recommend you to triangulate your model before export.
I would like to draw graphs with Three.js and wonder what is the best way for it.
This framework here https://github.com/davidpiegza/Graph-Visualization solves it in using spheres as nodes and lines as edges.
I would need to add labels to the edges or alternatively can select the edges.
What other ways are there to draw graphs? Does anyone have an idea?
You should check out MathBox http://acko.net/blog/making-mathbox/ (which is based on three.js and the author's shader library ShaderGraph.js). The MathBox uses his library for many of this interactive 3d Math examples found on his blog. http://acko.net/blog/