Ejemplo n.º 1
0
    /// <summary>
    /// Creator of Asset models
    /// </summary>
    /// <param name="smdlFilePath">
    /// Path for smdl file
    /// </param>
    /// <param name="name">
    /// Name of model (name set as name of file if null is given)
    /// </param>
    public AssetModelCreator(string smdlFilePath, string name = null)
    {
        //Checking obj file path
        var pathCheckResult = CheckSMDLFilePath(smdlFilePath);

        if (pathCheckResult != null)
        {
            throw new InvalidDataException(pathCheckResult);
        }

        //Assigning obj file path
        this._bundleFilePath = smdlFilePath;

        //Assigning model name

        if (name != null)
        {
            //Setting name based on given argument - if exisists
            this._modelName = name;
        }
        else
        {
            //If argument does not exist - set name according to file name
            this._modelName = AssetModelCreator.GetModelName(smdlFilePath);
        }
    }
Ejemplo n.º 2
0
    public void Init(AssetModelCreator creator, AssetBundle bundle, float scale)
    {
        this._creator = creator;
        this._bundle  = bundle;

        if (scale != 1.0f)
        {
            this._setScale(scale);
        }

        //Get and assign model size and position
        var sizeAndPosition = GetSizeAndPositionOfCombinedMesh(gameObject);

        _size            = sizeAndPosition[0];
        _initialPosition = sizeAndPosition[1];

        //Center the model according to container
        gameObject.transform.Translate(-InitialPosition);
        gameObject.transform.Translate(new Vector3(-0.5f * Size.x, 0, -0.5f * Size.z));

        //Initializing door components
        InitDoorComponents();

        //Initializing cover components
        InitCoverComponents();
    }
Ejemplo n.º 3
0
    private void InitModel()
    {
        var creator = new AssetModelCreator(Common.ModelPath);

        _model = creator.CreateModel(Container, Common.Scale);

        Model.Hide();
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Method for creating OBJModelCreators for all files in directory
    /// </summary>
    /// <param name="dirPath">
    /// Directory to check
    /// </param>
    /// <returns>
    /// All possible creators
    /// </returns>
    public static List <AssetModelCreator> GetCreatorsFromDirectory(string dirPath)
    {
        List <AssetModelCreator> listToReturn = new List <AssetModelCreator>();

        var allFilePaths = Directory.GetFiles(dirPath);

        foreach (var filePath in allFilePaths)
        {
            //Creating and adding new obj model creator if path is ok
            if (AssetModelCreator.CheckSMDLFilePath(filePath) == null)
            {
                listToReturn.Add(new AssetModelCreator(filePath));
            }
        }

        return(listToReturn);
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Method for creating and assigning model creator to loader object
 /// </summary>
 private void CreateAssetModelCreator()
 {
     //Constructor throws in case there is no such file!!
     this._modelCreator = new AssetModelCreator(this.BundleFilePath, this.ModelName);
 }