CodeRecipe( );

one stop for all game coders..

Follow us on Twitter
Home
Rigid Body creation - D11.5 Print E-mail
User Rating: / 2
PoorBest 
Written by CR Team   
Saturday, 18 July 2009 07:45

The previous article talked about creation of rigid body from models/mesh. This process can sometimes take time due to the complexity of the mesh. Also the createRigidBody( ) method would not allow one to create dynamic concave rigid bodies.rbody

Before going into the details we need to understand what a proxy template is…

A proxy template allows a user to create pre-calculated proxy/hull for a given model and then use it.

This has several advantages:

  1. It can be saved and used later , hence avoids over head during run time.
  2. The proxy template can be used to create rigid bodies for models of varying size. Say you have a Robot of different sizes ( scaled ), once you have created a proxy template for the robot , you can use the same proxy template to create rigid body for the different variation of sizes of Robot model. The scale and transforms are not stored in the proxy template and picked up from the model.
  3. You can use the created proxy template for convex, concave all being dynamic or static.

There are basically 2 workflows that can be followed with the new set of methods provided.

proxytemplate_workflow

Out of the 2 workflows, we recommend using the authoring one to avoid the overhead of creation of proxy templates each time.

The blocks in blue are the newly added methods for creating proxy temlates in Director 11.5. For more info on each of the methods refer the help doc.

 In workflow-1 ,steps from createproxyTemplate() to saveW3d() , can be performed once for creating the required proxy templates for all the models in the 3d world. During runtime, only loadProxyTemplate() and createRigidBodyFromProxy() methods need to be used as the proxy templates are already saved in the specified 3d member. Use of message window or running through all the models with a loop and creating the required proxy templates and save them into a 3d member using saveWorld() or saveW3d() methods would be ideal.

Some tips while using these methods:


createProxyTemplate
1
2
createProxyTemplate(ModelResourceRef, #proxyTemplateSymbol, decompositionlist)
--the decompositionlist is valid only for #convexDecomposed proxy template type.

ModelResourceRef - model resource cannot be Director primitive(like #box,#sphere etc..) except #mesh type. All other w3d modelresource are allowed.

proxyTemplateSymbol -
#concave ( for static concave rigid body :RB),
#convex ( for dynamic/static convex RB),
#convexDecomposed ( for static/dynamic concave RB)

decomposition parameter list -

#depth ( number of cross sectional planes running through a model , lesser the faster, range:0-10 , ideal:4-8) ,
#concavity ( value that defines what %age of concavity compared to the whole body should be considered, range:0-100, ideal:4-60),
#mergeVolume ( %age of a broken mesh compared the whole body which needs to be discarded or kept , range: 0-100,ideal:4-60)


AddProxyTemplate
1
addProxyTemplate(3dmember, proxyTemplate, string proxyname)

3dmember - a 3d world , ideally would be nice to have one 3d world dedicated to proxy templates to avoid all the confusion.

proxyTemplate - this is the template returned by createproxyTemlate() method.

proxyname - a unique name for the proxy template, use conventions like cdx_name, ccv_name,cvx_name for #convexdecomposed, #concave and #convex proxy templates respectively.

One can visualize the proxy/hull created using the rb.properties property of the rigid body. For a more detailed explaination on using this in you code have a look at the Proxy Template Howto tutorial !