Example #1
0
    /// <summary>
    /// Calculate the transform for this scene nodes and inform any child scene nodes and primitives to do the same
    /// </summary>
    /// <param name="parentTransform"></param>
    public void CompileTransform(ref Matrix4x4 parentTransform)
    {
        Matrix4x4 originatingPostion = Matrix4x4.Translate(nodeOrigin);
        Matrix4x4 trs = Matrix4x4.TRS(transform.localPosition, transform.localRotation, transform.localScale);

        combinedParentTransform = parentTransform * originatingPostion * trs;

        //For any child nodes, we need to tell them to compile their new position as well
        foreach (Transform child in transform)
        {
            SceneNode childNode = child.GetComponent <SceneNode>();
            if (childNode != null)
            {
                childNode.CompileTransform(ref combinedParentTransform);
            }
        }

        //For any items in our primitive list, compile their new position
        if (PrimitiveList.Count > 0)
        {
            foreach (NodePrimitive primitive in PrimitiveList)
            {
                primitive.LoadShaderMatrix(ref combinedParentTransform);
            }
        }

        if (smallCam != null)
        {
            smallCam.localPosition = combinedParentTransform.MultiplyPoint(new Vector3(0f, 0, -4f));
            smallCam.up            = transform.up;
            smallCam.forward       = -transform.forward;
        }
        UpdateAxisFramePosition();
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        Matrix4x4 startPos = Matrix4x4.identity;

        BaseNode.CompileTransform(ref startPos);

        if (!objectHeld && !skipLookatBehavior)
        {
            lookedAtPrimitives = BaseNode.ObjectLookedAt(mainCam.transform);
        }
    }