aboutsummaryrefslogtreecommitdiff
path: root/docs/api_docs/files/pageextassetutils.html
blob: f2e8dad66ec5602962bc5b9b0af6c5ac56786f0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<html>
	<head>
		<title>NVIDIA(R) Blast(R) SDK 1.1 API Reference: Asset Utilities (NvBlastExtAssetUtils)</title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<LINK HREF="NVIDIA.css" REL="stylesheet" TYPE="text/css">
	</head>

	<body bgcolor="#FFFFFF">
		<div id="header">
			<hr class="first">
			<img alt="" src="blast_logo.png">
			<br>
			<center>
				<a class="qindex" href="main.html">Main Page</a> &nbsp; 
				<!-- <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; //-->
				<a class="qindex" href="annotated.html">Class List</a> &nbsp; 
				<a class="qindex" href="functions.html">Class Members</a> &nbsp;  
			</center>
			<hr class="second">
		</div>
<!-- Generated by Doxygen 1.5.8 -->
<div class="contents">
<h1><a class="anchor" name="pageextassetutils">Asset Utilities (NvBlastExtAssetUtils) </a></h1>NvBlastExtAssetUtils provides simple utility functions for modifying <a class="el" href="struct_nv_blast_asset.html">NvBlastAsset</a> objects. Three functions are provided, described in the following sections.<p>
<br>
 <h2><a class="anchor" name="addworldbonds">
Add World Bonds</a></h2>
The function NvBlastExtAssetUtilsAddWorldBonds allows the user to create an asset from an existing asset, with the addition of new bonds that connect support chunks to the world. (See the documentation for <a class="el" href="struct_nv_blast_bond_desc.html">NvBlastBondDesc</a>.)<p>
For example, given an asset called <em>oldAsset</em>,<p>
<div class="fragment"><pre class="fragment"><span class="keyword">const</span> uint32_t worldBoundChunks[3] = { 1, 2, 3 };   <span class="comment">// Chunks to bind to the world.  These must be support chunks.</span>
<span class="keyword">const</span> <a class="code" href="struct_nvc_vec3.html">NvcVec3</a> bondDirections[3] = { { -1, 0, 1 }, { 0, 0, -1}, { 1, 0, 0 } };   <span class="comment">// Normal directions for the new bonds.</span>

<span class="comment">// Create a new asset</span>
<a class="code" href="struct_nv_blast_asset.html">NvBlastAsset</a>* newAsset = <a class="code" href="_nv_blast_ext_asset_utils_8h.html#df802362e469fcaa8a40cb9f787b9e60">NvBlastExtAssetUtilsAddWorldBonds</a>(oldAsset, worldBoundChunks, 3, bondDirections, NULL);
</pre></div><p>
Memory for the new asset is allocated using the allocator available through NvBlastGlobals (<a class="el" href="pageglobalsapi.html">Globals API (NvBlastGlobals)</a>). Therefore the new asset may be freed using<p>
<div class="fragment"><pre class="fragment"><a class="code" href="_nv_blast_globals_8h.html#f968d9c2dc2aaeb87f55bbd85488f741">NVBLAST_FREE</a>(newAsset);
</pre></div><p>
<br>
 <h2><a class="anchor" name="mergeassets">
Merge Assets</a></h2>
The NvBlastExtAssetUtilsMergeAssets function will combine any number of assets, generating an asset descriptor which may be passed to NvBlastCreateAsset. This is done in order to allow the user to make adjustments to the descriptor before creating the merged asset.<p>
The geometric data in each asset to be merged may be transformed so that the assets will have desired relative poses. In addition, the user may describe new bonds, in order to join support chunks of two different assets and create a larger support graph which spans the entire combined asset. The reference frame for the new bonds' geometric data is that of the new asset.<p>
For example, if one wants to merge two wall assets together, with a relative translation between them of 10 units in the x-direction, the code might look something like this:<p>
<div class="fragment"><pre class="fragment"><span class="keyword">const</span> <a class="code" href="struct_nv_blast_asset.html">NvBlastAsset</a>* components[2] = { asset0, asset1 }; <span class="comment">// asset0 and asset1 are already created</span>
<span class="keyword">const</span> <a class="code" href="struct_nvc_vec3.html">NvcVec3</a> translations[2] = { { -5, 0, 0 }, { 5, 0, 0 } };  <span class="comment">// Translate asset0 -5 in x, and asset1 +5 in x</span>

<span class="comment">// New bonds:</span>
<span class="keyword">const</span> uint32_t newBondCount = ...   <span class="comment">// Some number of new bonds</span>
<span class="keyword">const</span> <a class="code" href="struct_nv_blast_ext_asset_utils_bond_desc.html">NvBlastExtAssetUtilsBondDesc</a> newBondDescs[newBondCount];
newBondDesc[0].bond.normal.x = 1;   <span class="comment">// Normal in the +x direction, pointing from asset0 to asset1</span>
newBondDesc[0].bond.normal.y = 0;
newBondDesc[0].bond.normal.z = 0;
newBondDesc[0].bond.area = 1;
newBondDesc[0].bond.centroid.x = 0;
newBondDesc[0].bond.centroid.y = 0;
newBondDesc[0].bond.centroid.z = 2.5;   <span class="comment">// Position is in the middle, off the ground</span>
newBondDesc[0].bond.userData = 0;
newBondDesc[0].chunkIndices[0] = 5;     <span class="comment">// Connect from chunk[5] in components[componentIndices[0]]</span>
newBondDesc[0].chunkIndices[1] = 13;    <span class="comment">// .. to chunk[13] in  components[componentIndices[1]]</span>
newBondDesc[0].componentIndices[0] = 0; <span class="comment">// Connect asset in components[0]</span>
newBondDesc[0].componentIndices[1] = 1; <span class="comment">// .. to the asset in components[1]</span>

<span class="comment">// Create merged asset descriptor</span>
<a class="code" href="struct_nv_blast_asset_desc.html">NvBlastAssetDesc</a> mergedDesc = <a class="code" href="_nv_blast_ext_asset_utils_8h.html#1486283b3fce176c10246113da3a7633">NvBlastExtAssetUtilsMergeAssets</a>(components, NULL, translations, 2, newBondDescs, newBondCount);
</pre></div><p>
Note, we passed in NULL for the list of relative rotations, meaning no asset will be rotated.<p>
Also note, the new bond descriptors can just as well apply to a single asset (by setting both component indices to the same index), allowing the user to create additional bonds within a single asset if desired.<p>
The chunk and bond arrays referenced by the returned <a class="el" href="struct_nv_blast_asset_desc.html">NvBlastAssetDesc</a> are allocated using the NvBlastGlobals allocator, and it is up to the user to free this memory when it is no longer needed:<p>
<div class="fragment"><pre class="fragment"><a class="code" href="_nv_blast_globals_8h.html#f968d9c2dc2aaeb87f55bbd85488f741">NVBLAST_FREE</a>(mergedDesc.<a class="code" href="struct_nv_blast_asset_desc.html#262022943f835bbbf7c937b485f47cd7">chunkDescs</a>);
<a class="code" href="_nv_blast_globals_8h.html#f968d9c2dc2aaeb87f55bbd85488f741">NVBLAST_FREE</a>(mergedDesc.<a class="code" href="struct_nv_blast_asset_desc.html#f9ee95aba486c075fe87d8a117727d4f">bondDescs</a>);
</pre></div><p>
<br>
 <h2><a class="anchor" name="transforminplace">
Transform In-Place</a></h2>
The NvBlastExtAssetTransformInPlace function will apply an affine transformation (given by scaling, rotation, translation components) to the geometric data within an asset.<p>
To use this function, simply pass in an <a class="el" href="struct_nvc_vec3.html">NvcVec3</a> pointer to represent scale (which may be non-uniform), an <a class="el" href="struct_nvc_quat.html">NvcQuat</a> pointer to represent rotation, and an <a class="el" href="struct_nvc_vec3.html">NvcVec3</a> pointer to represent translation. Any of these pointers may be NULL, in which case that transform component is implicitly considered to be the identity. This transforms:<p>
<ul>
<li>Chunk centroids</li><li>Chunk volumes</li><li>Bond normals</li><li>Bond areas</li><li>Bond centroids</li></ul>
<p>
The transformation of position vectors is done in the following order: scale, followed by rotation, followed by translation.<p>
The transformation of normal vectors uses the cofactors of the scale matrix (diagonals given by {scale.y*scale.z, scale.z*scale.x, scale.x*scale.y}), followed by rotation. <br>
 </div>
<!-- start footer part -->
<div class="footer">
Copyright &copy; 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. <a href="http://www.nvidia.com ">www.nvidia.com</a>
</div>
</body>
</html>