3D Resource Objects
In this demo, resource geometry is separated from the 3D hierarchy so that the same resource can be used multiple times in the 3D world. One advantage to this is animating the resource will animate all appearances of it—the three discs in the demo below all use the same disc resource.
Drag off objects to rotate group
3D Resource Objects – source movie
The resources in this demo are programmed as trees, and consist of a root node with the faces as its children. To use a resource in the 3D world, the “resource” property of a 3Dnode is made a reference to the root of a resource tree:
With this arrangement rendering involves traversing the 3D world tree, and when a 3Dnode uses a resource, traversing the resource tree and rendering its nodes.
Use of Inheritance
The nodes in the two types of trees in this demo, 3D world tree and resource trees, both need tree-related properties and methods but also need properties and methods unique to each type of tree. For example, nodes in the 3D world tree need a resource property to point to a resource, while nodes in a resource tree need a list of vectors to store geometry. Programming this using inheritance is a good way to go.
To do that, a script called “treeNode” is programmed as a generic tree node, with parent and child properties and methods for managing a tree. This script serves as the ancestor for 3Dnode and resNode, the two types of nodes that make up the 3D world tree and resource trees, respectively. The 3Dnode and resNode scripts contain the properties and methods unique to their respective tree types.
Inheritance is used again for the scripts that automate creation of different resources geometries such as cylinders, planes, cubes, etc. These scripts inherit the resNode script and function as the root of the resource trees. (They also inherit treeNode via resNode).
Animating the Resource
This animation uses a “spring system” which is a bunch of objects that act on each other with spring forces (as if they were connected by springs). The objects in this case are the vectors that specify the outer edge of the disc resource. These vectors are stored in the edgeVerts list of the resDisc object.
Using forces means using the physics model (position, velocity, acceleration):
spring1 = (zInit[i] – verts[i].z) * .04
spring2 = (verts[prevI].z – verts[i].z) * .08
spring3 = (verts[nextI].z – verts[i].z) * .08
— acceleration, velocity, position
zAccel = spring1 + spring2 + spring3
zVelo[i] = zVelo[i] + zAccel
verts[i].z = verts[i].z + zVelo[i]
— dampen velocity
zVelo[i] = zVelo[i] * .9
modelFrame() method in script “discWave”
The disc resource lies in the x-y plane so the wave is created by animating the z coordinates of the edge vectors.
Three spring forces act on each vector, all given by the spring formula (restPosition – position). The first pulls the vector back to its initial position. The second two cause the vectors on either side to pull the vector in their direction, which creates the wave.
The velocity is dampened so the wave eventually dies out.
The wave is started by setting the velocity of a vector (zVelo[i]) to a non-zero number.
•What would happen if only the first spring force was used? What if only the last two were used?
This animation can be done in Shockwave 3D by animating a mesh vertexList.
- The Services requiring the submission
- find caskets los angeles