コード例 #1
0
        public Vector3 Calculate_Center_Point(ObjLoader.Loader.Data.Elements.Group grp)
        {
            V3 min = null;
            V3 max = null;

            // Find the bounds
            foreach (var vec in grp.Verticies)
            {
                var v = new V3(vec);

                if (min == null)
                {
                    min = v;
                }
                if (max == null)
                {
                    max = v;
                }

                if (v.x < min.x)
                {
                    min.x = v.x;
                }
                if (v.y < min.y)
                {
                    min.y = v.y;
                }
                if (v.z < min.z)
                {
                    min.z = v.z;
                }

                if (v.x > max.x)
                {
                    max.x = v.x;
                }
                if (v.y > max.y)
                {
                    max.y = v.y;
                }
                if (v.z > max.z)
                {
                    max.z = v.z;
                }
            }

            if (min == null)
            {
                return(Vector3.zero);
            }

            // Find the center
            var delta = new V3((max.x - min.x), (max.y - min.y), (max.z - min.z));
            var X     = min.x + (delta.x * 0.5f);
            var Y     = min.y + (delta.y * 0.5f);
            var Z     = min.z + (delta.z * 0.5f);

            return(new Vector3(X, Y, Z));
        }
コード例 #2
0
        private void ConvertGroups()
        {
            var groups = _loadResult.Groups;

            foreach (var modelGroup in groups)
            {
                _modelGroup = modelGroup;
                ConvertGroup();
            }
        }
コード例 #3
0
ファイル: DataStore.cs プロジェクト: sudocoders/ObjLoader
 public void PushGroup(string groupName)
 {
     _currentGroup = new Group(groupName);
     _groups.Add(_currentGroup);
 }