Exemplo n.º 1
0
        private static LandModelSA2 ConvertDisplayModel(Assimp.Scene aiScene, List <MaterialBuildInfo> materialBuildInfos, Assimp.Node aiMeshNode)
        {
            var displayModel = new LandModelSA2();

            displayModel.Flags   |= SurfaceFlags.Visible;
            displayModel.RootNode = ConvertNode(aiMeshNode, aiScene.Meshes, materialBuildInfos, ConvertDisplayGeometry);
            var displayGeometry = ( Geometry )displayModel.RootNode.Geometry;

            displayModel.Bounds = displayGeometry.Bounds;

            //var min = new Vector3( float.MaxValue, float.MaxValue, float.MaxValue );
            //var max = new Vector3( float.MinValue, float.MinValue, float.MinValue );
            //var modelWorldTransform = displayModel.RootNode.WorldTransform;
            //foreach ( var node in displayModel.RootNode.EnumerateAllNodes() )
            //{
            //    if ( node.Geometry == null )
            //        continue;

            //    var geometry = ( ( Geometry ) node.Geometry );
            //    var positionBuffer = ( VertexPositionBuffer )geometry.VertexBuffers.Single( x => x.Type == VertexAttributeType.Position );
            //    foreach ( var vertexPosition in positionBuffer.Elements )
            //    {
            //        var position = vertexPosition;
            //        min.X = Math.Min( min.X, position.X );
            //        min.Y = Math.Min( min.Y, position.Y );
            //        min.Z = Math.Min( min.Z, position.Z );
            //        max.X = Math.Max( max.X, position.X );
            //        max.Y = Math.Max( max.Y, position.Y );
            //        max.Z = Math.Max( max.Z, position.Z );
            //    }
            //}

            //displayModel.Bounds = Bounds.Calculate( min, max );
            return(displayModel);
        }
        public void Export(LandTableSA2 landTable, string filePath)
        {
            TextureNames = landTable.Textures.Select(x => x.Name).ToList();
            Scene        = CreateDefaultScene();
            Initialize(null);

            foreach (var model in landTable.Models)
            {
                mCurrentModel = model;
                ConvertRootNode(model.RootNode);
            }

            ExportCollada(Scene, filePath);
        }
Exemplo n.º 3
0
        private static LandModelSA2 ConvertCollisionModel(Assimp.Scene aiScene, List <MaterialBuildInfo> materialBuildInfos, Assimp.Node aiMeshNode)
        {
            var collisionModel = new LandModelSA2();

            collisionModel.Flags   |= SurfaceFlags.Collidable;
            collisionModel.RootNode = ConvertNode(aiMeshNode, aiScene.Meshes, materialBuildInfos,
                                                  ConvertCollisionGeometry);

            var collisionGeometry = (Basic.Geometry)collisionModel.RootNode.Geometry;

            collisionModel.Bounds = collisionGeometry.Bounds;

            return(collisionModel);
        }