public RenderSubMesh(SSSkeletalMesh skeletalMesh, SSSkeletalHierarchyRuntime hierarchy = null) : base(null, skeletalMesh.triangleIndices) { _runtimeMesh = new SSSkeletalMeshRuntime(skeletalMesh, hierarchy); _vertices = new SSVertex_PosNormTex[_runtimeMesh.numVertices]; for (int v = 0; v < _runtimeMesh.numVertices; ++v) { _vertices [v].TexCoord = _runtimeMesh.textureCoords(v); _vertices [v].Normal = _runtimeMesh.bindPoseNormal(v); } ComputeVertices(); string matString = skeletalMesh.materialShaderString; if (matString != null && matString.Length > 0) { base.textureMaterial = SSTextureMaterial.FromMaterialString(skeletalMesh.assetContext, matString); } // don't use BVH because vertices keep changing on every render frame // TODO can we "update" BVH efficiently, instead? base.useBVHForIntersections = false; }
/// <summary> /// Adds a sumbesh that will share the existing joint hierarchy /// </summary> public void attachMesh(SSSkeletalMesh mesh) { var newRender = new RenderSubMesh(mesh, _hierarchy); newRender.alphaBlendingEnabled = this.alphaBlendingEnabled; _renderSubMeshes.Add(newRender); }
public SSSkeletalMeshRuntime(SSSkeletalMesh mesh, SSSkeletalHierarchyRuntime hierarchy) { _hierarchy = hierarchy; _vertices = new SSSkeletalVertexRuntime[mesh.vertices.Length]; for (int v = 0; v < mesh.vertices.Length; ++v) { _vertices [v] = new SSSkeletalVertexRuntime (mesh.vertices [v]); } _weights = new SSSkeletalWeightRuntime[mesh.weights.Length]; for (int w = 0; w < mesh.weights.Length; ++w) { _weights [w] = new SSSkeletalWeightRuntime (mesh.weights [w]); } _triangleIndices = mesh.triangleIndices; _preComputeNormals (); }
public SSSkeletalMeshRuntime(SSSkeletalMesh mesh, SSSkeletalHierarchyRuntime hierarchy) { _hierarchy = hierarchy; _vertices = new SSSkeletalVertexRuntime[mesh.vertices.Length]; for (int v = 0; v < mesh.vertices.Length; ++v) { _vertices [v] = new SSSkeletalVertexRuntime(mesh.vertices [v]); } _weights = new SSSkeletalWeightRuntime[mesh.weights.Length]; for (int w = 0; w < mesh.weights.Length; ++w) { _weights [w] = new SSSkeletalWeightRuntime(mesh.weights [w]); } _triangleIndices = mesh.triangleIndices; _preComputeNormals(); }
public SSSkeletalRenderMesh(SSSkeletalMesh mesh) { _hierarchy = new SSSkeletalHierarchyRuntime(mesh.joints); attachMesh(mesh); _channelControllers.Add(new SSBindPoseSkeletalController()); }