Exemplo n.º 1
0
    // Create Vortex Studio mechanism
    void OnEnable()
    {
        Mechanism = VxDLL.VortexLoadMechanism(VxDLL.VortexContent + "/" + "Demo Scenes/Equipment/Forklift/Dynamic/Design/Forklift.vxmechanism", new double[3] {
            0.0, 0.0, 0.0
        }, new double[4] {
            0.0, 0.0, 0.0, 1.0
        });

        // Vortex node discovery
        if (Mechanism != 0)
        {
            uint    nodeHandlesCount = 128;
            ulong[] nodeHandles      = new ulong[nodeHandlesCount];
            if (VxDLL.VortexGetGraphicsNodeHandles(Mechanism, nodeHandles, ref nodeHandlesCount))
            {
                string discoveredNodes         = "";
                VortexGraphicNodeData nodeData = new VortexGraphicNodeData();
                for (uint i = 0; i < nodeHandlesCount && i < nodeHandles.Length; ++i)
                {
                    if (VxDLL.VortexGetGraphicNodeData(nodeHandles[i], ref nodeData))
                    {
                        // console output
                        if (discoveredNodes != "")
                        {
                            discoveredNodes += "\n";
                        }
                        string nodeName;
                        unsafe { nodeName = new string(nodeData.name); }
                        discoveredNodes += nodeName;

                        // mapping
                        Transform child = TransformExtension.FindRecursively(transform, nodeName);
                        if (child)
                        {
                            PartMapping[child] = nodeHandles[i];

                            // relative position
                            Vector3 newPosition = new Vector3();
                            unsafe
                            {
                                newPosition.x = (float)nodeData.position[0];
                                // swizzle Z and Y
                                newPosition.z = (float)nodeData.position[1];
                                newPosition.y = (float)nodeData.position[2];
                            }
                            transform.localPosition = newPosition;
                        }
                    }
                }

                if (nodeHandlesCount > 0)
                {
                    Debug.Log("Discovered Vortex Nodes:\n" + discoveredNodes);
                }
            }
        }
    }
Exemplo n.º 2
0
 public static extern bool VortexGetGraphicNodeData(ulong nodeHandle, ref VortexGraphicNodeData graphicNodeData);