|
Proxy templates are a bit tricky to understand at the begining. Once you get around it , you will be able to speed up the rigidbody creation time by x100 atleast.
The following are the steps: ( a diagramatic flow chart is here )
1.CreateProxyTemplate() - For example , if you plan to create a proxy template for a mesh named "coderecipe".
| CreateProxyTemplate() |
1 2 3 4 5 6 7 8 9
|
--Create proxy template for the coderecipe model --The proxy symbol can be of type #convexDecomposed , #concave, #convex --#convexDecomposed - use it for dynamic-concave, static-concave --#concave - can be used only for concave-static --#convex - can be used only for convex-static and convex-dynamic -- Every model has a resource associated with it,use the resource to create proxytemplates physX = member("physics") -- this is a dynamiks cast member proxyTemplate = physX.createProxyTemplate(coderecipe.resource,#convexDecomposed,\ [#concavity:3, #depth:6,#mergeVolume:3])
|
The above code snippet creates a proxytemplate from the given model resource.
2.AddproxyTemplate() - You ant to add the created proxy template to a 3d world ( 3d cast member )
| AddProxyTemplate() |
1 2 3 4 5 6 7 8 9 10 11
|
_return = physX.AddproxyTemplate(member("cr_proxyTemplates"),proxyTemplate,\ "coderecipe" & "_CD_proxyTemplate") -->_return holds the success result, 0 - error -->cr_proxyTemplates -name of the 3d member to store the created proxy -->Just to make life easier, use proper notations: --Example: --_CD - convex decompsed --_CS - concave static --_CX - convex -->The above approach allows you to store the created proxy into a --3d member for later use.
|
The above 2 steps completes the process of creating proxyTemplates.
Next is to use these created proxy templates within your physics engine...
3.LoadProxyTemplate() - load the proxy template from the 3d world.
| LoadProxyTemplate() |
1 2 3 4 5
|
--cd - convex decomposed saved_proxy = physX.loadProxyTemplate("coderecipe_CD_proxyTemplate",\ member("cr_proxyTemplate")) --saved_proxy will have the required details to create rigid body --The model resource type would be of type #physicsmesh
|
4. CreateRigidBodyFromProxy() - create rigidbody from the loaded proxy template.
| createRigidBodyFromProxy() |
1 2 3 4 5 6 7 8 9
|
rb_coderecipe = physX.createRigidBodyFromProxy(m_coderecipe.name,m_coderecipe.name,\ #dynamic,saved_proxy) --m_coderecipe = member("3dWorld").model("coderecipe") --rb_coderecipe - the dynamic concave rigidbody --set its mass and other properties rb_coderecipe.mass = 20 rb_coderecipe.restitution = 0.5 --saved_proxy can be used to create rigidbodies out of any m_coderecipe --model independent of scale and transform.
|
The ideal approach would be to create proxy templates for all the required models in a game, save them into a separate 3d member and use them when required.
Thats it. Now you are on your way to create those rigid bodies for complex meshes.
Requirements:
Adobe Director 11.5 A good system with a decent graphics card. Atleast 1 gb RAM
|