I am trying to ray trace the Stanford bunny model which is PLY format. I have a parser which parses the PLY file and gives me the value of co-ordinates of triangles and also their vertices. Now I am confused as to how to proceed ahead. Should I put these triangle vertices in a vector and then pass them to build a k-d tree? Also does someone have a tutorial or a sample source code where a ply model is passed to the k-d tree and the k-d tree is then traversed to ray trace the scene? If anybody has a sample code which they can share, pls let me know. Thanks.
PLY is a file format for objects described as a collection of polygons. A KD Tree is an optimisation structure designed to speed up rendering times by eliminating unnecessary intersection tests.
So you need to:
Define your own data structures for representing objects as a collection of points and a collection of polygons (which refer to the points).
Write a loader which uses the parser to read an object in PLY format, and constructs an instance of your polygon type.
Define a KD Tree data structure.
Write a KD Tree builder which iterates through the polygons which comprise your object and constructs a KD Tree.
Extend your ray-tracer to use the KD Tree.
Use google to find more info and sample code for KD Trees. The standard paper is by Vlastimil Havran which is available on-line.
Related
I want to create a structured mesh with boundary layers over an rather complex geometry in GMSH. For this reason I need to seperate my geometry to smaller portions, one of them is pictured:
Since structured meshes can only be created by extrusion, i would like to know wether it is possible to extrude a rectangle with a dilation, or if there is any other workaround known to generate a similar shape with a structured mesh.
In gmsh structured meshs can also be generated with the 'transfinite' commands.
See examples/simple_geo/hex.geo in the gmsh installation directory for an example.
I have made a house (without roof yet) with some rooms in blender 2.9 and exported it to unreal engine 4. But in Unreal engine i can't move in it with the 3d standard third person character. I can only walk on it as it would be a closed cube or something.
What do i have to do, to be able to walk in it around?
UE is automatically generating a convex (i.e. with no holes, caves, dents, openings, etc.) collision mesh that essentially wraps the whole model. Possibly just a cube. There are a couple of things you can do.
Open the mesh in UE and set the collision complexity to 'use complex as simple'. This isn't advisable unless the mesh is very simple as it uses every polygon in the mesh to query collisions against.
or
Create a set of collision meshes - one for each element of the house (walls, floor, etc.) - and bring them in with the model. These must be convex in shape. See here: Static Mesh FBX Import. You must follow the correct naming convention for the FBX import to recognise them as collision meshes.
If your house model has low enough a polygon count that you would end up with as many polygons in your collection of collision meshes, number 1 saves you the trouble of number 2 (and might even save some memory).
Don't forget everything needs to be triangulated.
I’d like to perform a surface parametrization of a triangle mesh (for the purpose of texture mapping).
I tried using some of CGAL’s algorithms, e.g. ARAP, Discrete Conformal Map etc.
The problem is that the surface parameterization methods proposed by CGAL only deal with meshes which are homeomorphic (topologically equivalent) to discs.
Meshes with arbitrary topology can be parameterized, provided that the user specifies a cut graph (a set of edges), which defines the border of a topological disc.
So the problem now becomes – how to cut the graph properly (using CGAL’s interface).
I found a similar question from 3 years ago that went unanswered.
P.S.
If someone can point me to a different library that can do the job, that’ll be just as great.
Thanks.
I am using the CGAL::Surface_mesh class to represent a 3d triangle mesh. I wanted to use this instead of the Polyhedral_3 mesh due to its simplicity and index structure and ease of use with OpenGL. I am trying to write a method to perform 1-4 subdivision of a triangle and cannot find how to do so in the documentation. Is there a way to split faces (1-4 splitting or barycentric splitting) in a Surface_mesh class similar to the create_center_vertex in Polyhedral_3?
There are a set of generic functions that are working both on Surface_mesh, Polyhedron and even OpenMesh. In the BGL package, see the Euler operations.
The one you are looking for is here.
I'm relatively new to OGRE graphics engine, so my question may seem too obvious, but searching for relevant information was not successful.
Given:
I have an OGRE application with a scene created of some meshes, lights, cameras and textures. It is rather simple, I think. That all is represented by a tree of scene nodes(internal object).
The goal:
To save the full tree of scene nodes or, preferably, an indicated branch of nodes of the tree to a ".mesh" file. To be able load it later as any other mesh. The ".mesh.xml" format is also fine. How it could be done?
If not:
If the desired thing is not possible, what is normal way to create those ".mesh" files? And where I could find some guides for it?
I think you're a bit confused: OGRE mesh file is a file that stores only geometric data of a given 3D model like positions, normals, texture coordinates, tangents, binormals, bone index, bone weights and so on. It also can store a subdivision of a single mesh in submeshes (generally based on the material), and each of them can have a reference to the proper material. In essence a mesh file only contains data on the models you would like to load on your game, nothing about the scene structure.
If you want to save (serialize) your scene, you have two choice:
Write your own scene serializer.
Using some library already provided by the OGRE community: for example DotScene format.
There are Ogre .mesh exporters for programs like Blender. A quick google for Ogre .mesh exporters should help you.