Exemple #1
0
    public static void CreateLight()
    {
        UpdateLights();

        if (GET_LIGHT_AMOUNT() + 1 > MAX_LIGHTS)
        {
            if (!EditorUtility.DisplayDialog(
                    "Too many Vertex Lights",
                    "You're creating more than " + MAX_LIGHTS + " Vertex Lights.\nPlace anyway?",
                    "Place", "Do not place"))
            {
                return;
            }
        }

        GameObject go = new GameObject("VertexLight");

        go.tag = "VLight";

        VLight vl = go.AddComponent <VLight>();

        vl.color = Color.white;
        vl.index = GET_LIGHT_AMOUNT();
        vl.UpdateShaderNames();

        Selection.activeGameObject = go;
    }
Exemple #2
0
    private static GameObject CreateVolumeLight(VLight.LightTypes type)
    {
        VLight[]   otherLights          = GameObject.FindObjectsOfType(typeof(VLight)) as VLight[];
        GameObject volumeLightContainer = new GameObject("V-Light " + otherLights.Length);

        if (SceneView.lastActiveSceneView != null)
        {
            SceneView.lastActiveSceneView.MoveToView(volumeLightContainer.transform);
        }
        VLight light = volumeLightContainer.AddComponent <VLight>();

        volumeLightContainer.camera.enabled = false;

#if UNITY_4_2 || UNITY_4_3 || UNITY_4_4
        volumeLightContainer.camera.fieldOfView   = 45;
        volumeLightContainer.camera.nearClipPlane = 0.1f;
        volumeLightContainer.camera.farClipPlane  = 1;
#else
        volumeLightContainer.camera.fov  = 45;
        volumeLightContainer.camera.near = 0.1f;
        volumeLightContainer.camera.far  = 1;
#endif
        volumeLightContainer.camera.renderingPath    = RenderingPath.VertexLit;
        volumeLightContainer.camera.orthographicSize = 2.5f;

        switch (type)
        {
        case VLight.LightTypes.Spot:
            light.lightType = VLight.LightTypes.Spot;
            break;

        case VLight.LightTypes.Point:
            volumeLightContainer.camera.isOrthoGraphic = true;
#if UNITY_4_2 || UNITY_4_3 || UNITY_4_4
            volumeLightContainer.camera.nearClipPlane    = -volumeLightContainer.camera.farClipPlane;
            volumeLightContainer.camera.orthographicSize = volumeLightContainer.camera.farClipPlane * 2;
#else
            volumeLightContainer.camera.near             = -volumeLightContainer.camera.far;
            volumeLightContainer.camera.orthographicSize = volumeLightContainer.camera.far * 2;
#endif
            light.lightType = VLight.LightTypes.Point;
            break;
        }

        int layer = LayerMask.NameToLayer(VLightManager.VOLUMETRIC_LIGHT_LAYER_NAME);
        if (layer != -1)
        {
            volumeLightContainer.layer = layer;
            volumeLightContainer.camera.cullingMask = ~(1 << layer);
        }

        volumeLightContainer.transform.Rotate(90, 0, 0);
        return(volumeLightContainer);
    }
Exemple #3
0
    public void TriggerFade(bool win)
    {
        fading       = true;
        currentFade  = win ? winRenderer : failRenderer;
        currentLight = win ? winLight : failLight;
        fadeIn       = true;
        fadeTime     = fadeWait;
        fadeAlpha    = 0;

        currentFade.gameObject.SetActive(true);
        var col = currentFade.material.color;

        col.a = fadeAlpha;
        currentFade.material.color = col;

        if (currentLight)
        {
            currentLight.gameObject.SetActive(true);
            currentLight.lightMultiplier = 0;
        }
    }
Exemple #4
0
        public override void InitState()
        {
            VAssImpImp.IPath = "c:/med/";
            ER = new VEnvRenderer(512, 512);
            PR = new VPostProcessRenderer(512, 512);
            // PR.Add(new VPPBlur());
            sg       = new VSceneGraph();
            PR.Scene = sg;
            ER.Scene = sg;

            e1            = VImport.ImportNode("c:/Media/dwarf2.b3d"); //file of 3d model to load.
            e1.LocalScale = new Vector3(1, 1, 1);

            var m1 = new VMaterial();

            m1.TCol = new VTex2D("c:/Media/tex1_c.png", LoadMethod.Single); // texture to load
            m1.TEnv = VTextureUtil.LoadCubeMap("c:/Media/cm1.png.cube");    // cubemap to load. use cubeconvert to convert.
            //m2.TEnv = ER.FB.Cube;
            var ee = e1 as VSceneEntity;

            //var ee2 = e2 as VSceneEntity; //building project atm.
            SetMat(ee, m1);

            // SetMat(ee2, m2);
            sg.Add(e1);
            // sg.Add(e2);

            c1 = new VCam();
            sg.Add(c1);
            l1 = new VLight();
            l1.Pos(new Vector3(0, 40, 0), Space.Local);
            c1.Pos(new Vector3(0, 0, 300), Space.Local);
            c1.LookAt(Vector3.Zero, new Vector3(0, 1, 0));
            sg.Add(l1);
            //e1.Pos(new Vector3(0, -30, 0), Space.Local);
            // e2.Pos(new Vector3(0, 20, 0), Space.Local);
        }
Exemple #5
0
 private void FindTarget()
 {
     light = (VLight)target;
 }
Exemple #6
0
 public virtual void Add(VLight l)
 {
     Lights.Add(l);
 }