public CubismDrawableManager(IntPtr model) : base(model) { int count = CubismCore.csmGetDrawableCount(model); vertexCounts = CubismUtils.PointerToIntArray(CubismCore.csmGetDrawableVertexCounts(model), count); texCoordPointers = CubismUtils.PointerToPointerArray(CubismCore.csmGetDrawableVertexUvs(model), count); indexCounts = CubismUtils.PointerToIntArray(CubismCore.csmGetDrawableIndexCounts(model), count); indexPointers = CubismUtils.PointerToPointerArray(CubismCore.csmGetDrawableIndices(model), count); int[] textureIds = CubismUtils.PointerToIntArray(CubismCore.csmGetDrawableTextureIndices(model), count); byte[] constFlags = CubismUtils.PointerToByteArray(CubismCore.csmGetDrawableConstantFlags(model), count); string[] names = CubismUtils.PointerToStringArray(CubismCore.csmGetDrawableIds(model), count); int[] maskCounts = CubismUtils.PointerToIntArray(CubismCore.csmGetDrawableMaskCounts(model), count); IntPtr[] maskPointers = CubismUtils.PointerToPointerArray(CubismCore.csmGetDrawableMasks(model), count); for (int i = 0; i < count; i++) { float[] texCoords = CubismUtils.PointerToFloatArray(texCoordPointers[i], vertexCounts[i] * 2); short[] indices = CubismUtils.PointerToShortArray(indexPointers[i], indexCounts[i]); int[] masks = CubismUtils.PointerToIntArray(maskPointers[i], maskCounts[i]); Add(new CubismDrawable(i, names[i], textureIds[i], masks, texCoords, indices, (ConstantDrawableFlags)constFlags[i])); } }
public override void PostModelUpdate() { int[] renderOrder = CubismUtils.PointerToIntArray(CubismCore.csmGetDrawableRenderOrders(Model), Count); byte[] dynamicFlags = CubismUtils.PointerToByteArray(CubismCore.csmGetDrawableDynamicFlags(Model), Count); float[] opacities = CubismUtils.PointerToFloatArray(CubismCore.csmGetDrawableOpacities(Model), Count); IntPtr[] vertexPointers = CubismUtils.PointerToPointerArray(CubismCore.csmGetDrawableVertexPositions(Model), Count); foreach (var drawable in this) { int id = drawable.Id; float[] vertices = CubismUtils.PointerToFloatArray(vertexPointers[id], vertexCounts[id] * 2); drawable.Update(opacities[id], renderOrder[id], vertices, (DynamicDrawableFlags)dynamicFlags[id]); } }
public void TestParameterUpdate() { var paramHandle = CubismCore.csmGetParameterValues(model.Handle); float[] prev = CubismUtils.PointerToFloatArray(paramHandle, model.Parameters.Count); var param = model.Parameters.Get("ParamEyeLOpen"); param.Value = param.Minimum; Assert.IsTrue(!prev.SequenceEqual(model.Parameters.Select(p => p.Value))); model.Update(); float[] now = CubismUtils.PointerToFloatArray(paramHandle, model.Parameters.Count); Assert.IsTrue(!prev.SequenceEqual(now)); }
public CubismParameterManager(IntPtr model) : base(model) { handle = CubismCore.csmGetParameterValues(model); int count = CubismCore.csmGetParameterCount(model); float[] def = CubismUtils.PointerToFloatArray(CubismCore.csmGetParameterDefaultValues(model), count); float[] min = CubismUtils.PointerToFloatArray(CubismCore.csmGetParameterMinimumValues(model), count); float[] max = CubismUtils.PointerToFloatArray(CubismCore.csmGetParameterMaximumValues(model), count); string[] names = CubismUtils.PointerToStringArray(CubismCore.csmGetParameterIds(model), count); for (int i = 0; i < count; i++) { Add(new CubismParameter(i, names[i], min[i], max[i], def[i])); } }