Esempio n. 1
0
    //------------------------------------------------------------------------------------------------------------
    private void Start()
    {
        //	Load the OBJ in
        var lStream     = new FileStream(INPUT_PATH, FileMode.Open);
        var lOBJData    = OBJLoader.LoadOBJ(lStream);
        var lMeshFilter = GetComponent <MeshFilter>();

        lMeshFilter.mesh.LoadOBJ(lOBJData);
        lStream.Close();

        lStream  = null;
        lOBJData = null;

        //	Wiggle Vertices in Mesh
        var lVertices = lMeshFilter.mesh.vertices;

        for (int lCount = 0; lCount < lVertices.Length; ++lCount)
        {
            lVertices[lCount] = lVertices[lCount] + Vector3.up * Mathf.Sin(lVertices[lCount].x) * 4f;
        }
        lMeshFilter.mesh.vertices = lVertices;

        //	Export the new Wiggled Mesh
        if (File.Exists(OUTPUT_PATH))
        {
            File.Delete(OUTPUT_PATH);
        }
        lStream  = new FileStream(OUTPUT_PATH, FileMode.Create);
        lOBJData = lMeshFilter.mesh.EncodeOBJ();
        OBJLoader.ExportOBJ(lOBJData, lStream);
        lStream.Close();
    }
Esempio n. 2
0
    public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
    {
        XAttribute fileAtt = elemtype.Attribute("file");

        if (fileAtt == null)
        {
            //Add error message here
            return(false);
        }
        string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value);

        filePath = Path.GetFullPath(filePath);

        //	Load the OBJ in
        var lStream  = new FileStream(filePath, FileMode.Open);
        var lOBJData = OBJLoader.LoadOBJ(lStream);

        lStream.Close();
        mesh = new Mesh[(int)MeshLayer.Count];
        for (int i = 0; i < mesh.Length; i++)
        {
            mesh[i] = new Mesh();
            mesh[i].LoadOBJ(lOBJData, ((MeshLayer)i).ToString());
        }
        lStream  = null;
        lOBJData = null;
        return(true);
    }
    public Model(string modelName, string textureName, int instanceId, out TextureData textData)
    {
        World worpldPtr = Camera.main.gameObject.GetComponent <World> ();
        //	Load the OBJ in
        var lStream  = new FileStream(Application.dataPath + "/Resources/" + modelName + ".obj", FileMode.Open);
        var lOBJData = OBJLoader.LoadOBJ(lStream);

        UnityEngine.Object obj     = Resources.Load(modelName);
        GameObject         gameObj = (GameObject)Instantiate(obj);

        Texture2D   mapTexture = Resources.Load <Texture2D> (textureName);
        TextureData data       = new TextureData();

        data.LoadTextureData(mapTexture);

        textData = data;

        var lMeshFilter = gameObj.GetComponentInChildren <MeshFilter>();

        lMeshFilter.gameObject.GetComponent <MeshRenderer> ().enabled = false;
        lMeshFilter.mesh.LoadOBJ(lOBJData);
        lStream.Close();

        lStream  = null;
        lOBJData = null;


        var verts = lMeshFilter.mesh.vertices;
        //	Wiggle Vertices in Mesh
        List <Vector2> uvs = new List <Vector2>();

        lMeshFilter.mesh.GetUVs(0, uvs);

        List <Vector3> normals = new List <Vector3>();

        lMeshFilter.mesh.GetNormals(normals);

        List <MeshDataProp> meshDataList = new List <MeshDataProp>();

        for (int i = 0; i < verts.Length; i++)
        {
            MeshDataProp meshData = new MeshDataProp();
            meshData.vertex = verts [i];
            meshData.uv     = uvs [i];
            meshDataList.Add(meshData);
        }

        var tris = lMeshFilter.mesh.triangles;

        for (int lCount = 0; lCount < tris.Length; lCount += 3)
        {
            Triangle triangle     = new Triangle(meshDataList[tris[lCount]].vertex, meshDataList[tris[lCount + 1]].vertex, meshDataList[tris[lCount + 2]].vertex, meshDataList[tris[lCount]].uv, meshDataList[tris[lCount + 1]].uv, meshDataList[tris[lCount + 2]].uv, true);
            Instance triangleInst = new Instance(triangle);
            triangleInst.instanceId = instanceId;
            instanceList.Add(triangleInst);
            worpldPtr.add_object(triangleInst);
        }
    }
Esempio n. 4
0
        public static Mesh LoadMesh(string fileName)
        {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            var      stream            = executingAssembly.GetManifestResourceStream("HideUnconnectedTracks.Resources." + fileName);
            var      mesh = new Mesh();

            mesh.LoadOBJ(OBJLoader.LoadOBJ(stream));
            return(mesh);
        }
Esempio n. 5
0
    private void CreateGridElement(GameObject elementGrid, string elementName, string path)
    {
        //Create button gameobject
        GameObject go = new GameObject(elementName);

        go.transform.SetParent(elementGrid.transform, false);

        //Add interaction component
        BDDElementHandler bddElementHandler = go.AddComponent <BDDElementHandler>();

        bddElementHandler.SetPath(path);
        bddElementHandler.SetElementPositioningPanel(ElementPositioningPanel);

        //Add image
        Image img = go.AddComponent <Image>() as Image;

        img.type = Image.Type.Sliced;
        //Create temporary instance to get thumb image
        GameObject thumbTransform = new GameObject(elementName);
        //Material
        MeshRenderer mr = thumbTransform.AddComponent <MeshRenderer>();

        mr.material = Resources.Load <Material>("Materials/BenchMat");
        //Mesh
        MeshFilter mf       = thumbTransform.AddComponent <MeshFilter>();
        FileStream lStream  = new FileStream(path, FileMode.Open);
        OBJData    lOBJData = OBJLoader.LoadOBJ(lStream);

        lStream.Close();
        mf.mesh.LoadOBJ(lOBJData);
        mf.mesh.RecalculateNormals();

        //Generate thumb
        Texture2D image = RuntimePreviewGenerator.GenerateModelPreview(thumbTransform.transform, 128, 128, false);

        img.sprite = Sprite.Create(image, new Rect(0, 0, image.width, image.height), new Vector2(0.5f, 0.5f));
        //Destroy temporary instance
        Destroy(thumbTransform);

        //Text under button
        GameObject txGO = new GameObject();
        Text       tx   = txGO.AddComponent <Text>() as Text;

        tx.text      = elementName;
        tx.color     = Color.black;
        tx.alignment = TextAnchor.UpperCenter;
        tx.font      = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
        tx.fontStyle = FontStyle.Bold;
        tx.fontSize  = 14;
        //tx.resizeTextForBestFit = true;
        //tx.resizeTextMaxSize = 25;
        txGO.transform.position = new Vector3(0, -63, 0);
        txGO.transform.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25);
        txGO.transform.SetParent(go.transform, false);
    }
Esempio n. 6
0
        private static Mesh LoadMesh(string fullPath, string meshName)
        {
            var mesh = new Mesh();

            using (var fileStream = File.Open(fullPath, FileMode.Open))
            {
                mesh.LoadOBJ(OBJLoader.LoadOBJ(fileStream));
            }
            mesh.Optimize();
            mesh.name = Path.GetFileNameWithoutExtension(meshName);

            return(mesh);
        }
Esempio n. 7
0
        public static Mesh LoadMesh(string fullPath, string meshName)
        {
            var mesh = new Mesh();

            using (var fileStream = File.Open(fullPath, FileMode.Open))
            {
                mesh.LoadOBJ(OBJLoader.LoadOBJ(fileStream));
            }
            mesh.name = meshName;
            if (!mesh.name.Contains("LOD"))
            {
                mesh.UploadMeshData(true);
            }
            return(mesh);
        }
Esempio n. 8
0
        private static Mesh LoadMesh(string fullPath, string meshName)
        {
            var mesh = new Mesh();

            using (var fileStream = File.Open(fullPath, FileMode.Open))
            {
                mesh.LoadOBJ(OBJLoader.LoadOBJ(fileStream));
            }
            var name = Path.GetFileNameWithoutExtension(meshName);

            mesh.name = name;
//            if (!name.Contains("LOD")) {
//                mesh.UploadMeshData(true);
//            }
            return(mesh);
        }
Esempio n. 9
0
    private GameObject ObjIOLoad(byte[] fileData)
    {
        /////////// Load the .obj using OBJIO
        GameObject targetObject = new GameObject();

        System.IO.Stream lStream  = new System.IO.MemoryStream(fileData);
        OBJData          lOBJData = OBJLoader.LoadOBJ(lStream);
        MeshFilter       filter   = targetObject.AddComponent <MeshFilter>();

        filter.mesh.LoadOBJ(lOBJData);
        lStream.Close();
        lStream  = null;
        lOBJData = null;
        targetObject.AddComponent <MeshRenderer> ().material = brainMaterial;
        filter.mesh.RecalculateNormals();
        return(targetObject);
        ///////////
    }
Esempio n. 10
0
    IEnumerator loadObj()
    {
        using (WWW www = new WWW(TestQR.loadedQRs[int.Parse(itb.TrackableName)])) {
            text.text = "Descargando modelo obj...";
            yield return(www);

            text.text = "Extrayendo modelo obj...";
            List <string> lines = new List <string>(www.text.Split('\n'));
            GameObject    obj;
            try {
                obj       = OBJLoader.LoadOBJ("QR object downloaded", lines, baseMaterial);
                text.text = "";
            } catch (Exception e) {
                text.text = e.ToString();
                yield break;
            }
            objRenderers = obj.GetComponentsInChildren <Renderer>();
            Bounds b         = new Bounds();
            bool   initiated = false;
            foreach (var r in objRenderers)
            {
                if (!initiated)
                {
                    b         = r.bounds;
                    initiated = true;
                }
                else
                {
                    b.Encapsulate(r.bounds);
                }
            }
            float highestSide = Mathf.Max(b.extents.x, b.extents.y, b.extents.z);
            if (highestSide > 0)
            {
                Vector3 scale = obj.transform.localScale;
                scale /= highestSide;
                scale *= wantedScale;
                obj.transform.localScale = scale;
            }
            transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
            obj.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
            obj.transform.parent = transform;
        }
    }
Esempio n. 11
0
        private static Mesh LoadMesh(string fullPath, string meshName)
        {
            var mesh = new Mesh();

            using (var fileStream = File.Open(fullPath, FileMode.Open))
            {
                mesh.LoadOBJ(OBJLoader.LoadOBJ(fileStream));
            }

            mesh.Optimize();
            mesh.name = Path.GetFileNameWithoutExtension(meshName);

            if (mesh.name != null && !mesh.name.Contains("LOD") && !mesh.name.Contains("NoCom"))
            {
                mesh.UploadMeshData(true);
            }

            return(mesh);
        }
    /// <summary>
    /// 初始化
    /// </summary>
    public SoftRenderForm()
    {
        Height = screenHeight;
        Width  = screenWidth;

        // 初始化前置缓冲区
        g = this.CreateGraphics();

        // 初始化屏幕缓冲区
        screenBuffer         = new Bitmap(screenWidth, screenHeight);
        screenBufferGraphics = Graphics.FromImage(screenBuffer);

        // 初始化深度缓冲区
        ZBuffer = new float[screenWidth + 1, screenHeight + 1];


        // 开启深度测试
        IsZTest = true;
        // 开启深度写入
        IsZWritting = true;

        // 开启光照渲染
        LightingOn = true;

        // 开启逐像素计算
        fragmentShaderOn = true;

        // 读取贴图
        //texture2D = new Bitmap("D:\\C#Instance\\LerningRenderPiplineWithSoftRender\\SortRenderWithCSharp\\SortRenderWithCSharp\readmeImage\\29126173.bmp");
        //texture2D = new Bitmap("C:\\Users\\Administrator\\Desktop\\29126173.bmp");
        texture2D = new Bitmap("D:\\UnityInstance\\资源\\Unity Shadeers Book Assert\\Unity_Shaders_Book-master\\Assets\\Textures\\Chapter7\\Grid.png");

        // 读取法线贴图
        normalTexture = new Bitmap(256, 256);
        //normalTexture = new Bitmap("D:\\UnityInstance\\Shader Collection\\Assets\\Textures\\Chapter7\\Brick_Normal.bmp");
        //normalTexture = new Bitmap("D:\\C#Instance\\LerningRenderPiplineWithSoftRender\\SortRenderWithCSharp\\SortRenderWithCSharp\readmeImage\\distorition1.bmp");

        // 读取OBJ文件
        OBJLoader.LoadOBJ("D:\\C#Instance\\LerningRenderPiplineWithSoftRender\\SortRenderWithCSharp\\SortRenderWithCSharp\\cubea.obj");

        StartRender();
    }
Esempio n. 13
0
    /**<summary> Initialise world, get obstacles and build navmesh </summary>*/
    public async void InitArea(Parser.Area area)
    {
        finished    = false;
        currentArea = area;
        collected   = 0;
        ClearWorld();

        Tuple <bool, byte[]> result = await ServerAPI.Obstacles(area.areaID);

        if (result.Item1)
        {
            Stream  s       = new MemoryStream(result.Item2);
            OBJData objData = OBJLoader.LoadOBJ(s);
            s.Dispose();
            if (objData == null || objData.m_Vertices.Count <= 0)
            {
                if (App.config.debug)
                {
                    Debug.Log("Couldn't load obstacle obj");
                }
                return;
            }
            Mesh mesh = new Mesh();
            mesh.LoadOBJ(objData);

            worldObject.GetComponent <MeshFilter>().mesh         = mesh;
            worldObject.GetComponent <MeshCollider>().sharedMesh = mesh;

            worldObject.GetComponent <NavMeshSurface>().BuildNavMesh();
        }
        else
        {
            if (App.config.debug)
            {
                Debug.Log("No obstacle obj");
            }
        }

        SelectGame();
    }
Esempio n. 14
0
        internal static Mesh LoadMesh(string fullPath)
        {
            if (!File.Exists(fullPath))
            {
                return(null);
            }
            var mesh = new Mesh();

            using (var fileStream = File.Open(fullPath, FileMode.Open))
            {
                try
                {
                    mesh.LoadOBJ(OBJLoader.LoadOBJ(fileStream));
                }
                catch (Exception x)
                {
                    Debug.Log($"Failed to load mesh. {x.Message} {x.StackTrace}");
                }
            }
            mesh.name = Path.GetFileNameWithoutExtension(fullPath);
            return(mesh);
        }
Esempio n. 15
0
    public void LoadObject()
    {
        //	Load the OBJ in
        var lStream     = new FileStream(INPUT_PATH, FileMode.Open);
        var lOBJData    = OBJLoader.LoadOBJ(lStream);
        var lMeshFilter = GetComponent <MeshFilter>();

        lMeshFilter.mesh.LoadOBJ(lOBJData);
        lStream.Close();

        lStream  = null;
        lOBJData = null;

        if (File.Exists(OUTPUT_PATH))
        {
            File.Delete(OUTPUT_PATH);
        }
        lStream  = new FileStream(OUTPUT_PATH, FileMode.Create);
        lOBJData = lMeshFilter.mesh.EncodeOBJ();
        OBJLoader.ExportOBJ(lOBJData, lStream);
        lStream.Close();
    }
Esempio n. 16
0
        private static Mesh LoadMesh(string fullPath, string meshName)
        {
            var mesh = new Mesh();

            using (var fileStream = File.Open(fullPath, FileMode.Open))
            {
                mesh.LoadOBJ(OBJLoader.LoadOBJ(fileStream));
            }

            mesh.name = Path.GetFileNameWithoutExtension(meshName);

            if (mesh.name != null && !mesh.name.Contains("LOD") && !mesh.name.Contains("NoCom"))
            {
                //var isReadable = false;
#if DEBUG
                //isReadable = true;
#endif
                //mesh.UploadMeshData(isReadable);
            }

            return(mesh);
        }
Esempio n. 17
0
    //------------------------------------------------------------------------------------------------------------
    private void Start()
    {
        //	Load the OBJ in
        var lStream     = new FileStream(INPUT_PATH, FileMode.Open);
        var lOBJData    = OBJLoader.LoadOBJ(lStream);
        var lMeshFilter = GetComponent <MeshFilter>();

        lMeshFilter.mesh.LoadOBJ(lOBJData);
        lStream.Close();

        lStream  = null;
        lOBJData = null;

        //	Wiggle Vertices in Mesh
        List <Vector2> uvs = new List <Vector2>();

        lMeshFilter.mesh.GetUVs(0, uvs);
        var tris = lMeshFilter.mesh.vertices;

        for (int lCount = 0; lCount < tris.Length; lCount++)
        {
            Debug.Log("Vert" + tris[lCount]);
            Debug.Log("Uv" + lMeshFilter.mesh.uv [lCount]);
        }
//		for (int lCount = 0; lCount < tris.Length; lCount += 3)
//		{
//			Debug.Log (tris [lMeshFilter.mesh.vertices[lCount]]);
//			Debug.Log (tris [lMeshFilter.mesh.vertices[lCount + 2]]);
//			Debug.Log (tris [lMeshFilter.mesh.vertices[lCount +  1]]);
//
//			Debug.Log (tris [lMeshFilter.mesh.uv[lCount]]);
//			Debug.Log (tris [lMeshFilter.mesh.uv[lCount + 2]]);
//			Debug.Log (tris [lMeshFilter.mesh.uv[lCount +  1]]);
//
//		}
        //lMeshFilter.mesh.vertices = lVertices;
    }
    /// <summary>
    /// 初始化
    /// </summary>
    public SoftRenderForm()
    {
        Height = screenHeight;
        Width  = screenWidth;

        // 初始化前置缓冲区
        g = this.CreateGraphics();

        // 初始化屏幕缓冲区
        screenBuffer         = new Bitmap(screenWidth + 1, screenHeight + 1);
        screenBufferGraphics = Graphics.FromImage(screenBuffer);

        // 初始化深度缓冲区
        ZBuffer = new float[screenWidth + 1, screenHeight + 1];

        // 初始化所有光源
        directionalLight = new DirectionalLight(MainLightDirection, Color01.White);
        lights.Add(directionalLight);
        //pointLight = new PointLight(Vector3.Zero, 7, new Color01(0, 0, 1f, 1f));
        //lights.Add(pointLight);
        //spotLight = new SpotLight(15f, 7f, new Vector3(0, 0, 1), new Color01(1, 0, 0, 1), new Vector3(0, 0, -3));
        //lights.Add(spotLight);

        // 开启深度测试
        IsZTest = true;
        // 开启深度写入
        IsZWritting = true;

        // 开启光照渲染
        LightingOn = true;

        // 开启逐像素计算
        fragmentShaderOn = true;

        // 初始化摄像机
        camera = new Camera();

        // 读取贴图
        texture2D = new Bitmap("C:\\Users\\Administrator\\Desktop\\29126173.bmp");

        // 读取法线贴图
        normalTexture = new Bitmap(256, 256);
        //normalTexture = new Bitmap("D:\\UnityInstance\\Shader Collection\\Assets\\Textures\\Chapter7\\Brick_Normal.bmp");

        // 读取OBJ文件
        SpaceShip = OBJLoader.LoadOBJ("../../enemry_spaceship.obj");
        cube      = OBJLoader.LoadOBJ("../../cube.obj");
        //cube = new Cube();
        sphere     = OBJLoader.LoadOBJ("../../sphere.obj");
        skyBoxMesh = cube;

        // 初始化天空盒
        skyBox = new CubeMap(
            // front
            new Bitmap("../../frontImage.png"),
            // back
            new Bitmap("../../backImage.png"),
            // left
            new Bitmap("../../leftImage.png"),
            // right
            new Bitmap("../../rightImage.png"),
            // top
            new Bitmap("../../upImage.png"),
            // bottom
            new Bitmap("../../downImage.png")
            );

        StartRender();
    }
Esempio n. 19
0
    public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
    {
        XAttribute fileAtt = elemtype.Attribute("file");

        if (fileAtt == null)
        {
            //Add error message here
            return(false);
        }


        if (storeContainer.shapeStore != null &&
            (elemtype.Attribute("normal") != null ||
             elemtype.Attribute("occlusion") != null ||
             elemtype.Attribute("alpha") != null
            ))
        {
            _normalTexture = new NormalContent();
            _normalTexture.ExternalStorage = storeContainer.shapeStore;
            if (!_normalTexture.AddTypeElement(elemtype))
            {
                _normalTexture = null;
            }
        }

        if (storeContainer.specialStore != null &&
            (elemtype.Attribute("metallic") != null ||
             elemtype.Attribute("illumination") != null
            ))
        {
            _specialTexture = new SpecialMapContent();
            _specialTexture.ExternalStorage = storeContainer.specialStore;
            if (!_specialTexture.AddTypeElement(elemtype))
            {
                _specialTexture = null;
            }
        }

        if (storeContainer.materialStore != null &&
            (elemtype.Attribute("pattern") != null ||
             elemtype.Attribute("specular") != null
            ))
        {
            _matTexture = new TextureContent();
            _matTexture.ExternalStorage = storeContainer.materialStore;
            if (!_matTexture.AddTypeElement(elemtype))
            {
                _matTexture = null;
            }
        }


        if (fileAtt.Value == "NONE")
        {
            //This means we don't want to actually store a mesh,
            //but still want to use the category.
            MeshData = new Dictionary <MeshLayer, CPUMesh>();
        }
        else
        {
            string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value);
            filePath = Path.GetFullPath(filePath);

            //	Load the OBJ in
            var lStream  = new FileStream(filePath, FileMode.Open);
            var lOBJData = OBJLoader.LoadOBJ(lStream);
            lStream.Close();
            MeshData = new Dictionary <MeshLayer, CPUMesh>();
            Mesh tempMesh = new Mesh();
            foreach (MeshLayer layer in Enum.GetValues(typeof(MeshLayer)))
            {
                MeshLayer translatedLayer;
                if (layer == MeshLayer.GrowthCutout1 ||
                    layer == MeshLayer.GrowthCutout2 ||
                    layer == MeshLayer.GrowthCutout3)
                {
                    translatedLayer = MeshLayer.GrowthCutout;
                }
                else if (layer == MeshLayer.GrowthMaterial1 ||
                         layer == MeshLayer.GrowthMaterial2 ||
                         layer == MeshLayer.GrowthMaterial3)
                {
                    translatedLayer = MeshLayer.GrowthMaterial;
                }
                else if (layer == MeshLayer.GrowthTransparent1 ||
                         layer == MeshLayer.GrowthTransparent2 ||
                         layer == MeshLayer.GrowthTransparent3)
                {
                    translatedLayer = MeshLayer.GrowthTransparent;
                }
                else
                {
                    translatedLayer = layer;
                }
                tempMesh.LoadOBJ(lOBJData, (layer.ToString()));
                if (tempMesh == null || tempMesh.vertexCount == 0)
                {
                    continue;
                }
                tempMesh.name = filePath + "." + layer.ToString();
                if (translatedLayer == MeshLayer.GrowthCutout ||
                    translatedLayer == MeshLayer.GrowthMaterial ||
                    translatedLayer == MeshLayer.GrowthTransparent)
                {
                    for (int i = (int)translatedLayer; i < (int)translatedLayer + 4; i++)
                    {
                        //This is because the tree growths can be in any order
                        //So we just copy the un-numbered one onto the rest.
                        MeshData[(MeshLayer)i] = new CPUMesh(tempMesh);
                    }
                }
                else
                {
                    MeshData[layer] = new CPUMesh(tempMesh);
                }
                tempMesh.Clear();
            }
            lStream  = null;
            lOBJData = null;
        }

        XAttribute rotAtt = elemtype.Attribute("rotation");

        if (rotAtt == null)
        {
            rotationType = RotationType.None;
        }
        else
        {
            try
            {
                rotationType = (RotationType)Enum.Parse(typeof(RotationType), rotAtt.Value);
            }
            catch
            {
                rotationType = RotationType.None;
                Debug.Log("Unknown rotation value: " + rotAtt.Value);
            }
        }
        return(true);
    }
Esempio n. 20
0
    private void InstantiateGo(Vector3 position)
    {
        //Instantiate the a game object from the name of the UI element clicked
        GameObject GO = new GameObject(this.name + "-" + DateTime.Now.ToString("hhmmssffff"));

        //Add material
        MeshRenderer mr = GO.AddComponent <MeshRenderer>();

        mr.material = Resources.Load <Material>("Materials/BenchMat");
        //Load mesh from file
        MeshFilter mf       = GO.AddComponent <MeshFilter>();
        FileStream lStream  = new FileStream(path, FileMode.Open);
        OBJData    lOBJData = OBJLoader.LoadOBJ(lStream);

        lStream.Close();
        mf.mesh.LoadOBJ(lOBJData);
        mf.mesh.RecalculateNormals();

        //Box collider
        BoxCollider collider = GO.AddComponent <BoxCollider>();

        //Create container for rotation
        GameObject container = new GameObject("Container-" + GO.name);

        container.transform.position = collider.bounds.center;
        container.transform.SetParent(GameObject.Find("AdditionalElements").transform, true);
        //Add interactions script
        SelectableElementController selectableElement = container.AddComponent <SelectableElementController>();
        //Check if is alterable
        GameObject alterableElements = GameObject.Find("Alterable");

        if (this.transform.IsChildOf(alterableElements.transform))
        {
            selectableElement.SetAlterable(true);
        }
        else
        {
            selectableElement.SetAlterable(false);
        }

        //Set parent
        GO.transform.SetParent(container.transform, false);
        GO.transform.localPosition = Vector3.zero;
        GO.tag = "AdditionalElements";

        //Normalize scale to MIN_MAX_SIZE Unity units...
        if (collider.bounds.size.x > MIN_MAX_SIZE)
        {
            while (collider.bounds.size.magnitude >= MIN_MAX_SIZE)
            {
                container.transform.localScale -= new Vector3(0.01f, 0.01f, 0.01f);
            }
        }
        else
        {
            while (collider.bounds.size.magnitude <= MIN_MAX_SIZE)
            {
                container.transform.localScale += new Vector3(0.01f, 0.01f, 0.01f);
            }
        }

        container.transform.position = position;

        //Stick to floor
        Bounds  bounds       = collider.bounds;
        float   colliderMinY = bounds.min.y;
        Vector3 newPosition  = container.transform.position;

        if (colliderMinY < 0)
        {
            newPosition += new Vector3(0, -colliderMinY, 0);
        }
        else
        {
            newPosition -= new Vector3(0, colliderMinY, 0);
        }
        container.transform.position = newPosition;

        //Update UI
        HistoryPanelManager.instance.Refresh();
    }