コード例 #1
0
 public void SetRadius(int radius)
 {
     if (Radius != radius)
     {
         Radius    = radius;
         LightArea = new LightArea(RadiusToShadowMapSize(Radius));
     }
 }
コード例 #2
0
    private void OnSceneGUI()
    {
        LightArea fow = (LightArea)target;

        Handles.color = Color.white;
        Handles.DrawWireArc(fow.transform.position, Vector3.up, Vector3.forward, 360, fow.viewRadius);
        Vector3 viewAngleA = fow.DirFromAngle(-fow.viewAngle / 2, false);
        Vector3 viewAngleB = fow.DirFromAngle(fow.viewAngle / 2, false);

        Handles.DrawLine(fow.transform.position, fow.transform.position + viewAngleA * fow.viewRadius);
        Handles.DrawLine(fow.transform.position, fow.transform.position + viewAngleB * fow.viewRadius);
    }
コード例 #3
0
        public AglLightMap(Stream stream)
        {
            var aamp = AampFile.LoadFile(stream);

            LightAreas.Clear();

            foreach (var ob in aamp.RootNode.paramObjects)
            {
                if (ob.HashString == "lut_param")
                {
                    //32 curves.
                    for (int i = 0; i < 32; i++)
                    {
                        LUTParameter param = new LUTParameter();
                        param.Name      = ob.GetEntryValue <StringEntry>($"name{i}").ToString();
                        param.Intensity = GetCurve(ob, $"intensity{i}")[0];
                        LutTable[i]     = param;
                    }
                }
            }
            foreach (var lightAreaParam in aamp.RootNode.childParams)
            {
                var lightArea = new LightArea();
                LightAreas.Add(lightArea);

                foreach (var ob in lightAreaParam.paramObjects)
                {
                    if (ob.HashString == "setting")
                    {
                        lightArea.Settings = new LightSettings(ob);
                    }
                }
                foreach (var c in lightAreaParam.childParams)
                {
                    if (c.HashString == "env_obj_ref_array")
                    {
                        foreach (var childObj in c.paramObjects)
                        {
                            lightArea.Lights.Add(new LightEnvObject(childObj));
                        }
                    }
                }
            }
            Console.WriteLine();
        }
コード例 #4
0
        public AglLightMap()
        {
            LutTable[0] = LUTParameter.Create($"Lambert", new float[] { 0, 0, 0.5f, 0.5f, 0.5f, 0.5f, 1, 1, 0.5f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
            LutTable[1] = LUTParameter.Create($"Half-Lambert", new float[] { 0, 0, 0.5f, 0.5f, 0.5f, 0.5f, 1, 1, 0.5f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
            LutTable[2] = LUTParameter.Create($"Hemisphere", new float[] { 0, 0, 0.5f, 0.5f, 0.5f, 0.5f, 1, 1, 0.5f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
            LutTable[3] = LUTParameter.Create($"Toon1", 18, new float[] { 0, 0, 0.042381f, 0.5f, 0, 0.090593f, 0.567106f, 0.345158f, 0.626382f, 0.582622f, 0.439986f, 0.791862f, 0.593483f, 0.560675f, 1.115393f, 1, 1, 0.042553f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });

            for (int i = 4; i < 32; i++)
            {
                LutTable[i] = LUTParameter.Create($"UserData{i+1}", new float[] { 0, 0, 0.5f, 0.5f, 0.5f, 0.5f, 1, 1, 0.5f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
            }

            //Order matters.
            //Games have a default lmap name list and materials pull from these.
            string[] lmapNames = new string[] {
                "diffuse", "diffuse1", "diffuse2", "diffuse_course4", "diffuse_course3",
                "diffuse_course0", "diffuse3", "diffuse_course2", "diffuse_course1", "diffuse4",
            };
            string[] hemiNames = new string[] {
                "HemiLight_chara0", "HemiLight_chara1", "HemiLight_chara2", "HemiLight_course4", "HemiLight_course3",
                "HemiLight_course0", "HemiLight_chara3", "HemiLight_course2", "HemiLight_course1", "HemiLight_chara4",
            };

            for (int i = 0; i < 8; i++)
            {
                var area = new LightArea();
                area.Settings = new LightSettings(lmapNames[i]);
                area.Lights.Add(new LightEnvObject("AmbientLight", "", true, true));
                area.Lights.Add(new LightEnvObject("DirectionalLight", "MainLight0", true, false));
                area.Lights.Add(new LightEnvObject("DirectionalLight", "", true, false));
                area.Lights.Add(new LightEnvObject("DirectionalLight", "", true, false));
                area.Lights.Add(new LightEnvObject("DirectionalLight", "", true, false));
                area.Lights.Add(new LightEnvObject("HemisphereLight", hemiNames[i], true, true));
                LightAreas.Add(area);
            }
        }
コード例 #5
0
ファイル: Game1.cs プロジェクト: KaptenDavidsson/WindowsGame9
 private void DrawCasters(LightArea lightArea)
 {
     spriteBatch.Begin();
     spriteBatch.Draw(mapBuilder.gridTexture, lightArea.ToRelativePosition(new Vector2(-thisPlayer.Position.X + mapBuilder.gridTexturePlacement.X - mapBuilder.ResidueX + thisPlayer.ScreenCenter.X, -thisPlayer.Position.Y + mapBuilder.gridTexturePlacement.Y - mapBuilder.ResidueY + thisPlayer.ScreenCenter.Y)), Color.Black);
     spriteBatch.End();
 }
コード例 #6
0
ファイル: Game1.cs プロジェクト: KaptenDavidsson/WindowsGame9
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            screenWidth = graphics.GraphicsDevice.PresentationParameters.BackBufferWidth;
            screenHeight = graphics.GraphicsDevice.PresentationParameters.BackBufferHeight;

            thisPlayer.ScreenCenter = new Vector2(screenWidth / 2, screenHeight / 2);
            thisPlayer.Position = new Vector2(1000, 700);
            thisPlayer.Life = 2000;
            thisPlayer.IsThisPlayer = true;

            mapBuilder = new MapBuilder(this, screenWidth, screenHeight, graphics, tileSize, thisPlayer, spriteBatch, players);

            shadowmapResolver = new ShadowmapResolver(GraphicsDevice, quadRender, ShadowmapSize.Size256, ShadowmapSize.Size1024);
            shadowmapResolver.LoadContent(Content);
            lightArea1 = new LightArea(GraphicsDevice, ShadowmapSize.Size1024);
            lightArea2 = new LightArea(GraphicsDevice, ShadowmapSize.Size512);

            lightPosition = thisPlayer.ScreenCenter;
            lightPosition2 = new Vector2(screenWidth / 2 - 80, screenHeight / 2);
            screenShadows = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            crossTexture = Content.Load<Texture2D>("cross");
            font = Content.Load<SpriteFont>("myFont");

            whiteBackground = Content.Load<Texture2D>("Cards/whitebackground");

            startScreen = new StartScreen(spriteBatch, new PlayerCard { Texture = Content.Load<Texture2D>("Cards/human"), BoundingBox = new Rectangle(20, 20, 200, 200), AnimatedTexture = new AnimatedTexture(Content.Load<Texture2D>("PlayerSprites/dudespritesheet"), 4, 4, true, 20, spriteBatch, 50, 50, new Vector2(25, 25), null) },
                new PlayerCard { Texture = Content.Load<Texture2D>("Cards/alien"), BoundingBox = new Rectangle(300, 20, 200, 200), AnimatedTexture = new AnimatedTexture(Content.Load<Texture2D>("PlayerSprites/alienspritesheet"), 4, 4, true, 20, spriteBatch, 70, 70, new Vector2(25, 25), null) },
                thisPlayer, mapBuilder, Content.Load<Texture2D>("Cards/checked"), Content.Load<Texture2D>("Cards/unchecked"), font);

            LoadWeaponDefinitions();

            artificialWallTexture = new AnimatedTexture(Content.Load<Texture2D>("MapItems/artificialwall"), 8, 1, false, 1, spriteBatch, 40, 40, new Vector2(20, 20), null);

            bloodTexture = new AnimatedTexture(Content.Load<Texture2D>("WeaponSprites/blood"), 13, 1, false, 26, spriteBatch, 50, 50, new Vector2(25, 25), null);
        }
コード例 #7
0
 public void SetMask(string mask)
 {
     LightArea.SetMask(mask);
 }