Open topic with navigation
Physics shapes is what becomes of a node3d object once it has a collision area defined. When a node3d object has a collision area defined it gains certain properties that allows it to interact with forces as well as other physics objects.
Physics objects can be created by the following methods:
The collision area around the object is a box that is structured to fit as close as possible around the object. Optionally an x,y,z component can be added to define the size of the box.
Note: The last line is only there to show what the collision area looks like. It is not necessary for the creation of the physics object and only works with objects that are centered at 0,0,0.
The collision area around the object is a sphere which can take an optional radius parameter. See how the following varies from the previous:
Note: The last 2 lines are only there to show what the collision area looks like. With this notice how the scale is calculated for the collision area of a sphere. Vizard internally creates a bounding box around the object and then takes 1/2 the max of height, width, and depth to be used as the radius. Since the radius of white_ball is .1 the scale must be 10 times the radius.
The collision area around the object is a sphere with a cylinder inserted between the two halves of the sphere. The collideCapsule method calculates the length of the cylinder along the object's z-axis, so to use this the elongation must be along the object's z-axis.
Note: There is no simple way to build the visualization of a collision area for a capsule. However the radius of the sphere that is used for the ends is calculated by taking 1/2 the max of the objects width, and height. The length the of cylinder is then the objects depth minus the diameter of the sphere.
The collide mesh builds the collision area of the object exactly as the object itself is built. Collide mesh objects are unaffected by forces and can only provide a solid collision area for other objects. The following example demonstrates this:
Collide plane creates a collision plane based on the objects initial position. The collision plane does not move with the object so should only be called once the object is in the appropriate place.
Collide copy performs exactly as it seems it should. Once an collision area is defined for an object, duplicating the collision area is as simple as calling collideCopy on the new object using the old object as the parameter.
In the following example a collision area is defined for one table, and then copied to the next:
This function removes and previously defined collision area. This in turn disables physics on the object.
Turing a node's visibility off disables its physics. If you want to retain the physics of a node and not have it appear there are two options:
1. Use a nested object
Create a group and add the object you wish to set invisible to it. Enable physics on the root object and then disable visibility on the child object.
2. Disable rendering and depth_write
Create the object as normal and then assuming the object is named "a":
The physics of a node are controlled through two properties, dynamics and contacts which are enabled by default. When dynamics is enabled the node reacts to forces such as gravity. When contacts is enabled collisions may occur. In order for these properties to have any effect physics must be enabled on the node.
Example 1 - Disabling contacts before enabling physics
Example 2 - Disabling dynamics before enabling physics
Physics Shapes - In depth discussion of the collide methods.
Forces - More detail on applyForce and applyTorque.
Joints - In depth overview of the joint types.
Motors - In depth explanation of how each motor works with each joint.
Physics Command Table
Tracking an object
Callbacks & complex shapes
Forces & materials