public BlendShapeManager(List<BlendShapeContent> shapes, ANSKModel model, Game game) { /* _bShapes = new List<BlendShapeComplex>(); for (int i = 0; i < shapes.Count; i++) _bShapes.Add(new BlendShapeComplex(new BlendShape(shapes[i]), model, game)); _model = model;*/ }
private void ExtractBlendShapeVerts(ANSKModel model) { List<short> check = new List<short>(); Vector3[] verts; short[] inds; /*for (int i = 0; i < model.Meshes.Count; i++) { for (int q = 0; q < model.Meshes[i].MeshParts.Count; q++) { //verts = new Vector3[model.Meshes[i].MeshParts[q].VertexBuffer.VertexCount]; //inds = new short[model.Meshes[i].MeshParts[q].IndexBuffer.IndexCount]; VertexDeclaration vertexDec = model.Meshes[i].MeshParts[q].VertexBuffer.VertexDeclaration; var vertEle = vertexDec.GetVertexElements(); var posEle = vertEle.First(e => e.VertexElementUsage == VertexElementUsage.Position); if (posEle.VertexElementFormat != VertexElementFormat.Vector3) throw new NotSupportedException(); var positions = new Vector3[model.Meshes[i].MeshParts[q].NumVertices]; model.Meshes[i].MeshParts[q].VertexBuffer.GetData(model.Meshes[i].MeshParts[q].VertexOffset * vertexDec.VertexStride + posEle.Offset, positions, 0, model.Meshes[i].MeshParts[q].NumVertices, vertexDec.VertexStride); var indexElementSize = (model.Meshes[i].MeshParts[q].IndexBuffer.IndexElementSize == IndexElementSize.SixteenBits) ? 2 : 4; if (indexElementSize != 2) throw new NotSupportedException(); var indices = new short[model.Meshes[i].MeshParts[q].PrimitiveCount * 3]; model.Meshes[i].MeshParts[q].IndexBuffer.GetData(model.Meshes[i].MeshParts[q].StartIndex * 2, indices, 0, model.Meshes[i].MeshParts[q].PrimitiveCount * 3); //model.Meshes[i].MeshParts[q].VertexBuffer.GetData<Vector3>(verts); //model.Meshes[i].MeshParts[q].IndexBuffer.GetData<short>(inds); for (int p = 0; p < _shape.Indices.Count; p++) { for (int w = 0; w < indices.Length; w++) { if (_shape.Indices[p] == indices[w] && !check.Exists(temp => temp == _shape.Indices[p])) { _verts.Add(new BlendShapeVert(i, q, indices[w], p, _shape.Vertices[p])); check.Add(indices[w]); } } } } }*/ }
public void LoadModel(ANSKModel model) { _model = model; }
public BlendShapeComplex(BlendShape shape, ANSKModel model, Game game) { _shape = shape; _min = 0; _max = 1; _toValue = 0; _timePassed = 0.0f; _timeToWait = 0.0f; _blend = false; _verts = new List<BlendShapeVert>(); ExtractBlendShapeVerts(model); _game = game; }