Beispiel #1
0
            // If geometry does not contain normals, colors, and/or uvs, dummy values
            // will be added.
            public ExportMesh(GeometryPool pool)
            {
                m_pool = pool;
                FbxUtils.ApplyFbxTexcoordHack(m_pool);
                m_linearColor = ExportUtils.ConvertToLinearColorspace(m_pool.m_Colors);

                var layout   = m_pool.Layout;
                var numVerts = m_pool.m_Vertices.Count;

                // TODO: all this padding code seems super bogus; try to remove.
                if (!layout.bUseNormals)
                {
                    var lst = m_pool.m_Normals;
                    lst.SetCount(numVerts);
                    for (int i = 0; i < numVerts; ++i)
                    {
                        lst[i] = Vector3.up;
                    }
                }

                if (!layout.bUseColors)
                {
                    var lst = m_linearColor;
                    lst.SetCount(numVerts);
                    for (int i = 0; i < numVerts; ++i)
                    {
                        lst[i] = Color.white;
                    }
                }
            }
Beispiel #2
0
        // Unused and untested
#if false
        /// Converts the existing payload to the new color space and vector basis.
        /// Note that scale is never converted and only gamma -> linear is currently supported.
        public static void ConvertPayload(ColorSpace newColorSpace,
                                          Vector3[] newVectorBasis,
                                          SceneStatePayload payload)
        {
            // We don't handle uninitialized color spaces or linear -> srgb conversions.
            // This is just not currently part of the export logic, so it's not implemented here.
            if (newColorSpace == ColorSpace.Uninitialized ||
                payload.colorSpace == ColorSpace.Uninitialized ||
                (payload.colorSpace == ColorSpace.Linear && newColorSpace == ColorSpace.Gamma))
            {
                throw new NotImplementedException();
            }

            if (newColorSpace != payload.colorSpace)
            {
                ExportUtils.ConvertToLinearColorspace(payload.env);
                ExportUtils.ConvertToLinearColorspace(payload.lights);
                foreach (var group in payload.groups)
                {
                    ExportUtils.ConvertToLinearColorspace(group.brushMeshes);
                }
                ExportUtils.ConvertToLinearColorspace(payload.modelMeshes);
            }

            if (newVectorBasis[0] != payload.vectorBasis[0] ||
                newVectorBasis[1] != payload.vectorBasis[1] ||
                newVectorBasis[2] != payload.vectorBasis[2])
            {
                // Never apply a scale change when changing basis.
                Matrix4x4 basis = ExportUtils.GetBasisMatrix(payload);
                foreach (var group in payload.groups)
                {
                    ExportUtils.ChangeBasis(group.brushMeshes, basis);
                }
                ExportUtils.ChangeBasis(payload.modelMeshes, basis);
                ExportUtils.ChangeBasis(payload.referenceImages, basis);
                ExportUtils.ChangeBasis(payload.referenceModels, basis);
            }

            payload.colorSpace  = newColorSpace;
            payload.vectorBasis = newVectorBasis;
        }