コード例 #1
0
    override public void Prepare()
    {
        PrepareStructure();
        maxHp         = 10;
        innerPosition = SurfaceRect.one;
        isArtificial  = false;

        mainResource  = ResourceType.Nothing;
        hp            = maxHp;
        resourceCount = 0;
        if (modelController == null)
        {
            modelController = LODController.GetCurrent();
        }
    }
コード例 #2
0
ファイル: MenuUI.cs プロジェクト: Hengle/VoxelGame
    public void Start()
    {
        int k = 0;

        if (PlayerPrefs.HasKey(GameConstants.BASE_SETTINGS_PLAYERPREF))
        {
            k = PlayerPrefs.GetInt(GameConstants.BASE_SETTINGS_PLAYERPREF);
        }

        if ((k & 2) == 0)  // first launch
        {
            LODController.SetLODdistance(0.5f);
            GameObject g = Instantiate(Resources.Load <GameObject>("UIPrefs/firstLaunchPanel"), transform);
            g.GetComponent <FirstLaunchUI>().menuScript = this;
            transform.GetChild(0).gameObject.SetActive(false);
            authorsButton.gameObject.SetActive(false);
        }
        else
        {
            if (saveSystem == null)
            {
                saveSystem = SaveSystemUI.Initialize(transform.root);
            }

            availableGenerationModes = new List <ChunkGenerationMode>()
            {
                ChunkGenerationMode.Standart, ChunkGenerationMode.Cube, ChunkGenerationMode.Peak
            };
            List <string> genModenames = new List <string>();
            foreach (ChunkGenerationMode cmode in availableGenerationModes)
            {
                genModenames.Add(cmode.ToString());
            }
            generationTypeDropdown.AddOptions(genModenames);
            generationTypeDropdown.value = 0;
            newGameGenMode = availableGenerationModes[0];
            LocalizeTitles();
            transform.GetChild(0).gameObject.SetActive(true);
        }
        GameMaster.SetPause(false);
    }
コード例 #3
0
    /// <summary>
    /// Make checks before invoking
    /// </summary>
    public int CreateLODPack(LODPackType i_lpackType, GameObject model, RenderPoint[] renderPoints, int resolution, float shotSize, Color backgroundColor, LODRegisterInfo regInfo)
    {
        backgroundColor.a = 0;
        LODController lcontroller = LODController.GetCurrent();

        backgroundColor.a = 0;
        int savedLayer  = model.layer;
        var layerNumber = 8;

        Renderer[] allObjects = model.transform.GetComponentsInChildren <Renderer>();
        foreach (Renderer r in allObjects)
        {
            r.gameObject.layer = layerNumber;
        }
        if (!PoolMaster.useDefaultMaterials)
        {
            PoolMaster.ReplaceMaterials(allObjects);
        }

        cam.orthographicSize = shotSize;
        cam.backgroundColor  = backgroundColor;

        RenderTexture m_RenderTexture = new RenderTexture(resolution, resolution, 8, RenderTextureFormat.ARGB32);

        cam.transform.parent        = model.transform;
        cam.transform.localRotation = Quaternion.Euler(Vector3.up * 180);

        cam.enabled = true;
        Texture2D atlas;

        switch (i_lpackType)
        {
        case LODPackType.Point:
        {
            cam.transform.localPosition = renderPoints[0].position;
            cam.transform.localRotation = Quaternion.Euler(renderPoints[0].rotation);
            m_RenderTexture.Create();
            cam.targetTexture = m_RenderTexture;
            cam.Render();
            RenderTexture.active = m_RenderTexture;
            atlas = new Texture2D(resolution, resolution);
            atlas.ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
            atlas.Apply();
            break;
        }

        case LODPackType.OneSide:
        {
            Texture2D[] spriteRenders = new Texture2D[4];
            // 0 degrees
            cam.transform.localPosition = renderPoints[0].position;
            cam.transform.localRotation = Quaternion.Euler(renderPoints[0].rotation);
            m_RenderTexture.Create();
            cam.targetTexture = m_RenderTexture;
            cam.Render();
            RenderTexture.active = m_RenderTexture;
            spriteRenders[0]     = new Texture2D(resolution, resolution);
            spriteRenders[0].ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
            spriteRenders[0].Apply();
            // 22.5 degrees
            cam.transform.localPosition = renderPoints[1].position;
            cam.transform.localRotation = Quaternion.Euler(renderPoints[1].rotation);
            m_RenderTexture.Create();
            cam.targetTexture = m_RenderTexture;
            cam.Render();
            RenderTexture.active = m_RenderTexture;
            spriteRenders[1]     = new Texture2D(resolution, resolution);
            spriteRenders[1].ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
            spriteRenders[1].Apply();
            // 45 degrees
            cam.transform.localPosition = renderPoints[2].position;
            cam.transform.localRotation = Quaternion.Euler(renderPoints[2].rotation);
            m_RenderTexture.Create();
            cam.targetTexture = m_RenderTexture;
            cam.Render();
            RenderTexture.active = m_RenderTexture;
            spriteRenders[2]     = new Texture2D(resolution, resolution);
            spriteRenders[2].ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
            spriteRenders[2].Apply();
            // 85 degrees
            cam.transform.localPosition = renderPoints[3].position;
            cam.transform.localRotation = Quaternion.Euler(renderPoints[3].rotation);
            m_RenderTexture.Create();
            cam.targetTexture = m_RenderTexture;
            cam.Render();
            RenderTexture.active = m_RenderTexture;
            spriteRenders[3]     = new Texture2D(resolution, resolution);
            spriteRenders[3].ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
            spriteRenders[3].Apply();

            atlas = new Texture2D(2 * resolution, 2 * resolution);
            atlas.PackTextures(spriteRenders, 0, 2 * resolution, false);
            break;
        }

        case LODPackType.Full:
        {
            Texture2D[] spriteRenders = new Texture2D[32];
            int         index         = 0;
            for (int i = 0; i < 8; i++)
            {
                // 0 degrees
                cam.transform.localPosition = renderPoints[index].position;
                cam.transform.localRotation = Quaternion.Euler(renderPoints[index].rotation);
                m_RenderTexture.Create();
                cam.targetTexture = m_RenderTexture;
                cam.Render();
                RenderTexture.active = m_RenderTexture;
                spriteRenders[index] = new Texture2D(resolution, resolution);
                spriteRenders[index].ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
                spriteRenders[index].Apply();
                index++;
                // 22.5 degrees
                cam.transform.localPosition = renderPoints[index].position;
                cam.transform.localRotation = Quaternion.Euler(renderPoints[index].rotation);
                m_RenderTexture.Create();
                cam.targetTexture = m_RenderTexture;
                cam.Render();
                RenderTexture.active = m_RenderTexture;
                spriteRenders[index] = new Texture2D(resolution, resolution);
                spriteRenders[index].ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
                spriteRenders[index].Apply();
                index++;
                // 45 degrees
                cam.transform.localPosition = renderPoints[index].position;
                cam.transform.localRotation = Quaternion.Euler(renderPoints[index].rotation);
                m_RenderTexture.Create();
                cam.targetTexture = m_RenderTexture;
                cam.Render();
                RenderTexture.active = m_RenderTexture;
                spriteRenders[index] = new Texture2D(resolution, resolution);
                spriteRenders[index].ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
                spriteRenders[index].Apply();
                index++;
                // 85 degrees
                cam.transform.localPosition = renderPoints[index].position;
                cam.transform.localRotation = Quaternion.Euler(renderPoints[index].rotation);
                m_RenderTexture.Create();
                cam.targetTexture = m_RenderTexture;
                cam.Render();
                RenderTexture.active = m_RenderTexture;
                spriteRenders[index] = new Texture2D(resolution, resolution);
                spriteRenders[index].ReadPixels(new Rect(0, 0, resolution, resolution), 0, 0);
                spriteRenders[index].Apply();
                index++;
            }
            atlas = new Texture2D(4 * resolution, 8 * resolution);
            atlas.PackTextures(spriteRenders, 0, 8 * resolution, false);
            break;
        }

        default: return(-1);
        }


        cam.enabled          = false;
        cam.transform.parent = null;
        RenderTexture.active = null;

        foreach (Renderer r in allObjects)
        {
            r.gameObject.layer = savedLayer;
        }
        if (!PoolMaster.useDefaultMaterials)
        {
            PoolMaster.ReplaceMaterials(allObjects);
        }
        return(lcontroller.RegisterLOD(new LODRegistrationTicket(regInfo, atlas, i_lpackType)));
    }
コード例 #4
0
 public void Options_LODdistChanged()
 {
     LODController.SetLODdistance(transform.GetChild(OPTIONS_LOD_DISTANCE_SLIDER_INDEX).GetComponent <Slider>().value);
 }
コード例 #5
0
ファイル: OakTree.cs プロジェクト: Hengle/VoxelGame
    // тоже можно рассовать по методам
    override protected void SetModel()
    {
        // проверка на предыдущую модель не нужна  - устанавливается через SetStage
        if (!modelsContainerReady) // первая загрузка
        {
            startStageSprites    = Resources.LoadAll <Sprite>("Textures/Plants/oakTree");
            blankModelsContainer = new GameObject("oakTreesContainer").transform;

            blankTrees_stage4 = new List <GameObject>();
            blankTrees_stage5 = new List <GameObject>();
            blankTrees_stage6 = new List <GameObject>();

            //stage 4 model
            GameObject model3d = LoadModel(4);

            // хоть это и первая загрузка, лучше всё равно проверить
            LODController currentLC = LODController.GetCurrent();
            int           regIndex  = currentLC.LOD_existanceCheck(oak4_lod_regInfo);
            if (regIndex == -1)
            {
                RenderPoint[] rpoints = new RenderPoint[] {
                    new RenderPoint(new Vector3(0, 0.222f, -0.48f), Vector3.zero),
                    new RenderPoint(new Vector3(0, 0.479f, -0.434f), new Vector3(30, 0, 0)),
                    new RenderPoint(new Vector3(0, 0.458f, -0.232f), new Vector3(45, 0, 0)),
                    new RenderPoint(new Vector3(0, 0.551f, -0.074f), new Vector3(75, 0, 0))
                };
                regIndex = LODSpriteMaker.current.CreateLODPack(LODPackType.OneSide, model3d, rpoints, 32, 0.25f, Color.green, oak4_lod_regInfo);
            }
            LODRegistrationTicket rticket = currentLC.registeredLODs[regIndex];
            lodPack_stage4    = new Sprite[4];
            lodPack_stage4[0] = rticket.sprites[0];
            lodPack_stage4[1] = rticket.sprites[1];
            lodPack_stage4[2] = rticket.sprites[2];
            lodPack_stage4[3] = rticket.sprites[3];


            GameObject fullModel = new GameObject("oak4");
            fullModel.SetActive(false);

            GameObject     spriterCarrier = new GameObject("lodSpriter");
            SpriteRenderer sr             = spriterCarrier.AddComponent <SpriteRenderer>();
            //сначала добавляется спрайт
            sr.sprite         = lodPack_stage4[0];
            sr.sharedMaterial = PoolMaster.useAdvancedMaterials ? PoolMaster.billboardShadedMaterial: PoolMaster.billboardMaterial;
            if (PoolMaster.shadowCasting)
            {
                sr.receiveShadows = true;
            }
            spriterCarrier.transform.parent        = fullModel.transform;
            spriterCarrier.transform.localPosition = Vector3.up * 0.211f;
            // потом модель
            model3d.transform.parent        = fullModel.transform;
            model3d.transform.localPosition = Vector3.zero;
            model3d.transform.localRotation = Quaternion.identity;
            fullModel.transform.parent      = blankModelsContainer;
            blankTrees_stage4.Add(fullModel);

            // stage 5 model
            model3d  = LoadModel(5);
            regIndex = currentLC.LOD_existanceCheck(oak5_lod_regInfo);
            if (regIndex == -1)
            {
                RenderPoint[] rpoints = new RenderPoint[] {
                    new RenderPoint(new Vector3(0, 0.222f, -0.48f), Vector3.zero),
                    new RenderPoint(new Vector3(0, 0.479f, -0.434f), new Vector3(30, 0, 0)),
                    new RenderPoint(new Vector3(0, 0.458f, -0.232f), new Vector3(45, 0, 0)),
                    new RenderPoint(new Vector3(0, 0.551f, -0.074f), new Vector3(75, 0, 0))
                };
                regIndex = LODSpriteMaker.current.CreateLODPack(LODPackType.OneSide, model3d, rpoints, 32, 0.3f, Color.green, oak5_lod_regInfo);
            }
            rticket           = currentLC.registeredLODs[regIndex];
            lodPack_stage5    = new Sprite[4];
            lodPack_stage5[0] = rticket.sprites[0];
            lodPack_stage5[1] = rticket.sprites[1];
            lodPack_stage5[2] = rticket.sprites[2];
            lodPack_stage5[3] = rticket.sprites[3];
            fullModel         = new GameObject("oak5");
            fullModel.SetActive(false);
            spriterCarrier    = new GameObject("lodSpriter");
            sr                = spriterCarrier.AddComponent <SpriteRenderer>();
            sr.sharedMaterial = PoolMaster.useAdvancedMaterials ? PoolMaster.billboardShadedMaterial : PoolMaster.billboardMaterial;;
            if (PoolMaster.shadowCasting)
            {
                sr.receiveShadows = true;
            }
            sr.sprite = lodPack_stage5[0];
            spriterCarrier.transform.parent        = fullModel.transform;
            spriterCarrier.transform.localPosition = Vector3.up * 0.239f;
            model3d.transform.parent        = fullModel.transform;
            model3d.transform.localPosition = Vector3.zero;
            model3d.transform.localRotation = Quaternion.identity;
            fullModel.transform.parent      = blankModelsContainer;
            blankTrees_stage5.Add(fullModel);

            //stage 6 model
            model3d  = LoadModel(6);
            regIndex = currentLC.LOD_existanceCheck(oak6_lod_regInfo);
            if (regIndex == -1)
            {
                RenderPoint[] rpoints = new RenderPoint[] {
                    new RenderPoint(new Vector3(0, 0.222f, -0.48f), Vector3.zero),
                    new RenderPoint(new Vector3(0, 0.479f, -0.434f), new Vector3(30, 0, 0)),
                    new RenderPoint(new Vector3(0, 0.458f, -0.232f), new Vector3(45, 0, 0)),
                    new RenderPoint(new Vector3(0, 0.551f, -0.074f), new Vector3(75, 0, 0))
                };
                regIndex = LODSpriteMaker.current.CreateLODPack(LODPackType.OneSide, model3d, rpoints, 64, 0.45f, Color.green, oak6_lod_regInfo);
            }
            rticket           = currentLC.registeredLODs[regIndex];
            lodPack_stage6    = new Sprite[4];
            lodPack_stage6[0] = rticket.sprites[0];
            lodPack_stage6[1] = rticket.sprites[1];
            lodPack_stage6[2] = rticket.sprites[2];
            lodPack_stage6[3] = rticket.sprites[3];

            fullModel = new GameObject("oak6");
            fullModel.SetActive(false);
            spriterCarrier    = new GameObject("lodSpriter");
            sr                = spriterCarrier.AddComponent <SpriteRenderer>();
            sr.sharedMaterial = PoolMaster.useAdvancedMaterials ? PoolMaster.billboardShadedMaterial : PoolMaster.billboardMaterial;;
            if (PoolMaster.shadowCasting)
            {
                sr.receiveShadows = true;
            }
            sr.sprite = lodPack_stage6[0];
            spriterCarrier.transform.parent        = fullModel.transform;
            spriterCarrier.transform.localPosition = Vector3.up * 0.21f;
            model3d.transform.parent        = fullModel.transform;
            model3d.transform.localPosition = Vector3.zero;
            model3d.transform.localRotation = Quaternion.identity;
            fullModel.transform.parent      = blankModelsContainer;
            blankTrees_stage6.Add(fullModel);
            //
            modelsContainerReady = true;
            FollowingCamera.main.cameraChangedEvent += CameraUpdate;
        }
        if (stage > TRANSIT_STAGE)
        {
            switch (stage)
            {
            case 4:
                if (blankTrees_stage4.Count > 1)
                {
                    int lastIndex = blankTrees_stage4.Count - 1;
                    modelHolder = blankTrees_stage4[lastIndex];
                    blankTrees_stage4.RemoveAt(lastIndex);
                    if (lastIndex > MAX_INACTIVE_BUFFERED_STAGE4)
                    {
                        Destroy(blankTrees_stage4[lastIndex - 1]);
                        blankTrees_stage4.RemoveAt(lastIndex - 1);
                    }
                }
                else
                {
                    modelHolder = Instantiate(blankTrees_stage4[0], Vector3.zero, Quaternion.identity, transform);
                }
                break;

            case 5:
                if (blankTrees_stage5.Count > 1)
                {
                    int lastIndex = blankTrees_stage5.Count - 1;
                    modelHolder = blankTrees_stage5[lastIndex];
                    blankTrees_stage5.RemoveAt(lastIndex);
                    if (lastIndex > MAX_INACTIVE_BUFFERED_STAGE5)
                    {
                        Destroy(blankTrees_stage5[lastIndex - 1]);
                        blankTrees_stage5.RemoveAt(lastIndex - 1);
                    }
                }
                else
                {
                    modelHolder = Instantiate(blankTrees_stage5[0], Vector3.zero, Quaternion.identity, transform);
                }
                break;

            case 6:
                if (blankTrees_stage6.Count > 1)
                {
                    int lastIndex = blankTrees_stage6.Count - 1;
                    modelHolder = blankTrees_stage6[lastIndex];
                    blankTrees_stage6.RemoveAt(lastIndex);
                    if (lastIndex > MAX_INACTIVE_BUFFERED_STAGE6)
                    {
                        Destroy(blankTrees_stage6[lastIndex - 1]);
                        blankTrees_stage6.RemoveAt(lastIndex - 1);
                    }
                }
                else
                {
                    modelHolder = Instantiate(blankTrees_stage6[0], Vector3.zero, Quaternion.identity, transform);
                }
                break;
            }
            modelHolder.transform.parent        = transform;
            modelHolder.transform.localPosition = Vector3.zero;
            modelHolder.transform.rotation      = Quaternion.Euler(0, modelRotation * 90, 0);
            spriter = modelHolder.transform.GetChild(SPRITER_CHILDNUMBER).GetComponent <SpriteRenderer>();
            // # model draw mode check
            float dist = (transform.position - FollowingCamera.camPos).magnitude;
            if (dist < TREE_SPRITE_MAX_VISIBILITY * stage)
            {
                if (dist < LODController.lodCoefficient)
                {
                    modelHolder.transform.GetChild(MODEL_CHILDNUMBER).gameObject.SetActive(true); // model
                    spriter.enabled = false;                                                      // lod sprite
                    drawmode        = OakDrawMode.DrawModel;
                }
                else
                {
                    modelHolder.transform.GetChild(MODEL_CHILDNUMBER).gameObject.SetActive(false); // model
                    // # setting lod (changed)
                    drawmode = OakDrawMode.DrawLOD;
                    byte  spriteNumber = 0;
                    float angle        = Vector3.Angle(Vector3.up, FollowingCamera.camPos - transform.position);
                    if (angle < 30)
                    {
                        if (angle < 10)
                        {
                            spriteNumber = 3;
                        }
                        else
                        {
                            spriteNumber = 2;
                        }
                    }
                    else
                    {
                        if (angle > 80)
                        {
                            spriteNumber = 0;
                        }
                        else
                        {
                            spriteNumber = 1;
                        }
                    }
                    switch (stage)
                    {
                    case 4: spriter.sprite = lodPack_stage4[spriteNumber]; break;

                    case 5: spriter.sprite = lodPack_stage5[spriteNumber]; break;

                    case 6: spriter.sprite = lodPack_stage6[spriteNumber]; break;
                    }
                    lodNumber = spriteNumber;
                    // eo setting lod
                    spriter.enabled = true; // lod sprite
                }
            }
            else
            {
                spriter.enabled = false;
                drawmode        = OakDrawMode.NoDraw;
            }
            modelHolder.SetActive(true);
        }
        else
        {
            GameObject model          = new GameObject("sprite");
            Transform  modelTransform = model.transform;
            modelTransform.parent        = transform;
            modelTransform.localPosition = Vector3.zero;
            //Vector3 cpos = modelTransform.InverseTransformPoint(FollowingCamera.camPos); cpos.y = 0;
            // modelTransform.LookAt(cpos);
            spriter                = modelTransform.gameObject.AddComponent <SpriteRenderer>();
            spriter.sprite         = startStageSprites[stage];
            spriter.sharedMaterial = PoolMaster.verticalWavingBillboardMaterial;
            spriter.enabled        = ((transform.position - FollowingCamera.camPos).magnitude < TREE_SPRITE_MAX_VISIBILITY * stage);
            drawmode               = OakDrawMode.DrawStartSprite;
        }
    }
コード例 #6
0
    // выдаст модели для природных объектов

    protected override void SetModel()
    {
        if (transform.childCount != 0)
        {
            Destroy(transform.GetChild(0).gameObject);
        }
        int        material_ID   = mainResource.ID;
        bool       modelIsSprite = false;
        GameObject model;

        switch (material_ID)
        {
        case ResourceType.STONE_ID:
        case ResourceType.METAL_K_ORE_ID:
        case ResourceType.METAL_S_ORE_ID:
        case ResourceType.METAL_P_ORE_ID:
        case ResourceType.METAL_N_ORE_ID:
        case ResourceType.METAL_E_ORE_ID:
        case ResourceType.METAL_M_ORE_ID:
            model = Instantiate(Resources.Load <GameObject>("Prefs/boulderPref"));
            break;

        case ResourceType.MINERAL_F_ID:
        case ResourceType.MINERAL_L_ID:
            model = Instantiate(Resources.Load <GameObject>("Prefs/pilePref"));
            break;

        case ResourceType.FOOD_ID:
            model         = Instantiate(Resources.Load <GameObject>("Prefs/berryBush"));
            modelIsSprite = true;
            break;

        default:
            model = Instantiate(Resources.Load <GameObject>("Prefs/defaultContainer"));
            break;
        }
        model.transform.parent        = transform;
        model.transform.localPosition = Vector3.zero;
        model.transform.localRotation = Quaternion.Euler(Vector3.zero);
        if (!modelIsSprite)
        {
            Transform meshTransform = transform.GetChild(0).GetChild(0);
            meshTransform.GetComponent <MeshRenderer>().sharedMaterial = ResourceType.GetMaterialById(material_ID, meshTransform.GetComponent <MeshFilter>(), 255);

            short packIndex = -1;
            if (!materialBasedLods.TryGetValue(mainResource, out packIndex))
            {
                Vector3[] positions    = new Vector3[] { new Vector3(0, 0.084f, -0.063f) };
                Vector3[] angles       = new Vector3[] { new Vector3(45, 0, 0) };
                Texture2D spritesAtlas = LODSpriteMaker.current.MakeSpriteLODs(model, positions, angles, 0.06f, Color.grey);
                Sprite[]  lodSprites   = new Sprite[1];

                lodSprites[0] = Sprite.Create(spritesAtlas, new Rect(0, 0, spritesAtlas.width, spritesAtlas.height), new Vector2(0.5f, 0.5f), 512);
                packIndex     = LODController.AddSpritePack(lodSprites);
                materialBasedLods.Add(mainResource, packIndex);
            }
            modelController.AddObject(model.transform, ModelType.Boulder, packIndex);
        }
        else
        {
            //shader replaced
            //FollowingCamera.main.AddSprite(model.transform);
            //haveSprite = true;
        }
    }
コード例 #7
0
    // тоже можно рассовать по методам
    override protected void SetModel()
    {
        // проверка на предыдущую модель не нужна
        if (!modelsContainerReady)
        {
            stageSprites    = Resources.LoadAll <Sprite>("Textures/Plants/oakTree");
            modelsContainer = new GameObject("oakTreesContainer");

            treeBlanks          = new List <GameObject>();
            modelsLodController = LODController.GetCurrent();
            GameObject trunkPref = Load3DModel(4);
            crones_stage4 = trunkPref.transform.GetChild(0).GetComponent <MeshFilter>().sharedMesh;
            trunk_stage4  = trunkPref.transform.GetChild(1).GetComponent <MeshFilter>().sharedMesh;
            ReturnModelToPool(trunkPref);

            trunkPref     = Load3DModel(5);
            crones_stage5 = trunkPref.transform.GetChild(0).GetComponent <MeshFilter>().sharedMesh;
            trunk_stage5  = trunkPref.transform.GetChild(1).GetComponent <MeshFilter>().sharedMesh;
            ReturnModelToPool(trunkPref);

            trunkPref     = Load3DModel(6);
            crones_stage6 = trunkPref.transform.GetChild(0).GetComponent <MeshFilter>().sharedMesh;
            trunk_stage6  = trunkPref.transform.GetChild(1).GetComponent <MeshFilter>().sharedMesh;
            ReturnModelToPool(trunkPref);

            modelsContainerReady = true;
        }
        GameObject model = null;

        if (stage > TRANSIT_STAGE)
        {
            if (treeBlanks.Count == 0)
            {
                model = Load3DModel(stage);
            }
            else
            {
                int last = treeBlanks.Count - 1;
                model = treeBlanks[last];
                treeBlanks.RemoveAt(last);
            }
            Transform modelTransform = model.transform;

            short packIndex = -1;
            switch (stage)
            {
            case 4:
                modelTransform.GetChild(0).GetComponent <MeshFilter>().sharedMesh = crones_stage4;
                modelTransform.GetChild(1).GetComponent <MeshFilter>().sharedMesh = trunk_stage4;
                packIndex = oak4spritesIndex;
                break;

            case 5:
                modelTransform.GetChild(0).GetComponent <MeshFilter>().sharedMesh = crones_stage5;
                modelTransform.GetChild(1).GetComponent <MeshFilter>().sharedMesh = trunk_stage5;
                packIndex = oak5spritesIndex;
                break;

            case 6:
                modelTransform.GetChild(0).GetComponent <MeshFilter>().sharedMesh = crones_stage6;
                modelTransform.GetChild(1).GetComponent <MeshFilter>().sharedMesh = trunk_stage6;
                packIndex = oak6spritesIndex;
                break;
            }
            modelsLodController.ChangeModelSpritePack(modelTransform, ModelType.Tree, packIndex);
            model.transform.parent        = transform;
            model.transform.localPosition = Vector3.zero;
        }
        else
        {
            modelTransform = new GameObject("sprite").transform;
            modelTransform.transform.parent = transform;
            modelTransform.localPosition    = Vector3.zero;
            //Vector3 cpos = modelTransform.InverseTransformPoint(FollowingCamera.camPos); cpos.y = 0;
            // modelTransform.LookAt(cpos);
            SpriteRenderer sr = modelTransform.gameObject.AddComponent <SpriteRenderer>();
            sr.sprite = stageSprites[stage];
        }
    }
コード例 #8
0
    static GameObject Load3DModel(byte stage)
    {
        GameObject loadedModel = null;

        loadedModel = Instantiate(Resources.Load <GameObject>("Lifeforms/oak-" + stage.ToString()));
        short modelSpritePack = 0;

        switch (stage)
        {
        case 4:
            if (oak4spritesIndex == -1)
            {
                Vector3[] positions    = new Vector3[] { new Vector3(0, 0.222f, -0.48f), new Vector3(0, 0.479f, -0.434f), new Vector3(0, 0.458f, -0.232f), new Vector3(0, 0.551f, -0.074f) };
                Vector3[] angles       = new Vector3[] { Vector3.zero, new Vector3(30, 0, 0), new Vector3(45, 0, 0), new Vector3(75, 0, 0) };
                Texture2D spritesAtlas = LODSpriteMaker.current.MakeSpriteLODs(loadedModel, positions, angles, 0.25f, Color.green);
                Sprite[]  lodSprites   = new Sprite[4];
                int       size         = spritesAtlas.width / 2;

                lodSprites[0]    = Sprite.Create(spritesAtlas, new Rect(0, 0, size, size), new Vector2(0.5f, 0.5f), 128);
                lodSprites[1]    = Sprite.Create(spritesAtlas, new Rect(size, 0, size, size), new Vector2(0.5f, 0.5f), 128);
                lodSprites[2]    = Sprite.Create(spritesAtlas, new Rect(0, size, size, size), new Vector2(0.5f, 0.5f), 128);
                lodSprites[3]    = Sprite.Create(spritesAtlas, new Rect(size, size, size, size), new Vector2(0.5f, 0.5f), 128);
                oak4spritesIndex = LODController.AddSpritePack(lodSprites);
            }
            modelSpritePack = oak4spritesIndex;
            break;

        case 5:
            if (oak5spritesIndex == -1)
            {
                Vector3[] positions    = new Vector3[] { new Vector3(0, 0.222f, -0.48f), new Vector3(0, 0.479f, -0.434f), new Vector3(0, 0.458f, -0.232f), new Vector3(0, 0.551f, -0.074f) };
                Vector3[] angles       = new Vector3[] { Vector3.zero, new Vector3(30, 0, 0), new Vector3(45, 0, 0), new Vector3(75, 0, 0) };
                Texture2D spritesAtlas = LODSpriteMaker.current.MakeSpriteLODs(loadedModel, positions, angles, 0.25f, Color.green);
                Sprite[]  lodSprites   = new Sprite[4];
                int       size         = spritesAtlas.width / 2;

                lodSprites[0]    = Sprite.Create(spritesAtlas, new Rect(0, 0, size, size), new Vector2(0.5f, 0.5f), 128);
                lodSprites[1]    = Sprite.Create(spritesAtlas, new Rect(size, 0, size, size), new Vector2(0.5f, 0.5f), 128);
                lodSprites[2]    = Sprite.Create(spritesAtlas, new Rect(0, size, size, size), new Vector2(0.5f, 0.5f), 128);
                lodSprites[3]    = Sprite.Create(spritesAtlas, new Rect(size, size, size, size), new Vector2(0.5f, 0.5f), 128);
                oak5spritesIndex = LODController.AddSpritePack(lodSprites);
            }
            modelSpritePack = oak5spritesIndex;
            break;

        case 6:
            if (oak6spritesIndex == -1)
            {
                Vector3[] positions    = new Vector3[] { new Vector3(0, 0.222f, -0.48f), new Vector3(0, 0.479f, -0.434f), new Vector3(0, 0.458f, -0.232f), new Vector3(0, 0.551f, -0.074f) };
                Vector3[] angles       = new Vector3[] { Vector3.zero, new Vector3(30, 0, 0), new Vector3(45, 0, 0), new Vector3(75, 0, 0) };
                Texture2D spritesAtlas = LODSpriteMaker.current.MakeSpriteLODs(loadedModel, positions, angles, 0.25f, Color.green);
                Sprite[]  lodSprites   = new Sprite[4];
                int       size         = spritesAtlas.width / 2;

                lodSprites[0]    = Sprite.Create(spritesAtlas, new Rect(0, 0, size, size), new Vector2(0.5f, 0.5f), 128);
                lodSprites[1]    = Sprite.Create(spritesAtlas, new Rect(size, 0, size, size), new Vector2(0.5f, 0.5f), 128);
                lodSprites[2]    = Sprite.Create(spritesAtlas, new Rect(0, size, size, size), new Vector2(0.5f, 0.5f), 128);
                lodSprites[3]    = Sprite.Create(spritesAtlas, new Rect(size, size, size, size), new Vector2(0.5f, 0.5f), 128);
                oak6spritesIndex = LODController.AddSpritePack(lodSprites);
            }
            modelSpritePack = oak6spritesIndex;
            break;
        }
        modelsLodController.AddObject(loadedModel.transform.GetChild(2), ModelType.Tree, modelSpritePack);
        return(loadedModel);
    }
コード例 #9
0
    protected override void SetModel()
    {
        if (transform.childCount == 0)
        {
            GameObject model;

            bool            createSpriteLOD = false;
            LODRegisterInfo regInfo         = new LODRegisterInfo(0, 0, 0);
            float           height          = 0;
            switch (model_id)
            {
            case ContainerModelType.DeadLifestone:
            {
                model = Instantiate(Resources.Load <GameObject>("Structures/LifeStone"));
                Destroy(model.transform.GetChild(0).gameObject);
                Destroy(model.transform.GetChild(1).gameObject);
                MeshRenderer[] mrrs = model.GetComponentsInChildren <MeshRenderer>();
                foreach (MeshRenderer mr in mrrs)
                {
                    mr.sharedMaterial = PoolMaster.GetMaterial(MaterialType.Basic);
                }
                break;
            }

            case ContainerModelType.DeadTreeOfLife:
            {
                model = Instantiate(Resources.Load <GameObject>("Lifeforms/deadTreeOfLife"));
                break;
            }

            case ContainerModelType.DeadOak4:
            {
                model           = Instantiate(Resources.Load <GameObject>("Lifeforms/oak-4_dead"));
                createSpriteLOD = true;
                regInfo         = new LODRegisterInfo(LODController.CONTAINER_MODEL_ID, (int)ContainerModelType.DeadOak4, 0);
                height          = 0.211f;
                break;
            }

            case ContainerModelType.DeadOak5:
            {
                model           = Instantiate(Resources.Load <GameObject>("Lifeforms/oak-6_dead"));
                createSpriteLOD = true;
                regInfo         = new LODRegisterInfo(LODController.CONTAINER_MODEL_ID, (int)ContainerModelType.DeadOak5, 0);
                height          = 0.211f;
                break;
            }

            case ContainerModelType.DeadOak6:
            {
                model           = Instantiate(Resources.Load <GameObject>("Lifeforms/oak-6_dead"));
                createSpriteLOD = true;
                regInfo         = new LODRegisterInfo(LODController.CONTAINER_MODEL_ID, (int)ContainerModelType.DeadOak6, 0);
                height          = 0.211f;
                break;
            }

            case ContainerModelType.Pile:
            {
                model = Instantiate(Resources.Load <GameObject>("Prefs/pilePref"));

                createSpriteLOD = true;
                regInfo         = new LODRegisterInfo((int)ContainerModelType.Pile, 0, mainResource.ID);
                height          = 0.047f;

                Transform meshTransform = model.transform.GetChild(0);
                var       mf            = meshTransform.GetComponent <MeshFilter>();
                var       mr            = meshTransform.GetComponent <MeshRenderer>();
                PoolMaster.SetMaterialByID(
                    ref mf,
                    ref mr,
                    mainResource.ID,
                    255
                    );
                break;
            }

            case ContainerModelType.BerryBush:
            {
                model = Instantiate(Resources.Load <GameObject>("Prefs/berryBush"));
                //if (PoolMaster.shadowCasting) PoolMaster.ReplaceMaterials(model, true);
                break;
            }

            case ContainerModelType.Boulder:
            {
                model = Instantiate(Resources.Load <GameObject>("Prefs/boulderPref"));
                Transform meshTransform = model.transform.GetChild(0);
                var       mf            = meshTransform.GetComponent <MeshFilter>();
                var       mr            = meshTransform.GetComponent <MeshRenderer>();
                PoolMaster.SetMaterialByID(
                    ref mf,
                    ref mr,
                    mainResource.ID,
                    255
                    );

                regInfo         = new LODRegisterInfo((int)ContainerModelType.Boulder, 0, mainResource.ID);
                createSpriteLOD = true;
                height          = 0.047f;
                break;
            }

            default:
            {
                model = Instantiate(Resources.Load <GameObject>("Prefs/defaultContainer"));
                Transform meshTransform = model.transform.GetChild(0);
                var       mf            = meshTransform.GetComponent <MeshFilter>();
                var       mr            = meshTransform.GetComponent <MeshRenderer>();
                PoolMaster.SetMaterialByID(
                    ref mf,
                    ref mr,
                    mainResource.ID,
                    255
                    );
                break;
            }
            }

            if (createSpriteLOD)
            {
                SpriteRenderer sr = new GameObject("lod").AddComponent <SpriteRenderer>();
                sr.transform.parent        = model.transform;
                sr.transform.localPosition = Vector3.up * height;
                sr.sharedMaterial          = !PoolMaster.useDefaultMaterials ? PoolMaster.billboardShadedMaterial : PoolMaster.billboardMaterial;
                if (PoolMaster.shadowCasting)
                {
                    sr.receiveShadows = true;
                }
                LODController currentLC         = LODController.GetCurrent();
                LODPackType   lpackType         = LODPackType.Point;
                int           indexInRegistered = currentLC.LOD_existanceCheck(regInfo);

                if (indexInRegistered == -1)
                {
                    int           resolution      = 8;
                    float         size            = 0.05f;
                    Color         backgroundColor = Color.gray;
                    RenderPoint[] renderpoints    = new RenderPoint[] { };

                    switch (model_id)
                    {
                    case ContainerModelType.Pile:
                    {
                        renderpoints = new RenderPoint[] { new RenderPoint(new Vector3(0, 0.084f, -0.063f), new Vector3(45, 0, 0)) };
                        break;
                    }

                    case ContainerModelType.Boulder:
                    {
                        renderpoints = new RenderPoint[] { new RenderPoint(new Vector3(0, 0.084f, -0.063f), new Vector3(45, 0, 0)) };
                        break;
                    }

                    case ContainerModelType.DeadOak4:
                    {
                        renderpoints = new RenderPoint[] {
                            new RenderPoint(new Vector3(0, 0.222f, -0.48f), Vector3.zero),
                            new RenderPoint(new Vector3(0, 0.479f, -0.434f), new Vector3(30, 0, 0)),
                            new RenderPoint(new Vector3(0, 0.458f, -0.232f), new Vector3(45, 0, 0)),
                            new RenderPoint(new Vector3(0, 0.551f, -0.074f), new Vector3(75, 0, 0))
                        };
                        size       = 0.2f;
                        resolution = 32;
                        lpackType  = LODPackType.OneSide;
                        break;
                    }

                    case ContainerModelType.DeadOak5:
                    {
                        renderpoints = new RenderPoint[] {
                            new RenderPoint(new Vector3(0, 0.222f, -0.48f), Vector3.zero),
                            new RenderPoint(new Vector3(0, 0.479f, -0.434f), new Vector3(30, 0, 0)),
                            new RenderPoint(new Vector3(0, 0.458f, -0.232f), new Vector3(45, 0, 0)),
                            new RenderPoint(new Vector3(0, 0.551f, -0.074f), new Vector3(75, 0, 0))
                        };
                        size       = 0.25f;
                        resolution = 32;
                        lpackType  = LODPackType.OneSide;
                        break;
                    }

                    case ContainerModelType.DeadOak6:
                    {
                        renderpoints = new RenderPoint[] {
                            new RenderPoint(new Vector3(0, 0.222f, -0.48f), Vector3.zero),
                            new RenderPoint(new Vector3(0, 0.479f, -0.434f), new Vector3(30, 0, 0)),
                            new RenderPoint(new Vector3(0, 0.458f, -0.232f), new Vector3(45, 0, 0)),
                            new RenderPoint(new Vector3(0, 0.551f, -0.074f), new Vector3(75, 0, 0))
                        };
                        size       = 0.4f;
                        resolution = 64;
                        lpackType  = LODPackType.OneSide;
                        break;
                    }
                    }

                    indexInRegistered = LODSpriteMaker.current.CreateLODPack(lpackType, model, renderpoints, resolution, size, backgroundColor, regInfo);
                }
                model.transform.parent        = transform;
                model.transform.localPosition = Vector3.zero;
                model.transform.localRotation = Quaternion.Euler(Vector3.zero);
                lodComponent = currentLC.SetInControl(basement, model.transform.GetChild(0).gameObject, sr, indexInRegistered);
            }
            else
            {
                model.transform.parent        = transform;
                model.transform.localPosition = Vector3.zero;
                model.transform.localRotation = Quaternion.Euler(Vector3.zero);
            }
        }
    }
コード例 #10
0
    public static HarvestableResource ConstructContainer(ContainerModelType i_modelType, ResourceType i_rtype, float i_count)
    {
        HarvestableResource hr = new GameObject().AddComponent <HarvestableResource>();

        hr.ID = CONTAINER_ID;
        hr.PrepareStructure();
        hr.mainResource  = i_rtype;
        hr.resourceCount = i_count;
        GameObject model;

        bool            createSpriteLOD = false;
        LODRegisterInfo regInfo         = new LODRegisterInfo(0, 0, 0);
        float           height          = 0;

        hr.model_id = i_modelType;
        switch (hr.model_id)
        {
        case ContainerModelType.DeadLifestone:
        {
            hr.gameObject.name = "dead Lifestone";
            model = Instantiate(Resources.Load <GameObject>("Structures/LifeStone"));
            Destroy(model.transform.GetChild(0).gameObject);
            Destroy(model.transform.GetChild(1).gameObject);
            MeshRenderer[] mrrs = model.GetComponentsInChildren <MeshRenderer>();
            foreach (MeshRenderer mr in mrrs)
            {
                mr.sharedMaterial = PoolMaster.GetMaterial(MaterialType.Basic);
            }
            byte c = (byte)(PlaneExtension.INNER_RESOLUTION / 4);
            hr.surfaceRect = new SurfaceRect(c, c, (byte)(c + c));
            hr.maxHp       = LifeSource.MAX_HP * 0.9f;
            break;
        }

        case ContainerModelType.DeadTreeOfLife:
        {
            hr.gameObject.name = "dead Tree of Life";
            model = Instantiate(Resources.Load <GameObject>("Lifeforms/deadTreeOfLife"));
            byte c = (byte)(PlaneExtension.INNER_RESOLUTION / 4);
            hr.surfaceRect = new SurfaceRect(c, c, (byte)(c + c));
            hr.maxHp       = LifeSource.MAX_HP * 0.9f;
            break;
        }

        case ContainerModelType.DeadOak4:
            hr.gameObject.name = "dead oak 4";
            model          = Instantiate(Resources.Load <GameObject>("Lifeforms/oak-4_dead"));
            hr.surfaceRect = SurfaceRect.one;
            hr.maxHp       = 50;

            createSpriteLOD = true;
            regInfo         = new LODRegisterInfo(LODController.CONTAINER_MODEL_ID, (int)ContainerModelType.DeadOak4, 0);
            height          = 0.211f;
            break;

        case ContainerModelType.DeadOak5:
            hr.gameObject.name = "dead oak 5";
            model          = Instantiate(Resources.Load <GameObject>("Lifeforms/oak-6_dead"));
            hr.surfaceRect = SurfaceRect.one;
            hr.maxHp       = 100;

            createSpriteLOD = true;
            regInfo         = new LODRegisterInfo(LODController.CONTAINER_MODEL_ID, (int)ContainerModelType.DeadOak5, 0);
            height          = 0.211f;
            break;

        case ContainerModelType.DeadOak6:
            hr.gameObject.name = "dead oak 6";
            model          = Instantiate(Resources.Load <GameObject>("Lifeforms/oak-6_dead"));
            hr.surfaceRect = SurfaceRect.one;
            hr.maxHp       = 200;

            createSpriteLOD = true;
            regInfo         = new LODRegisterInfo(LODController.CONTAINER_MODEL_ID, (int)ContainerModelType.DeadOak6, 0);
            height          = 0.211f;
            break;

        case ContainerModelType.Pile:
        {
            hr.gameObject.name = "pile";
            model = Instantiate(Resources.Load <GameObject>("Prefs/pilePref"));

            createSpriteLOD = true;
            regInfo         = new LODRegisterInfo((int)ContainerModelType.Pile, 0, hr.mainResource.ID);
            height          = 0.047f;

            Transform meshTransform = model.transform.GetChild(0);
            var       mf            = meshTransform.GetComponent <MeshFilter>();
            var       mr            = meshTransform.GetComponent <MeshRenderer>();
            PoolMaster.SetMaterialByID(
                ref mf,
                ref mr,
                i_rtype.ID,
                255
                );
            hr.maxHp       = 30;
            hr.surfaceRect = SurfaceRect.one;
            break;
        }

        case ContainerModelType.BerryBush:
        {
            hr.gameObject.name = "berry bush";
            model = Instantiate(Resources.Load <GameObject>("Prefs/berryBush"));
            //if (PoolMaster.shadowCasting) PoolMaster.ReplaceMaterials(model, true);
            hr.maxHp       = 10;
            hr.surfaceRect = SurfaceRect.one;
            break;
        }

        case ContainerModelType.Boulder:
        {
            hr.gameObject.name = "boulder";
            model = Instantiate(Resources.Load <GameObject>("Prefs/boulderPref"));
            Transform meshTransform = model.transform.GetChild(0);
            var       mf            = meshTransform.GetComponent <MeshFilter>();
            var       mr            = meshTransform.GetComponent <MeshRenderer>();
            PoolMaster.SetMaterialByID(
                ref mf,
                ref mr,
                i_rtype.ID,
                255
                );

            regInfo         = new LODRegisterInfo((int)ContainerModelType.Boulder, 0, hr.mainResource.ID);
            createSpriteLOD = true;
            height          = 0.047f;

            hr.maxHp       = 50;
            hr.surfaceRect = SurfaceRect.one;
            break;
        }

        default:
        {
            hr.gameObject.name = "default container";
            model = Instantiate(Resources.Load <GameObject>("Prefs/defaultContainer"));
            Transform meshTransform = model.transform.GetChild(0);
            var       mf            = meshTransform.GetComponent <MeshFilter>();
            var       mr            = meshTransform.GetComponent <MeshRenderer>();
            PoolMaster.SetMaterialByID(
                ref mf,
                ref mr,
                i_rtype.ID,
                255
                );

            hr.model_id = ContainerModelType.Default;

            hr.maxHp       = 10;
            hr.surfaceRect = SurfaceRect.one;
            break;
        }
        }
        hr.hp = hr.maxHp;

        if (createSpriteLOD)
        {
            SpriteRenderer sr = new GameObject("lod").AddComponent <SpriteRenderer>();
            sr.transform.parent        = model.transform;
            sr.transform.localPosition = Vector3.up * height;
            sr.sharedMaterial          = PoolMaster.useAdvancedMaterials ? PoolMaster.billboardShadedMaterial : PoolMaster.billboardMaterial;;
            if (PoolMaster.shadowCasting)
            {
                sr.receiveShadows = true;
            }
            LODController currentLC = LODController.GetCurrent();
            LODPackType   lpackType = LODPackType.Point;
            int           indexInRegistered = currentLC.LOD_existanceCheck(regInfo);
            float         lodDistance = 6, visibilityDistance = 15;

            if (indexInRegistered == -1)
            {
                int           resolution      = 8;
                float         size            = 0.05f;
                Color         backgroundColor = Color.gray;
                RenderPoint[] renderpoints    = new RenderPoint[] { };

                switch (hr.model_id)
                {
                case ContainerModelType.Pile:
                {
                    renderpoints = new RenderPoint[] { new RenderPoint(new Vector3(0, 0.084f, -0.063f), new Vector3(45, 0, 0)) };
                    break;
                }

                case ContainerModelType.Boulder:
                {
                    renderpoints = new RenderPoint[] { new RenderPoint(new Vector3(0, 0.084f, -0.063f), new Vector3(45, 0, 0)) };
                    break;
                }

                case ContainerModelType.DeadOak4:
                {
                    renderpoints = new RenderPoint[] {
                        new RenderPoint(new Vector3(0, 0.222f, -0.48f), Vector3.zero),
                        new RenderPoint(new Vector3(0, 0.479f, -0.434f), new Vector3(30, 0, 0)),
                        new RenderPoint(new Vector3(0, 0.458f, -0.232f), new Vector3(45, 0, 0)),
                        new RenderPoint(new Vector3(0, 0.551f, -0.074f), new Vector3(75, 0, 0))
                    };
                    size               = 0.2f;
                    resolution         = 32;
                    lpackType          = LODPackType.OneSide;
                    lodDistance        = 15;
                    visibilityDistance = 24;
                    break;
                }

                case ContainerModelType.DeadOak5:
                {
                    renderpoints = new RenderPoint[] {
                        new RenderPoint(new Vector3(0, 0.222f, -0.48f), Vector3.zero),
                        new RenderPoint(new Vector3(0, 0.479f, -0.434f), new Vector3(30, 0, 0)),
                        new RenderPoint(new Vector3(0, 0.458f, -0.232f), new Vector3(45, 0, 0)),
                        new RenderPoint(new Vector3(0, 0.551f, -0.074f), new Vector3(75, 0, 0))
                    };
                    size               = 0.25f;
                    resolution         = 32;
                    lpackType          = LODPackType.OneSide;
                    lodDistance        = 18;
                    visibilityDistance = 28;
                    break;
                }

                case ContainerModelType.DeadOak6:
                {
                    renderpoints = new RenderPoint[] {
                        new RenderPoint(new Vector3(0, 0.222f, -0.48f), Vector3.zero),
                        new RenderPoint(new Vector3(0, 0.479f, -0.434f), new Vector3(30, 0, 0)),
                        new RenderPoint(new Vector3(0, 0.458f, -0.232f), new Vector3(45, 0, 0)),
                        new RenderPoint(new Vector3(0, 0.551f, -0.074f), new Vector3(75, 0, 0))
                    };
                    size               = 0.4f;
                    lodDistance        = 21;
                    visibilityDistance = 32;
                    resolution         = 64;
                    lpackType          = LODPackType.OneSide;
                    break;
                }
                }

                indexInRegistered = LODSpriteMaker.current.CreateLODPack(lpackType, model, renderpoints, resolution, size, backgroundColor, regInfo);
            }
            model.transform.parent        = hr.transform;
            model.transform.localPosition = Vector3.zero;
            model.transform.localRotation = Quaternion.Euler(Vector3.zero);
            LODController.GetCurrent().TakeCare(model.transform, indexInRegistered, lodDistance, visibilityDistance);
        }
        else
        {
            model.transform.parent        = hr.transform;
            model.transform.localPosition = Vector3.zero;
            model.transform.localRotation = Quaternion.Euler(Vector3.zero);
        }
        return(hr);
    }