<< Click to Display Table of Contents >> Navigation: »No topics above this level« Simplygon 7.1 examples |
Introduction
This documentation provides an overview of the examples accompanying the SDK. The examples are located in the self-extracting archive "ExamplesSources.exe" that will extract the examples to the "SourceCode" sub folder.
AggregationProcessorExample
Source: AggregationProcessorExample.cpp
This example demonstrates how to use the Aggregation processor to combine geometries in a scene to share one material. A scene with multiple objects and materials is loaded. In this scene we have four instances of the SimplygonMan, one textured utah teapot and one textured plane. The Aggregate LOD will process this scene and export the result as a wavefront file. The resulting scene will have one single texture per material channel (diffuse and specular). Each texture in the scene is combined into these new textures and the texture coordinates are recomputed to map the new textures. As a result, as the four SimplygonMan meshes had the same textures, they will now share texture coordinates. The utah teapot and plane will instead have new unique texture coordinates. The output texture images demonstrates how the textures have been combined.
BoneReductionExample
Source: BoneReductionExample.cpp
This example demonstrates how to do bone LODs. First, we generate a simple geometry with bones and weights and apply a bend function. Next, we optimize the asset, including bones. The bend function is then applied to the bone LOD.
CastingWithTextureBlendExample
Source: CastingWithTextureBlendExample.cpp
This example demonstrates how to setup multi-layered textures with different blend functions for casting.
ChartAggregatorExample
Source: ChartAggregatorExample.cpp
This example demonstrates how to use the ChartAggregator tool to create new UV layouts using original UV charts.
CustomNodeExample
Source: CustomNodeExample.cpp
This example demonstrates how to use a custom node in a material node network. Custom nodes let users define behaviour by specifying their own material casting evaluation and shader code generating functions.
CuttingPlanesExample
Source: CuttingPlanesExample.cpp
This example demonstrates how to setup any number of arbitrary cutting planes for use in the remeshing processor, and implements a simple method of creating a bounding-box aligned set of cutting planes.
DataCreationPreferencesExample
Source: DataCreationPreferencesExample.cpp
This example demonstrates how to use the data creation preferences flag to generate LODs using the same vertex set as the original geometry, and how the AppendPackedGeometry method can be used to allow the LODs and the original model to use a common vertex set, regardless of data restriction setting.
DXExample
Source: DXExample.cpp
This example demonstrates how to use the Simplygon API in a DirectX 9 rendering context, using Simplygon to load assets, create LODs and to calculate the D3D tangent spaces. The asset simplygonman.obj is defined with a right-handed coordinate system, so the triangle winding is reversed and the z-axis inverted as the asset is converted to D3D format to be rendered. The asset is processed and a LOD is generated. The original normal map is defined in D3D tangent space, and a material casting is performed to generate a new D3D normal map for the LOD as well as a new diffuse map.
GeometryExample
Source: GeometryExample.cpp
This tutorial shows how to load the most basic vertex and triangle data into a Simplygon IGeometryData object. An array with coordinates for 9 vertices, and an array with indices for the corners of 8 triangles are created, and then loaded into a IGeometryData object.
GeometryGroupingExample
Source: GeometryGroupingExample.cpp
This tutorial shows how to group several meshes so that they can be reduced as a single mesh.
GeometryValidityTestingExample
Source: GeometryValidityTestingExample.cpp
This example demonstrates how to inspect a GeometryData-object and make sure all stored data inside is valid, and that it is stored correctly. An easier way is to use the IGeometryValidator class to test the validity of a Geometry. However, this example will give you more insight than using a pre-built class would.
GeomorphExample
Source: GeomorphExample.cpp
This example demonstrates how to use Geomorph, i.e. how to generate information that will allow for LOD without popping. As shown in the example, the information can be used to 'slide' vertices in the high poly mesh to their respective positions in the low poly mesh, to produce blends between LOD levels.
ImpostorExample
Source: ImpostorExample.cpp
This example demonstrates how to look use the ImpostorProcessor to generate a billboard impostor for an input mesh from a specific viewing angle, and use the generated mapping image to cast textures from the original model to the billboard in such a way that it will perfectly match the original asset when viewed from the correct angle.
MappingImageExample
Source: MappingImageExample.cpp
This example shows how a loaded geometry is reduced to about ten percent of its original triangle count. The loaded object is textured with a procedurally generated texture. A mapping image is then created for the reduced geometry, the mapping image is then used manually to cast the original material onto the LOD. The textures and the optimized objects are then saved to file.
MaterialCastingExample
Source: MaterialCastingExample.cpp
This example demonstrates how to setup materials in Simplygon and cast diffuse, specular, normals and user channels to create material LODs.
MaterialNodeExample
Source: MaterialNodeExample.cpp
This example shows how to create a material node network. A model is loaded without an original material. A material will be created
solely consisting of material nodes. The node network used is shown in Figure \ref{fig:materialnodefig. Once the material node network is generated, the example will show how to:
•Export generated HLSL/GLSL shader code based on the node network.
•Use Simplygon to render a preview of the model with the material.
•Cast a new MaterialLOD texture from the node network material.
MaterialPartRemoverExample
Source: MaterialPartRemoverExample.cpp
This example removes objects that have homogeneous material ids and are smaller in the scene than a per-material threshold value chosen by the user.
MaterialReplacerExample
Source: MaterialReplacerExample.cpp
This Example shows how a geometry with 13 materials gets replaced or removed down to 6 materials. The materials that gets removed are determined by the least visual cost, where hidden materials and materials that share the same settings have no visual cost.
MultiMaterialCastingExample
Source: MultiMaterialCastingExample.cpp
This example demonstrates how to load an .obj file with materials and then cast the 3 input materials into 2 output materials using input-output material mapping and Simplygon mapping images.
MultithreadingExample
Source: MultithreadingExample.cpp
This is an example of using SimplygonSDK in a multithreaded environment. The example loads a geometry file, runs a number of concurrent reductions, and stores the resulting geometries to file.
OcclusionMeshExample
Source: OcclusionMeshExample.cpp
This example shows how to use the occlusion mesh processor.
PackedGeometryExample
Source: PackedGeometryExample.cpp
This example shows how to use the IPackedGeometryData object to be able to import/export geometries that have per-vertex data where Simplygon use per-corner data. The example loads a wavefront .obj file into a standard IGeometryData object, then creates an IPackedGeometryData object copy, and prints the contents to an output file.
ParameterizerExample
Source: ParameterizerExample.cpp
This example demonstrates how to generate unique texture coordinates for a mesh using the parameterizer tool.
ReductionExample
Source: ReductionExample.cpp
A simple reduction processing example. A wavefront file is opened, the contained geometry of the file is processed in 2 different ways, and then stored back to new files. RunExampleRegular loads in a geometry and does a simple optimization on it, then stores it back to file. RunExampleTextureMapping does an optimization similar to what was just done, however, now texture mapping is also used. Diffuse texture map and tangent space normal map is created.
RemeshingExample
Source: RemeshingExample.cpp
This example shows how to use the remeshing API in Simplygon. The example loads a geometry from file, and then creates 4 level-of- detail geometries based on the original, two of which use a non-zero merge distance. Each LOD is textured with a unique diffuse and normal texture map. The resulting LODs are written along with the maps to file, using a custom built wavefront exporter function.
This example also demonstrates why it's often advantageous to use a non-zero merge distance when remeshing.
SceneDataExample
Source: SceneDataExample.cpp
This example demonstrates how to setup a scene graph in Simplygon, including mesh(geometry), bones and materials.
SurfaceMappingExample
Source: SurfaceMappingExample.cpp
This example demonstrates how to use the SurfaceMapper to generate a mapping image between two user-defined geometries, and use that mapping image to cast materials from one geometry onto the other.
TextureVertexWeightsExample
Source: TextureVertexWeightsExample.cpp
This example shows how a geometry with a diffuse texture is loaded. The loaded geometry is assigned vertex weights which will determine how important the areas are. The geometry gets reduced to about 90\% triangles remaining and a material LOD is generated with the assistance of the vertex weights. The areas with larger vertex weights will get a larger proportional size of the UV texture space area. The vertex weights in the example is distributed to go from higher to lower weights from the top to the bottom of the model, hence the head of the model gets a large part of the UV texture space.
VertexColorBakingExample
Source: VertexColorBakingExample.cpp
This example shows how to bake materials into vertex colors instead of into new textures.
VertexDataExample
Source: VertexDataExample.cpp
This example shows how to include custom vertex-data in a geometry data object, and keep the information through the reduction processing. The example first generates a geometry (a helix) that has vertex-skinning-blend weights applied into the vertices. The helix is then reduced using the reducer. The resulting geometry is then bent using 2 bones and the blend weights, and the result (before and after bending) is output into an obj file.
VertexWeightExample
Source: VertexWeightExample.cpp
This example shows how vertex weights are used to decide how important different vertices are. Vertices with a vertex weights of a value higher than "1.0" is considered an important vertex, while vertices with an vertex weight lower than "1.0" is considered to not be as important. Vertices with a vertex weights of "1.0" are just as important as they normally would be. These weights are used during the reduction process where the reduction is weighted by the vertex weights.
VisibilityWeightExample
Source: VisibilityWeightExample.cpp
This example shows how to perform a visibility-weighted reduction. A wavefront file is opened, the contained geometry of the file is processed in 2 different ways, with and without visibility weighting, and is then stored back to new file. This example and the output models it produces demonstrates the effect of visibility weighting, ie that more visible areas are preserved at the expense of occluded areas.
WavefrontExample
Source: WavefrontExample.cpp
This example shows how to manually import/export geometry data to/from Simplygon. The example implements a wavefront importer/exporter, and also a per-corner data indexer/packer, to remove duplicate data items when outputting to a wavefront file.
Figure 1: Island material from the MaterialNodeExample