internal static void SetSkeleton(EntityId entity, MySkeletonBoneDescription[] hierarchy, int[] skeletonIndices) { Skinnings[entity] = new MySkinning { SkeletonHierarchy = hierarchy, SkeletonIndices = skeletonIndices, SkinTransforms = new Matrix[hierarchy.Length], AbsoluteTransforms = new Matrix[hierarchy.Length] }; EntityDirty.Add(entity); }
internal static void SetAnimation(EntityId entity, Matrix[] simulatedBones) { Debug.Assert(Skinnings.ContainsKey(entity)); var skinning = Skinnings[entity]; var skeletonCount = skinning.SkeletonHierarchy.Length; for (int i = 0; i < skeletonCount; i++) { skinning.AbsoluteTransforms[i] = simulatedBones[i]; } for (int i = 0; i < skeletonCount; i++) { if (skinning.SkeletonHierarchy[i].Parent != -1) { skinning.AbsoluteTransforms[i] = skinning.AbsoluteTransforms[i] * skinning.AbsoluteTransforms[skinning.SkeletonHierarchy[i].Parent]; } } int bonesCount = skinning.SkeletonIndices.Length; for (int i = 0; i < bonesCount; i++) { skinning.SkinTransforms[i] = skinning.SkeletonHierarchy[skinning.SkeletonIndices[i]].SkinTransform * skinning.AbsoluteTransforms[skinning.SkeletonIndices[i]]; } }
internal static RenderableId CreateRenderable(EntityId entity, MeshId model, Vector3 keyColor) { var id = new RenderableId { Index = Renderables.Allocate() }; Renderables.Data[id.Index] = new MyRenderableInfo { KeyColor = keyColor, ObjectDithering = 0, Mesh = model }; EntityDirty.Add(entity); RenderableIndex[entity] = id; return id; }
internal static void SetAabb(EntityId entity, ref BoundingBoxD aabb) { Entities.Data[entity.Index].AabbD = aabb; Entities.Data[entity.Index].Aabb = (BoundingBox)aabb; MeshCullDirty.Add(entity); }
internal static void SetMatrix(EntityId entity, ref MatrixD matrix) { Entities.Data[entity.Index].WorldMatrixD = matrix; }
internal static EntityId CreateEntity(uint GID) { var id = new EntityId { Index = Entities.Allocate() }; EntityIndex[GID] = id; MyArrayHelpers.Reserve(ref EntityCullProxyId, id.Index + 1); Entities.Data[id.Index] = new MyEntityInfo { Visible = true }; EntityCullProxyId[id.Index] = -1; return id; }
internal static EntityId CreateEntity(uint GID) { var id = new EntityId { Index = Entities.Allocate() }; EntityIndex[GID] = id; Entities.Data[id.Index] = new MyEntityInfo { Visible = true }; return id; }