//设置阴影分析范围 private void cb_ShadowType_SelectedIndexChanged(object sender, EventArgs e) { int index = this.cb_ShadowType.SelectedIndex; if (index == 0) { m_shadowType = ShadowType.ALL; m_selection = null; } else if (index == 1) { m_shadowType = ShadowType.SELECTION; } else if (index == 2) { m_shadowType = ShadowType.NONE; m_selection = null; } Layer3Ds layers = m_sceneControl.Scene.Layers; //设置阴影类型 for (int i = 0; i < layers.Count; i++) { Layer3D layer = layers[i]; layer.ShadowType = m_shadowType; } }
private void SetStyle(DatasetType type, Selection3D selection) { switch (type) { case DatasetType.Point3D: mGeostyle_P.IsMarkerSizeFixed = false; mGeostyle_P.MarkerSize = 100; mGeostyle_P.MarkerColor = Color.GreenYellow; selection.Style = mGeostyle_P; break; case DatasetType.Line3D: mGeostyle_L.FillForeColor = Color.GreenYellow; mGeostyle_L.FillMode = FillMode3D.Line; mGeostyle_L.LineColor = Color.GreenYellow; selection.Style = mGeostyle_L; break; } }
//绘制区域并开始分析 private void btn_StartAnalysis_Click(object sender, EventArgs e) { if (m_shadowType == ShadowType.SELECTION) { //目前只允许一次选择一个图层中的对象 Layer3Ds layers = m_sceneControl.Scene.Layers; for (int i = 0; i < layers.Count; i++) { Layer3D layer = layers[i]; Selection3D seletion3D = layer.Selection; if (seletion3D != null) { m_selection = seletion3D; break; } } if (m_selection == null) { MessageBox.Show("请先选择要产生阴影的对象!"); return; } } this.RegisterEvents(false); this.RegisterEvents(true); m_oldAction = m_sceneControl.Action; m_sceneControl.Action = Action3D.CreatePolygon; if (m_shadowQuery == null) { m_shadowQuery = this.CreateShadowVisibilityQuery(); } this.btn_StartAnalysis.Enabled = false; this.btn_ClearResult.Enabled = true; }
protected override void Subscribed() { if (_labyrinthData != null) { Raise(new SetClearColourEvent(_backgroundRed, _backgroundGreen, _backgroundBlue, 1.0f)); return; } var assets = Resolve <IAssetManager>(); var state = Resolve <IGameState>(); var factory = Resolve <ICoreFactory>(); _labyrinthData = assets.LoadLabyrinthData(_mapData.LabDataId); if (_labyrinthData == null) { return; } _logicalMap = new LogicalMap3D(_mapData, _labyrinthData, state.TemporaryMapChanges, state.PermanentMapChanges); var properties = new TilemapRequest { Id = MapId, Width = (uint)_logicalMap.Width, Scale = _labyrinthData.TileSize, Origin = _labyrinthData.TileSize.Y / 2 * Vector3.UnitY, HorizontalSpacing = _labyrinthData.TileSize * Vector3.UnitX, VerticalSpacing = _labyrinthData.TileSize * Vector3.UnitZ, AmbientLightLevel = _labyrinthData.Lighting, FogColor = _labyrinthData.FogColor, ObjectYScaling = _labyrinthData.ObjectYScaling, Pipeline = DungeonTilemapPipeline.Normal }; _selection = AttachChild(new Selection3D()); AttachChild(new MapRenderable3D(_logicalMap, _labyrinthData, properties)); AttachChild(new ScriptManager()); AttachChild(new Collider3D(_logicalMap)); if (!_labyrinthData.BackgroundId.IsNone) { var background = assets.LoadTexture(_labyrinthData.BackgroundId); _skybox = factory.CreateSkybox(background); } var palette = assets.LoadPalette(_logicalMap.PaletteId); uint backgroundColour = palette.GetPaletteAtTime(0)[_labyrinthData.BackgroundColour]; _backgroundRed = (backgroundColour & 0xff) / 255.0f; _backgroundGreen = (backgroundColour & 0xff00 >> 8) / 255.0f; _backgroundBlue = (backgroundColour & 0xff0000 >> 16) / 255.0f; //if(_labyrinthData.CameraHeight != 0) // Debugger.Break(); //if(_labyrinthData.Unk12 != 0) // 7=1|2|4 (Jirinaar), 54=32|16|4|2, 156=128|16|8|2 (Tall town) // Debugger.Break(); // Raise(new LogEvent(LogEvent.Level.Info, $"WallHeight: {_labyrinthData.WallHeight} MaxObj: {maxObjectHeightRaw} EffWallWidth: {_labyrinthData.EffectiveWallWidth}")); foreach (var npc in _logicalMap.Npcs) { if (npc.SpriteOrGroup.IsNone) { continue; } if (npc.SpriteOrGroup.Type != AssetType.ObjectGroup) { Warn($"[3DMap] Tried to load npc with object group of incorrect type: {npc.SpriteOrGroup}"); continue; } if (npc.SpriteOrGroup.Id >= _labyrinthData.ObjectGroups.Count) { Warn($"[3DMap] Tried to load object group {npc.SpriteOrGroup.Id}, but the max group id is {_labyrinthData.ObjectGroups.Count-1}."); continue; } var objectData = _labyrinthData.ObjectGroups[npc.SpriteOrGroup.Id]; // TODO: Verify SpriteOrGroup is an ObjectGroup // TODO: Build proper NPC objects with AI, sound effects etc foreach (var subObject in objectData.SubObjects) { AttachChild(MapObject.Build(npc.Waypoints[0].X, npc.Waypoints[0].Y, _labyrinthData, subObject, properties)); } } for (int y = 0; y < _logicalMap.Height; y++) { for (int x = 0; x < _logicalMap.Width; x++) { var group = _logicalMap.GetObject(x, y); if (group == null) { continue; } foreach (var subObject in group.SubObjects) { AttachChild(MapObject.Build(x, y, _labyrinthData, subObject, properties)); } } } Raise(new SetClearColourEvent(_backgroundRed, _backgroundGreen, _backgroundBlue, 1.0f)); }