Exemplo n.º 1
0
    private void Start()
    {
        string fileName = Path.Combine(Application.streamingAssetsPath, objFile);

        if (!File.Exists(fileName))
        {
            Debug.LogError("FILE COULD NOT BE FOUND!");
            return;
        }

        string objData = File.ReadAllText(fileName);
        int    objLen  = (int)(objData.Split('o').Length * 1.2f);

        debugMeshes = new List <Mesh>(objLen);
        gameWorld   = new world(objLen);
        MeshHelpers.CreateMeshesFromEpa(objData);
        Raycast.InitRaycastData(ref gameWorld);

        //Generate Ground plane.
        bounds ground = new bounds();

        ground.minPoints = new float3(-1000, -.1f, -1000);
        ground.maxPoints = new float3(1000, .1f, 1000);

        groundMesh = MeshHelpers.MakeCubeFromBounds(ground);
        groundMesh.RecalculateBounds();
        entity groundEntity = new entity();

        groundEntity.bounds.minPoints = groundMesh.bounds.min;
        groundEntity.bounds.maxPoints = groundMesh.bounds.max;
        groundEntity.name             = "Ground";
        GameWorld.AddEntity(ref gameWorld, ref groundEntity);
    }