public OrderGeneratorResult TryActivate(Scene3D scene) { var transform = new Transform(_position, Quaternion.CreateFromAxisAngle(Vector3.UnitZ, _angle)); // TODO: The collider should be created earlier and updated in UpdatePosition/UpdateDrag // TODO: This should work for all collider types. if (Collider.Create(_buildingDefinition, transform) is BoxCollider collider) { // TODO: Optimise using a quadtree foreach (var obj in scene.GameObjects.Items) { if (!(obj.Collider is BoxCollider otherCollider)) { continue; } if (collider.Intersects(otherCollider)) { return(OrderGeneratorResult.Failure("Intersects an another building.")); } } } var order = Order.CreateBuildObject(scene.GetPlayerIndex(scene.LocalPlayer), _definitionIndex, _position, _angle); // TODO: Check that the target area has been explored // TODO: Check that we still have enough money // TODO: Check that the builder can reach target position // TODO: Check that the terrain is even enough at the target position // TODO: Also send an order to builder to start building. return(OrderGeneratorResult.SuccessAndExit(new[] { order })); }
private void surfacesWireframeAndVerticesSmoothShadingToolStripMenuItem_Click(object sender, EventArgs e) { sphere = new Sphere3D(); sphere.Generate(new List <double>() { 2, 64, 64 }); Scene3D scene = new Scene3D(); scene.LightList.Add(light); scene.AddObject(sphere); sphere.AmbientColor = Color.FromArgb(0, 255, 0); sphere.DiffuseColor = Color.FromArgb(0, 255, 0); sphere.SpecularColor = Color.White; sphere.Shininess = 20; sphere.SetUniformColor(Color.White); // This color is used ONLY for the wireframe. sphere.ShowVertices = true; sphere.ShowWireFrame = true; sphere.ShowSurfaces = true; sphere.WireFrameWidth = 1.5f; sphere.VertexSize = 2.5f; sphere.UseLight = true; sphere.ShadingModel = ShadingModel.Smooth; sphere.Alpha = 0.5f; viewer3D.Scene = scene; }
public void DrawDebugOverlay(Scene3D scene, DrawingContext2D drawingContext) { if (scene?.Shadows.VisualizeShadowFrustums is not true) { return; } for (var splitIndex = 0; splitIndex < _shadowData.NumSplits; splitIndex++) { _lightFrustum.Matrix = _shadowData.ShadowCameraViewProjections[splitIndex]; var corners = _lightFrustum.Corners; var color = CascadeColors[splitIndex]; void DrawLine(int start, int end) { DebugDrawingUtils.DrawLine(drawingContext, scene.Camera, corners[start], corners[end], color); } DrawLine(0, 1); DrawLine(1, 2); DrawLine(2, 3); DrawLine(3, 0); DrawLine(4, 5); DrawLine(5, 6); DrawLine(6, 7); DrawLine(7, 4); DrawLine(0, 4); DrawLine(1, 5); DrawLine(2, 6); DrawLine(3, 7); } }
/// <summary> /// 生成所有图例模型和注释 /// </summary> internal void genAllLegend() { //=====模型图例 Scene3D scene = new Scene3D(); ModelSerial serial = scene.addNewSerial(); serial.mAlign = new Vector3D(0.5, 0, 0.5); foreach (LegendUnit one in ListModelLegend) { one.genModel(); mg.Children.Add(one.mg); } //=====颜色图例 Rectangle rec; TextBlock txt; foreach (string dataname in ListColorLegend.Keys) { rec = new Rectangle() { Width = 10, Height = 10, Stroke = Brushes.White, StrokeThickness = 0.3, Fill = ListColorLegend[dataname], VerticalAlignment = VerticalAlignment.Center }; colorFlag.Children.Add(rec); txt = new TextBlock() { Foreground = Brushes.White, Text = " " + dataname + " ", VerticalAlignment = VerticalAlignment.Center }; colorFlag.Children.Add(txt); } }
public override void Initialize() { Globals.Instance.MFingerEvent.Add3DEventListener(this); this.SetFingerEventActive(true); GameObject girobj = GameObject.Find("Room_sushe01"); SceneHomeObj = girobj; scene3d = girobj.GetComponent <Scene3D>();// as Scene3D; characterCustomizeOne = scene3d.characterCustomizeOne; Dictionary <long, GirlData> dicWarShipData = Globals.Instance.MGameDataManager.MActorData.GetWarshipDataList(); foreach (GirlData girlData in dicWarShipData.Values) { // if(girlData.BasicData.LogicID == 1217002000) // { // // break; // } } characterCustomizeOne.changeCharacterAnimationController("General_Idle"); camera = scene3d.camera; camera.enabled = true; particle = scene3d.particle; particle.Stop(); }
internal ConstructBuildingOrderGenerator( ObjectDefinition buildingDefinition, int definitionIndex, GameData config, Player player, GameContext gameContext, Scene3D scene) { _buildingDefinition = buildingDefinition; _definitionIndex = definitionIndex; _config = config; _scene = scene; // TODO: Should this be relative to the current camera angle? _baseAngle = MathUtility.ToRadians(_buildingDefinition.PlacementViewAngle); _angle = _baseAngle; _previewObject = new GameObject( buildingDefinition, gameContext, player, null) { IsPlacementPreview = true }; UpdatePreviewObjectPosition(); UpdatePreviewObjectAngle(); UpdateValidity(); // TODO: This should work for all collider types. _collider = Collider.Create(_buildingDefinition, _previewObject.Transform) as BoxCollider; }
private void withTextureToolStripMenuItem_Click(object sender, EventArgs e) { const string FILE_NAME = "./EarthTextureSmall.bmp"; if (File.Exists(FILE_NAME)) { Bitmap bitmap = (Bitmap)Image.FromFile(FILE_NAME); viewer3D.AddTexture(bitmap); Scene3D scene = new Scene3D(); scene.LightList.Add(light); sphere = new Sphere3D(); sphere.Generate(new List <double>() { 2, 64, 64 }); sphere.AmbientColor = Color.FromArgb(255, 255, 255); sphere.DiffuseColor = Color.FromArgb(255, 255, 255); sphere.SpecularColor = Color.White; sphere.Shininess = 20; sphere.ShowVertices = false; sphere.ShowWireFrame = false; sphere.ShowSurfaces = true; sphere.UseLight = true; sphere.ShadingModel = ShadingModel.Smooth; sphere.SetTexture(1); scene.AddObject(sphere); viewer3D.Scene = scene; viewer3D.Invalidate(); } }
internal ConstructBuildingOrderGenerator( ObjectDefinition buildingDefinition, int definitionIndex, GameData config, Player player, GameContext gameContext, Scene3D scene) { _buildingDefinition = buildingDefinition; _definitionIndex = definitionIndex; _config = config; _scene = scene; // TODO: Should this be relative to the current camera angle? _angle = MathUtility.ToRadians(_buildingDefinition.PlacementViewAngle); _previewObject = new GameObject( buildingDefinition, gameContext, player, null) { IsPlacementPreview = true }; _scene.BuildPreviewObject = _previewObject; UpdatePreviewObjectPosition(); UpdatePreviewObjectAngle(); UpdateValidity(); }
internal SpecialPowerOrderGenerator( SpecialPower specialPower, GameData config, Player player, GameContext gameContext, SpecialPowerTarget target, Scene3D scene, in TimeInterval time)
/// <summary> /// Default ctor /// </summary> public Scene3DControl() { InitializeComponent(); Scene = new Scene3D(); Drag = new DragBallNavigator(this); ViewerConfig = new GLViewerConfig(); ViewerConfig.LoadDefault(); }
public GameLogic(Scene3D scene3D) { _scene3D = scene3D; _objectDefinitionLookupTable = new ObjectDefinitionLookupTable(scene3D.AssetLoadContext.AssetStore.ObjectDefinitions); _objects = new List <GameObject>(); _techTreeOverrides = new Dictionary <string, ObjectBuildableType>(); }
public void Record(Scene3D scene) { Position = scene.Camera.Transform.Position; Rotation = scene.Camera.Transform.Rotation; FieldOfView = scene.Camera.FieldOfView; YStartPosition = scene.CameraDriver.YStartPosition; MoveMode = scene.CameraDriver.MoveMode; }
public DebugOverlay(Scene3D scene3D, ContentManager contentManager) { _scene3D = scene3D; _debugFont = contentManager.FontManager.GetOrCreateFont("Arial", 16, FontWeight.Normal); _debugStringBuilder = new StringBuilder(); _debugDrawables = new List <IDebugDrawable>(); }
public void Apply(Scene3D scene) { scene.Camera.Transform.Position = Position; scene.Camera.Transform.Rotation = Rotation; scene.Camera.FieldOfView = MathHelper.Clamp(FieldOfView, 3, 179); scene.CameraDriver.YStartPosition = YStartPosition; scene.CameraDriver.MoveMode = MoveMode; }
public void RenderShadowMap( Scene3D scene, GraphicsDevice graphicsDevice, ref ShadowConstantsPS constants, Action <Framebuffer, BoundingFrustum> drawSceneCallback) { // TODO: Use terrain light for terrain self-shadowing? var light = scene.Lighting.CurrentLightingConfiguration.ObjectLightsPS.Light0; // Calculate size of shadow map. var shadowMapSize = scene.Shadows.ShadowMapSize; var numCascades = (uint)scene.Shadows.ShadowMapCascades; if (_shadowData != null && _shadowData.ShadowMap != null && (_shadowData.ShadowMap.Width != shadowMapSize || _shadowData.ShadowMap.Height != shadowMapSize || _shadowData.NearPlaneDistance != scene.Camera.NearPlaneDistance || _shadowData.FarPlaneDistance != scene.Camera.FarPlaneDistance || _shadowData.NumSplits != numCascades)) { RemoveAndDispose(ref _shadowData); } if (_shadowData == null) { _shadowData = AddDisposable(new ShadowData( numCascades, scene.Camera.NearPlaneDistance, scene.Camera.FarPlaneDistance, shadowMapSize, graphicsDevice)); } if (scene.Shadows.ShadowsType == ShadowsType.None) { constants.ShadowsType = ShadowsType.None; return; } _shadowFrustumCalculator.CalculateShadowData( light, scene.Camera, _shadowData, scene.Shadows); constants.Set(numCascades, scene.Shadows, _shadowData); // Render scene geometry to each split of the cascade. for (var splitIndex = 0; splitIndex < _shadowData.NumSplits; splitIndex++) { _lightFrustum.Matrix = _shadowData.ShadowCameraViewProjections[splitIndex]; drawSceneCallback( _shadowData.ShadowMapFramebuffers[splitIndex], _lightFrustum); } }
public override void ExecuteCmd(string szContent, ref GenContext Context, ref ArrayList Output, ref Object Tag) { base.ExecuteCmd(szContent, ref Context, ref Output, ref Tag); if (!(Tag is SceneTree)) { throw new Exception("ExtrudeZCommand::ExecuteCmd:The last parameter must be a SceneTree instance"); } SceneTree sct = (SceneTree)Tag; int iPos = -1; string szPar1 = GenContext.GetFirstParam(szContent, ref iPos, ','); //SourceKeyname string szPar2 = GenContext.GetNextParam(szContent, ref iPos, ','); //z string szPar3 = GenContext.GetNextParam(szContent, ref iPos, ','); //nLat string szPar4 = GenContext.GetNextParam(szContent, ref iPos, ','); //Type abs/rel string szPar5 = GenContext.GetNextParam(szContent, ref iPos, ','); //TargetKeyname float z = (float)Convert.ToDouble(szPar2); if (Convert.ToInt32(szPar3) < 2) { throw new Exception("ExtrudeZCommand:nLat must greater than 1 to create mayesurface"); } if (GenContext.GetNextParam(szContent, ref iPos, ',') != "") { throw new Exception("ExtrudeZCommand:Invalid argument list."); } int iCount = sct.m_Object3DList.Count + 1; if (szPar5 == "") { szPar5 = "\"ExtrudeZ" + iCount.ToString() + "\""; } Object3D ob = sct.GetObject3D(Context.EvalText(szPar1)); MayeArc arc = null; MayeSurface mayesurf = null; if (!(ob is MayeArc)) { throw new Exception("ExtrudeZCommand::ExecuteCmd:Only a MayeArc object can be extruded"); } //sct.DeleteObject3D(ref ob); Object3D tob = sct.GetObject3D(Context.EvalText(szPar5)); if (tob != null) { throw new Exception("ExtrudeZCommand:ExecuteCmd:Cannot extrude in a existing target object."); } arc = (MayeArc)ob; mayesurf = new MayeSurface(Convert.ToInt32(szPar3), arc.m_nLong, ob.m_Color, Context.EvalText(szPar5), false); // mayeLine = new Line3D(new Vector3(x1, y1, z1 ), new Vector3(x2, y2, z2), Convert.ToInt32(szPar7), System.Drawing.Color.FromArgb(Int32.Parse(szPar8, System.Globalization.NumberStyles.HexNumber)), szPar10, false); arc.ExtrudeZ(z, 0, ref mayesurf); Scene3D sc = (Scene3D)sct.m_MainSceneNode.m_Scene3DRef; sct.AddObject3D(sc.m_Keyname, mayesurf); }
public OrderGeneratorResult TryActivate(Scene3D scene) { var playerId = scene.GetPlayerIndex(scene.LocalPlayer); var objectIds = scene.GameObjects.GetObjectIds(scene.LocalPlayer.SelectedUnits); var order = Order.CreateSetRallyPointOrder(playerId, objectIds, _position); // TODO: Also send an order to builder to start building. return(OrderGeneratorResult.SuccessAndExit(new[] { order })); }
public OrderGeneratorResult TryActivate(Scene3D scene) { var transform = new Transform(_position, Quaternion.CreateFromAxisAngle(Vector3.UnitZ, _angle)); var order = Order.CreateBuildObject(scene.GetPlayerIndex(scene.LocalPlayer), _definitionIndex, _position, _angle); // TODO: Check that we still have enough money return(OrderGeneratorResult.SuccessAndExit(new[] { order })); }
public ParticleSystemManager(Scene3D scene, AssetLoadContext assetLoadContext) { _scene = scene; _loadContext = assetLoadContext; _maxParticleCount = assetLoadContext.AssetStore.GameData.Current.MaxParticleCount; _particleSystems = new List <ParticleSystem>(); _renderBucket = scene.RenderScene.CreateRenderBucket("Particles", 15); }
internal GameObjectCollection( AssetLoadContext loadContext, Player civilianPlayer, Navigation.Navigation navigation, Scene3D scene) { _loadContext = loadContext; _items = new List <GameObject>(); _nameLookup = new Dictionary <string, GameObject>(); _civilianPlayer = civilianPlayer; _navigation = navigation; _scene = scene; }
internal SpecialPowerOrderGenerator( SpecialPower specialPower, GameData config, Player player, GameContext gameContext, SpecialPowerTarget target, Scene3D scene) { _specialPower = specialPower; _target = target; _scene = scene; _config = config; }
public Vs1() { InitializeComponent(); Scene3D scene = new Scene3D(); scene.LightList.Add(Light()); _head = new Head(); scene.ObjectList.Add(_head); viewer.Scene = scene; viewer.StartAnimation(); happyButton.Enabled = false; //cba }
private void noLightToolStripMenuItem_Click(object sender, EventArgs e) { Scene3D scene = new Scene3D(); scene.AddObject(sphere); sphere = new Sphere3D(); sphere.Generate(new List <double>() { 2, 64, 64 }); sphere.SetUniformColor(Color.FromArgb(0, 255, 0)); scene.LightList = new List <Light>(); viewer3D.Scene = scene; viewer3D.UseSmoothShading = false; }
private void verticesToolStripMenuItem_Click(object sender, EventArgs e) { sphere = new Sphere3D(); sphere.Generate(new List <double>() { 2, 64, 64 }); Scene3D scene = new Scene3D(); scene.AddObject(sphere); sphere.ShowVertices = true; sphere.ShowWireFrame = false; sphere.ShowSurfaces = false; sphere.VertexSize = 2f; viewer3D.Scene = scene; }
protected virtual REScene PrepareScene(Scene3D scene, Camera3D camera) { var wrappedScene = new REScene(); var preparationContext = new RenderPreparationContext(wrappedScene); preparationContext.PushCoordinateSystem(camera.CoordinateSystem); _shapeDecorator = new Shape3DDecorator(preparationContext); scene.Shapes.AcceptVisitor(_shapeDecorator); wrappedScene.Objects.Add(_shapeDecorator.DecoratedShape); scene.Lights.AcceptVisitor(_shapeDecorator); wrappedScene.Lights.Add(_shapeDecorator.DecoratedLight); preparationContext.PopCoordinateSystem(); return wrappedScene; }
private void wireframeToolStripMenuItem_Click(object sender, EventArgs e) { sphere = new Sphere3D(); sphere.Generate(new List <double>() { 2, 64, 64 }); Scene3D scene = new Scene3D(); scene.AddObject(sphere); sphere.SetUniformColor(Color.FromArgb(255, 255, 255)); sphere.ShowVertices = false; sphere.ShowWireFrame = true; sphere.ShowSurfaces = false; sphere.WireFrameWidth = 1f; viewer3D.Scene = scene; }
private void lightSmoothShadingToolStripMenuItem_Click(object sender, EventArgs e) { sphere = new Sphere3D(); sphere.Generate(new List <double>() { 2, 64, 64 }); sphere.AmbientColor = Color.FromArgb(0, 255, 0); sphere.DiffuseColor = Color.FromArgb(0, 255, 0); sphere.SpecularColor = Color.White; sphere.Shininess = 20; Scene3D scene = new Scene3D(); scene.AddObject(sphere); scene.LightList.Add(light); viewer3D.Scene = scene; viewer3D.UseSmoothShading = true; }
private void runToolStripMenuItem_Click(object sender, EventArgs e) { if (_BlockEvents) { return; } Runner.ScriptedRunner Run = new Runner.ScriptedRunner(800, 600, OpenTK.Graphics.GraphicsMode.Default, _Interface.CurrentGame.Name); Scene NewScene = null; if (_Interface.CurrentScene.Type == SceneType.Scene2D) { NewScene = new Scene2D((Scene2D)_Interface.CurrentScene); } else if (_Interface.CurrentScene.Type == SceneType.Scene3D) { NewScene = new Scene3D((Scene3D)_Interface.CurrentScene); } Run.Init(_Interface.CurrentGame, _Interface.CurrentScene); Run.Run(); }
private void surfacesNoLightToolStripMenuItem_Click(object sender, EventArgs e) { sphere = new Sphere3D(); sphere.Generate(new List <double>() { 2, 64, 64 }); Scene3D scene = new Scene3D(); scene.LightList.Add(light); scene.AddObject(sphere); sphere.SetUniformColor(Color.FromArgb(0, 255, 0)); sphere.ShowVertices = false; sphere.ShowWireFrame = false; sphere.ShowSurfaces = true; sphere.UseLight = false; sphere.ShadingModel = ShadingModel.Flat; scene.LightList = new List <Light>(); viewer3D.Scene = scene; }
private void translucentToolStripMenuItem_Click(object sender, EventArgs e) { sphere = new Sphere3D(); sphere.Generate(new List <double>() { 2, 64, 64 }); Scene3D scene = new Scene3D(); scene.LightList.Add(light); scene.AddObject(sphere); sphere.AmbientColor = Color.FromArgb(255, 255, 255); sphere.DiffuseColor = Color.FromArgb(255, 255, 255); sphere.SpecularColor = Color.White; sphere.Shininess = 20; sphere.ShowVertices = false; sphere.ShowWireFrame = false; sphere.ShowSurfaces = true; sphere.UseLight = true; sphere.ShadingModel = ShadingModel.Smooth; sphere.SetAlpha(0.5f); Sphere3D smallSphere = new Sphere3D(); smallSphere.Generate(new List <double>() { 1.5, 64, 64 }); smallSphere.AmbientColor = Color.FromArgb(0, 0, 255); smallSphere.DiffuseColor = Color.FromArgb(0, 0, 255); smallSphere.SpecularColor = Color.White; smallSphere.Shininess = 20; smallSphere.SetUniformColor(Color.White); // This color is used ONLY for the wireframe. smallSphere.ShowVertices = false; smallSphere.ShowWireFrame = false; smallSphere.ShowSurfaces = true; smallSphere.UseLight = true; smallSphere.ShadingModel = ShadingModel.Smooth; scene.AddObject(smallSphere); scene.SortForTranslucence(); viewer3D.Scene = scene; }
private void surfacesSmoothShadingToolStripMenuItem_Click(object sender, EventArgs e) { sphere = new Sphere3D(); sphere.Generate(new List <double>() { 2, 64, 64 }); Scene3D scene = new Scene3D(); scene.LightList.Add(light); scene.AddObject(sphere); sphere.AmbientColor = Color.FromArgb(0, 255, 0); sphere.DiffuseColor = Color.FromArgb(0, 255, 0); sphere.SpecularColor = Color.White; sphere.Shininess = 20; sphere.ShowVertices = false; sphere.ShowWireFrame = false; sphere.ShowSurfaces = true; sphere.UseLight = true; sphere.ShadingModel = ShadingModel.Smooth; viewer3D.Scene = scene; }
// Error: Error #3709: The depthAndStencil flag in the application descriptor must match the enableDepthAndStencil Boolean passed to configureBackBuffer on the Context3D object. //at flash.display3D::Context3D/configureBackBuffer() //at flare.basic::Scene3D/stageContextEvent()[Z:\projects\flare3d 2.5\src\flare\basic\Scene3D.as:393] public ApplicationSprite() { // crash on orientation change? // galaxy s has 55 fps! scene = new Viewer3D(this); scene.autoResize = true; // this wont work for partial builds // scene.clearColor.setTo(1, 1, 1); Action<ScriptCoreLib.ActionScript.flash.events.Event> contextCreateEvent = e => { // https://github.com/PrimaryFeather/Starling-Framework/issues/74 starlingBack = new Starling(typeof(StarlingBack).ToClassToken(), stage, null, stage.stage3Ds[scene.stageIndex]); starlingBack.start(); starlingTop = new Starling(typeof(StarlingTop).ToClassToken(), stage, null, stage.stage3Ds[scene.stageIndex]); starlingTop.start(); // http://www.flare3d.com/support/index.php?topic=1101.0 this.addChild(new Stats()); }; // why isnt the event found by jsc flash natives gen? scene.addEventListener(ScriptCoreLib.ActionScript.flash.events.Event.CONTEXT3D_CREATE, contextCreateEvent.ToFunction() ); Action<ScriptCoreLib.ActionScript.flash.events.Event> renderEvent = e => { // prevents the 3d scene to render. // we'll handle the render by our own. e.preventDefault(); // draw starling background. starlingBack.nextFrame(); // starling writes the depth buffer, so we need to clear it before draw the 3D stuff. // this wont work for partial builds scene.context.clear(0, 0, 0, 1, 1, 0, (uint)Context3DClearMask.DEPTH); // render 3D scene. // jsc: conflicting event vs member scene.__render(); // draw starling ui. starlingTop.nextFrame(); }; scene.addEventListener(Scene3D.RENDER_EVENT, renderEvent.ToFunction()); model = scene.addChildFromFile(Model.ToByteArrayAsset()); }
public abstract void Render(Scene3D scene, Camera3D camera, Canvas canvas);
public override sealed void Render(Scene3D scene, Camera3D camera, Canvas canvas) { REScene wrappedScene = PrepareScene(scene, camera); Render(wrappedScene, camera, canvas); }
private void pictureBox5_Click(object sender, EventArgs e) { this.Scene = new Scene3D(); }