Beispiel #1
0
    public TxLinkHandle CreateLink(int _node0, int _node1)
    {
        TxLinkHandle handle = TxLinkHandle.CreateInstance();

        handle.index = links.Length;
        handle.node0 = _node0;
        handle.node1 = _node1;
        handle.name  = string.Format("L({0},{1})", _node0, _node1);
        System.Array.Resize(ref links, links.Length + 1);
        links[handle.index] = handle;
        return(handle);
    }
Beispiel #2
0
    void CreateHandles()
    {
        TxTruss data = trussData;

        if (data == null)
        {
            return;
        }

        nodes = new TxNodeHandle[data.nodeCount];
        for (int i = 0; i < data.nodeCount; ++i)
        {
            TxNodeHandle node = TxNodeHandle.CreateInstance();
            node.index    = i;
            node.name     = string.Format("N({0})", i);
            node.position = data.nodePosition[i];
            node.mass     = data.nodeMass[i];
            nodes[i]      = node;
        }

        links = new TxLinkHandle[data.linkCount];
        for (int i = 0; i < data.linkCount; ++i)
        {
            TxLinkHandle link = TxLinkHandle.CreateInstance();
            link.index      = i;
            link.node0      = data.linkNodes[i * 2 + 0];
            link.node1      = data.linkNodes[i * 2 + 1];
            link.name       = string.Format("L({0},{1})", link.node0, link.node1);
            link.stiffness  = data.linkStiffness[i];
            link.damping    = data.linkDamping[i];
            link.elastic    = data.linkElastic[i];
            link.breaking   = data.linkBreaking[i];
            link.stretching = data.linkStretching.Length > 0 ? data.linkStretching[i] : 1.0f;
            link.resist     = (TxLinkHandle.Resist)(data.linkFlags[i] & 0x3);
            links[i]        = link;
        }

        faces = new TxFaceHandle[data.faceCount];
        for (int i = 0; i < data.faceCount; ++i)
        {
            TxFaceHandle face = TxFaceHandle.CreateInstance();
            face.index     = i;
            face.node0     = data.faceNodes[i * 3 + 0];
            face.node1     = data.faceNodes[i * 3 + 1];
            face.node2     = data.faceNodes[i * 3 + 2];
            face.name      = string.Format("F({0},{1},{2})", face.node0, face.node1, face.node2);
            face.collision = (data.faceFlags[i] & (1 << 0)) != 0;
            face.skinning  = (data.faceFlags[i] & (1 << 1)) != 0;
            face.matter    = data.faceMatter.Length > 0 ? data.faceMatter[i] : 0;
            face.envelope  = data.faceEnvelope[i];
            faces[i]       = face;
        }
    }