Ejemplo n.º 1
0
        public void Serialize(List <BoneInfo> result, float boneRange, MyCubeGrid grid)
        {
            var info = new BoneInfo();

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Serialize");

            float boneErrorSquared = GetMaxBoneError(grid.GridSize);

            boneErrorSquared *= boneErrorSquared;

            foreach (var bone in Bones)
            {
                Vector3I?cube = GetCubeFromBone(bone.Key, grid);
                if (cube != null)
                {
                    var   boneOffset = GetDefinitionOffsetWithNeighbours(cube.Value, bone.Key, grid);
                    float distance   = Math.Abs(boneOffset.LengthSquared() - bone.Value.LengthSquared());
                    if (distance > boneErrorSquared)
                    {
                        info.BonePosition = bone.Key;
                        info.BoneOffset   = Vector3UByte.Normalize(bone.Value, boneRange);
                        if (!Vector3UByte.IsMiddle(info.BoneOffset)) // Middle number means zero in floats
                        {
                            result.Add(info);
                        }
                    }
                }
            }
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
Ejemplo n.º 2
0
        public void SerializePart(Vector3I minBone, Vector3I maxBone, float boneRange, List <byte> result)
        {
            Vector3I pos;

            for (pos.X = minBone.X; pos.X <= maxBone.X; pos.X++)
            {
                for (pos.Y = minBone.Y; pos.Y <= maxBone.Y; pos.Y++)
                {
                    for (pos.Z = minBone.Z; pos.Z <= maxBone.Z; pos.Z++)
                    {
                        var boneValue = Vector3UByte.Normalize(this[pos], boneRange);
                        result.Add(boneValue.X);
                        result.Add(boneValue.Y);
                        result.Add(boneValue.Z);
                    }
                }
            }
        }