private static void CameraSettingOfActorModel(Camera cameraRT, AvatarModel dataAM, float modelOffset)
 {
     if (dataAM.camProjRotRevise.get_Count() >= 2)
     {
         ModelDisplayManager.CameraSettingOfActorModel(cameraRT, new Vector3(0f, dataAM.camProjRotRevise.get_Item(0), dataAM.camProjRotRevise.get_Item(1)), dataAM.camProjPosRevise, modelOffset);
     }
 }
    public static ActorModel SetRawImage(RawImage rawImage, int modelId, Vector2 offsetlocalPos, ref GameObject goModel, ref GameObject goCamera)
    {
        AvatarModel avatarModel = DataReader <AvatarModel> .Get(modelId);

        if (avatarModel == null)
        {
            return(null);
        }
        RenderTexture renderTexture = null;

        RTManager.CreateRenderTexture(ref renderTexture, "temp_render_texture");
        rawImage.GetComponent <RectTransform>().set_sizeDelta(new Vector2((float)renderTexture.get_width(), (float)renderTexture.get_height()));
        RTManager.SetRT(rawImage, renderTexture);
        ActorModel actorModel = ModelDisplayManager.Instance.JustCreateUIModel(0, modelId, avatarModel, true, "CameraRange", offsetlocalPos);
        Camera     camera     = ModelDisplayManager.CreateCameraToModel(renderTexture);

        ModelDisplayManager.CameraSettingOfActorModel(camera, avatarModel, offsetlocalPos.x);
        goModel  = actorModel.get_gameObject();
        goCamera = camera.get_gameObject();
        return(actorModel);
    }
Esempio n. 3
0
    public void SetCameraPosition(RTManager.RtType type, bool bEnable)
    {
        if (CamerasMgr.Camera2RTCommon == null)
        {
            Debug.LogError("CamerasMgr.Camera2RTCommon == null***********************");
            return;
        }
        if (!bEnable)
        {
            return;
        }
        switch (type)
        {
        case RTManager.RtType.LocalHeatDistortion:
            CamerasMgr.Camera2RTCommon.get_transform().set_localPosition(Vector3.get_zero());
            CamerasMgr.Camera2RTCommon.get_transform().set_localScale(Vector3.get_one());
            CamerasMgr.Camera2RTCommon.get_transform().set_localRotation(Quaternion.get_identity());
            break;

        case RTManager.RtType.Player:
        {
            if (this.AimTarget == null)
            {
                Debug.LogError("AimTarget is null");
                return;
            }
            Quaternion rotation = this.AimTarget.get_rotation();
            this.playerTmpPosition = this.AimTarget.get_position();
            Vector3 vector    = rotation * RTManager.Instance.CamProjRotateRevise;
            Vector3 position  = vector + RTManager.Instance.AimTarget.get_transform().get_position();
            Vector3 position2 = this.AimTarget.get_transform().get_position();
            position2.y += this.AimTargetOffsetY;
            CamerasMgr.Camera2RTCommon.get_transform().set_position(position);
            CamerasMgr.Camera2RTCommon.get_transform().LookAt(position2);
            break;
        }

        case RTManager.RtType.ActorModel1:
            if (this.AimTarget != null)
            {
                ModelDisplayManager.CameraSettingOfActorModel(CamerasMgr.Camera2RTCommon, this.CamProjRotateRevise, this.AimTargetOffsetY, 0f);
            }
            break;

        case RTManager.RtType.InstanceBall:
            if (this.AimTarget != null && ModelDisplayManager.Instance.goTerrestrialGlobe != null)
            {
                Vector3 position3 = ModelDisplayManager.Instance.goTerrestrialGlobe.get_transform().FindChild("CameraLookAtPlace").get_position();
                Vector3 position4 = ModelDisplayManager.Instance.goTerrestrialGlobe.get_transform().FindChild("CameraPlace").get_position();
                CamerasMgr.Camera2RTCommon.get_transform().set_position(position4);
                CamerasMgr.Camera2RTCommon.get_transform().LookAt(position3);
            }
            break;

        case RTManager.RtType.ElementBall:
            if (this.AimTarget != null && ModelDisplayManager.Instance.elementBall != null)
            {
                Vector3 position5 = ModelDisplayManager.Instance.elementBall.get_transform().FindChild("CameraLookAtPlace").get_position();
                Vector3 position6 = ModelDisplayManager.Instance.elementBall.get_transform().FindChild("CameraPlace").get_position();
                CamerasMgr.Camera2RTCommon.get_transform().set_position(position6);
                CamerasMgr.Camera2RTCommon.get_transform().LookAt(position5);
                if (BallElement.Instance.distanceVisable == 0f)
                {
                    BallElement.Instance.CalDistance();
                }
            }
            break;
        }
    }