Exemplo n.º 1
0
    public OVRGLTFAccessor(JSONNode node, JSONNode root, bool bufferViewOnly = false)
    {
        JSONNode jsonBufferView = node;

        if (!bufferViewOnly)
        {
            additionalOffset = node["byteOffset"].AsInt;
            dataType         = ToOVRType(node["type"].Value);
            componentType    = (OVRGLTFComponentType)node["componentType"].AsInt;
            dataCount        = node["count"].AsInt;

            int bufferViewId = node["bufferView"].AsInt;
            jsonBufferView = root["bufferViews"][bufferViewId];
        }

        int bufferId = jsonBufferView["buffer"].AsInt;

        byteOffset = jsonBufferView["byteOffset"].AsInt;
        byteLength = jsonBufferView["byteLength"].AsInt;
        byteStride = jsonBufferView["byteStride"].AsInt;

        var jsonBuffer = root["buffers"][bufferId];

        bufferLength = jsonBuffer["byteLength"].AsInt;
    }
Exemplo n.º 2
0
    private float GetMaxValueForType(OVRGLTFComponentType type)
    {
        switch (type)
        {
        case OVRGLTFComponentType.BYTE:
            return(sbyte.MaxValue);

        case OVRGLTFComponentType.UNSIGNED_BYTE:
            return(byte.MaxValue);

        case OVRGLTFComponentType.SHORT:
            return(short.MaxValue);

        case OVRGLTFComponentType.UNSIGNED_SHORT:
            return(ushort.MaxValue);

        case OVRGLTFComponentType.UNSIGNED_INT:
            return(uint.MaxValue);

        case OVRGLTFComponentType.FLOAT:
            return(float.MaxValue);

        default:
            return(0);
        }
    }
Exemplo n.º 3
0
    private int GetStrideForType(OVRGLTFComponentType type)
    {
        switch (type)
        {
        case OVRGLTFComponentType.BYTE:
            return(sizeof(sbyte));

        case OVRGLTFComponentType.UNSIGNED_BYTE:
            return(sizeof(byte));

        case OVRGLTFComponentType.SHORT:
            return(sizeof(short));

        case OVRGLTFComponentType.UNSIGNED_SHORT:
            return(sizeof(ushort));

        case OVRGLTFComponentType.UNSIGNED_INT:
            return(sizeof(uint));

        case OVRGLTFComponentType.FLOAT:
            return(sizeof(float));

        default:
            return(0);
        }
    }
Exemplo n.º 4
0
    private uint ReadElementAsUint(byte[] data, int index, OVRGLTFComponentType type)
    {
        switch (type)
        {
        case OVRGLTFComponentType.BYTE:
            return((uint)Convert.ToSByte(data[index]));

        case OVRGLTFComponentType.UNSIGNED_BYTE:
            return(data[index]);

        case OVRGLTFComponentType.SHORT:
            return((uint)BitConverter.ToInt16(data, index));

        case OVRGLTFComponentType.UNSIGNED_SHORT:
            return(BitConverter.ToUInt16(data, index));

        case OVRGLTFComponentType.UNSIGNED_INT:
            return(BitConverter.ToUInt32(data, index));

        default:
            Debug.Log(String.Format("Failed to read Component Type {0} as a uint.", type));
            return(0);
        }
    }