Hiding Meshes Resource for torqueX
by David Everhart · in Torque X 2D · 06/24/2008 (11:20 pm) · 2 replies
Below is a link to the one I found , but it looks like it is for TGE or TGEA:
Hiding Meshes resource
I have gone through the C++ code in the above resource, and using it as a guide, was able to identify in the shapeinstance class where the meshes are rendered inthe Torque X code. The T3DDTSRenderer has a hiddenmeshes property, but that only allows you to set the mask that is used for filtering out what meshes to show (per the dev comments, its kinda hit and miss).
Before I really dig into it, and possibly implement an overload that takes in an array of mesh indexes to filter out, and implement my own logic in the filtering logic, I wanted to see if anyone done this yet for Torque X. No need to reinvent the wheel if so :)
Hiding Meshes resource
I have gone through the C++ code in the above resource, and using it as a guide, was able to identify in the shapeinstance class where the meshes are rendered inthe Torque X code. The T3DDTSRenderer has a hiddenmeshes property, but that only allows you to set the mask that is used for filtering out what meshes to show (per the dev comments, its kinda hit and miss).
Before I really dig into it, and possibly implement an overload that takes in an array of mesh indexes to filter out, and implement my own logic in the filtering logic, I wanted to see if anyone done this yet for Torque X. No need to reinvent the wheel if so :)
Torque Owner David Everhart
I was able to get the essence of the hiding meshes resource to work. I had to expose the _meshObjects objectInstance[] of the ShapeInstance class, since it was hidden. Once it was exposed, I used john kanalkis's structure for creating a DTS, and then added the following to the bottom as a test:
string[] bodyparts = new string[] {"TestMan_v006:Feet1","TestMan_v006:Legs1","TestMan_v006:Torso1","TestMan_v006:Arms1","TestMan_v006:Head1"}; //string[] bodyparts = new string[] { "TestMan_v006:Feet", "TestMan_v006:Legs", "TestMan_v006:Torso", "TestMan_v006:Arms", "TestMan_v006:Head" }; //string[] bodyparts = new string[] { "TestMan_v006:Feet1", "TestMan_v006:Legs", "TestMan_v006:Torso1", "TestMan_v006:Arms", "TestMan_v006:Head" }; // Hide all meshes initially for (int index = 0; index < componentRender.Shape.Objects.Length; index++) { componentRender.ShapeInstance.MeshObjects[index].Visibility = 0.0f; } // Turn on the meshes in the bodyparts array for (int bodyPartIndex = 0; bodyPartIndex < bodyparts.Length; bodyPartIndex++) { for (int objectIndex = 0; objectIndex < componentRender.Shape.Objects.Length; objectIndex++) { if (componentRender.Shape.Names[componentRender.Shape.Objects[objectIndex].NameIndex] == bodyparts[bodyPartIndex]) { componentRender.ShapeInstance.MeshObjects[objectIndex].Visibility = 1.0f; } } }It seems to work so far, I will post a far more in-depth analysis of everything with pictures on my blog here once I have it all figured out.