aboutsummaryrefslogtreecommitdiff
path: root/docs/contrib/creating_landscape_collisions.html
blob: 4731b944d8d97f647259dab3dbdf2cb73d851644 (plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>NeL Collisions</title>
	
</head>

<body>

<h1>How to create collisions in a landscape</h1>
<h2>License</h2>

<p style="font-size:10px; color:gray;">
	<!-- style="font-size:9px; font-family: Tahoma, Verdana, sans-serif; color:gray;" -->
    Copyright (C) 2002,  Philippe Lamoureux, phlam@noos.fr<br>
<br>
    This program is free software; you can redistribute it and/or modify<br>
    it under the terms of the GNU General Public License as published by<br>
    the Free Software Foundation; either version 2 of the License, or<br>
    (at your option) any later version.<br>
<br>
    This program is distributed in the hope that it will be useful,<br>
    but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>
    GNU General Public License for more details.<br>
<br>
    You should have received a copy of the GNU General Public License<br>
    along with this program; if not, write to the Free Software<br>
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA<br>
</p>

<h2>Description</h2>
<p>During the build-gamedata process, NeL patches automatically generate a collision layer.<br>
To insert a mesh into your landscape and have your character collide it, you have to manually add collision informations.<br><br>

This document shows how to create this kind of collisions in 3DSMax and export / test them in the Snowballs demo.
</p>

<h2>Requisites</h2>
You need the following configuration :
<ul>
	<li>3DSMax and NeL plugins</li>
	<li>A working Snowballs demo</li>
	<li>Snowballs 3DSMax .max source files</li>
	<li>The build_gamedata package, and especially :
		<ul>
		<li>the /build_gamedata/bin/build_indoor_rbank.exe tool</li>
		<li>the /build_gamedata/processes/rbank/build_indoor_rbank.cfg configuration file with the following options
			<ul>
			<li>Merge = 1;</li>
			<li>MergePath = "smooth/";</li>
			<li>MergeInputPrefix = "snowballs";</li>
			<li>OutputPath = "retrievers/";</li>
			<li>MergeOutputPrefix = "snowballs";</li>
			</ul>
		</li>
		</ul>
	</li>
</ul>
Backup your original Snowballs files : some of them will be changed by this process.<br>
Copy the original snowball.gr and snowballs.rbank files from /snowballs/data/pacs/ into /build_gamedata/processes/rbank/smooth/<br>

<h2>Overall process</h2>
<p>
<ul>
	<li>In 3DSMax
	<ul>
		<li>Load a .max Zone file</li>
		<li>Create a mesh</li>
		<li>Export its .shape file in /snowballs/data/shapes</li>
		<li>Select the whole scenery objects and export the instance group file, replacing the old /snowballs/data/zone/&lt;zone&gt;.ig file</li>
		<li>Create an interior collision mesh (explained hereafter)</li>
		<li>Create an exterior collision mesh (explained hereafter)</li>
		<li>Select all the collision meshes and export the collisions (Utilities / NeL Export / Export collisions), point to the /build_gamedata/processes/rbank/cmb/ directory</li>
	</ul></li>
	<li>Launch /build_gamedata/processes/rbank/3_build.bat to build and merge the new collision data to the original Snowballs collision.</li>
	<li>Replace the files snowballs.gr and snowballs.rbank in /snowballs/data/pacs/ with the new ones from /build_gamedata/processes/rbank/retrievers/</li>
	<li>Launch Snowballs</li>
</ul>
</p>
<h2>Details on collisions</h2>
<h3>Pairs</h3>
<p>
In a landscape, every collision system is composed of two objects : an interior and an exterior mesh<br>
<ul>
	<li>The interior mesh is a mesh on which the user can walk,</li>
	<li>The exterior mesh acts as a collider in the landscape (visible open edges) and a bridge between the landscape and the interior collision mesh (invisible open edges).<br>
		(An 'open' edge is an edge that belongs to only one face).
	</li>
</ul>
Even if there is no need for an interior collision mesh, this mesh must be present :
</p>
<table  width=800 cellspacing=20 align="center">
<tr>
	<td><img src="simple_cube_visible.jpg" width="360" height="180" alt="" border="0"></td>
	<td><img src="simple_cube_coll.jpg" width="360" height="180" alt="" border="0"></td>
</tr>
<tr>
	<td valign="top">Here is a simple box placed on the landscape</td>
	<td valign="top">
		The 'exterior' collision mesh prevents the player from crossing the visible mesh<br>
		The 'interior' collision mesh is of no use, but it has to be present.
	</td>
</tr>
</table>
<h3>Frontiers</h3>
<p>
To have the character walk on a mesh, like a staircase or a ramp, the exterior and interior
collision meshes must have overlapping invisible open edges.<br>
Every invisible edge in the exterior mesh must have a corresponding 'snapped' edge in the interior mesh.
</p>
<table  width=800 cellspacing=20 align="center">
<tr>
	<td><img src="ramp_visible.jpg" width="366" height="208" alt="" border="0"></td>
	<td><img src="ramp_coll.jpg" width="366" height="208" alt="" border="0"></td>
</tr>
<tr>
	<td valign="top">Ramp raising from the ground, the player cannot walk under it.</td>
	<td valign="top">
		<ul>
			<li>The visible edges of the exterior mesh block the user coming from the landscape</li>
			<li>The visible edges of the interior mesh prevent the user from falling out of the ramp</li>
			<li>The superposed invisible edges of both the interior and the exterior meshes indicate a connection between the landscape and the ramp</li>
		</ul>
	</td>
</tr>
</table>
<h3>Objects informations and constraints</h3>
<p>
<ul>
	<li><strong>Node properties</strong><br>
		(Utilities / NeL Export / Node Properties / Instances Tab)<br>
		The two collision meshes have the same non null Instance group name.<br>
		The interior collision mesh has the 'Collision Mesh' property checked.<br>
		The exterior collision mesh has both the 'Collision Mesh' and 'Collision Mesh Exterior' properties checked.<br><br>

	</li>
	<li><strong>Edges</strong><br>
	Both objects must have the same number of invisible open edges,<br>
	the vertices of the interior mesh along these edges must be 'snapped' to those of the exterior mesh (same position).<br><br>

	</li>
	<li><strong>Material ID</strong><br>
		Exterior collision mesh : <br>
		The faces must have the MatID 666.<br><br>

		Interior collision mesh : <br>
		Verify that the faces along the open edges have a unique material ID : Faces that have different
		matIDs are separated in different meshes at export time, this generates new 'open' edges that can't match a corresponding
		edge on the exterior collision mesh.<br><br>

	</li>
</ul>
</p>
<h3>Complex collisions</h3>
<table width=800 cellspacing=20 align="center">
<tr>
	<td>The following example is composed of two collision systems</td>
	<td></td>
</tr>
<tr>
	<td><img src="rampncollumn_0.jpg" width="360" height="219" alt="" border="0"></td>
	<td></td>
</tr>
<tr>
	<td><img src="rampncollumn_1.jpg" width="360" height="219" alt="" border="0"></td>
	<td><img src="rampncollumn_2.jpg" width="360" height="219" alt="" border="0"></td>
</tr>
<tr>
	<td valign="top">A connection between the landscape and the ramp, but the exterior mesh only blocks the path around the start :
	the player can walk under the ramp.</td>
	<td valign="top">
		A collision at the base of the ramp.
	</td>
</tr>
</table>

<h3>Remark</h3>
<p>
For now this system cannot create bridges.<br>
You can have a collision that has two or more distinct connections with the landscape, but the exterior mesh cannot be broken into
multiple meshes, so you couldn't go onto and under a bridge<br>
<br>
<br>
<br>
<br>
<br>
</p>

</body>
</html>