public OcclusionCullingScreen(IServiceLocator services) : base(services) { _sceneNodes = new List <SceneNode>(); // Create new occlusion buffer with default settings. OcclusionBuffer = new OcclusionBuffer(GraphicsService); OcclusionBuffer.ProgressiveShadowCasterCulling = true; EnableCulling = true; // Create a second camera for rendering a top-down view of the scene. var topDownPerspective = new PerspectiveProjection(); topDownPerspective.SetFieldOfView(MathHelper.ToRadians(90), 1, 1, 512); _topDownCameraNode = new CameraNode(new Camera(topDownPerspective)); _topDownCameraNode.PoseWorld = new Pose(new Vector3F(-10, 120, -10)); _topDownCameraNode.LookAt(new Vector3F(-10, 0, -10), Vector3F.UnitZ); _sceneQuery = new CustomSceneQuery(); _debugRenderer = new DebugRenderer(GraphicsService, null, null); // The DigitalRune Profiler is used to measure execution times. Profiler.SetFormat("Occlusion.Render", 1e3f, "[ms]"); Profiler.SetFormat("Occlusion.Query", 1e3f, "[ms]"); }
public MyGraphicsScreen(IGraphicsService graphicsService) : base(graphicsService) { _meshRenderer = new MeshRenderer(); var contentManager = ServiceLocator.Current.GetInstance <ContentManager>(); var spriteFont = contentManager.Load <SpriteFont>("SpriteFont1"); _debugRenderer = new DebugRenderer(graphicsService, spriteFont); Scene = new Scene(); // Add a camera with a perspective projection. var projection = new PerspectiveProjection(); projection.SetFieldOfView( ConstantsF.PiOver4, graphicsService.GraphicsDevice.Viewport.AspectRatio, 0.1f, 100.0f); CameraNode = new CameraNode(new Camera(projection)) { Name = "CameraPerspective" }; Scene.Children.Add(CameraNode); }
/// <summary> /// Initializes a new instance of the <see cref="DebugGraphicsScreen" /> class. /// </summary> /// <param name="services">The services.</param> public DebugGraphicsScreen(IServiceLocator services) : base(services?.GetInstance <IGraphicsService>()) { if (services == null) { throw new ArgumentNullException(nameof(services)); } Coverage = GraphicsScreenCoverage.Partial; _spriteBatch = GraphicsService.GetSpriteBatch(); _whiteTexture = GraphicsService.GetDefaultTexture2DWhite(); var contentManager = services.GetInstance <ContentManager>(); var spriteFont = contentManager.Load <SpriteFont>("DigitalRune.Editor.Game/Fonts/DejaVuSans"); DebugRenderer = new DebugRenderer(GraphicsService, spriteFont); _internalDebugRenderer = new DebugRenderer(GraphicsService, spriteFont); // To count the update frame rate, we handle the GameLogicUpdating event. // (We cannot use GraphicsScreen.OnUpdate because it is only called at the same rate if // the graphics screen is registered in the graphics service. If it is not registered, // then OnUpdate and OnRender are always called together.) var editor = services.GetInstance <IEditorService>(); _gameExtension = editor.Extensions.OfType <GameExtension>().FirstOrDefault(); if (_gameExtension != null) { _gameExtension.GameLogicUpdating += OnGameLogicUpdating; } }
/// <summary> /// Draws an arc to visualize a rotation limit about an axis. /// </summary> /// <param name="debugRenderer">The debug renderer.</param> /// <param name="constraintToWorld"> /// A transformation that transforms from constraint anchor space to world space. /// </param> /// <param name="center">The center of the circle.</param> /// <param name="axis">The rotation axis.</param> /// <param name="direction">A direction vector (e.g. the direction of a bone).</param> /// <param name="minimum">The minimum angle.</param> /// <param name="maximum">The maximum angle.</param> /// <param name="scale">The scale.</param> /// <param name="color">The color.</param> /// <param name="drawOverScene"> /// If set to <see langword="true"/> the object is drawn over the graphics scene (depth-test /// disabled). /// </param> private static void DrawArc(this DebugRenderer debugRenderer, Pose constraintToWorld, Vector3 center, Vector3 axis, Vector3 direction, float minimum, float maximum, float scale, Color color, bool drawOverScene) { if (minimum == 0 && maximum == 0) { return; } // Line from circle center to start of arc. Vector3 previousArcPoint = center + scale * constraintToWorld.ToWorldDirection(Quaternion.CreateFromRotationMatrix(axis, minimum).Rotate(direction)); debugRenderer.DrawLine(center, previousArcPoint, color, drawOverScene); // Draw arc. int numberOfSegments = (int)Math.Max((maximum - minimum) / (ConstantsF.Pi / 24), 1); float segmentAngle = (maximum - minimum) / numberOfSegments; for (int i = 0; i < numberOfSegments; i++) { Vector3 arcPoint = center + scale * constraintToWorld.ToWorldDirection(Quaternion.CreateFromRotationMatrix(axis, minimum + (i + 1) * segmentAngle).Rotate(direction)); debugRenderer.DrawLine(previousArcPoint, arcPoint, color, drawOverScene); previousArcPoint = arcPoint; } // Line from end of arc to circle center. debugRenderer.DrawLine(previousArcPoint, center, color, drawOverScene); }
public BaseEntity(string name, PulsarScene scene, DebugRenderer debugRenderer, Vector3 position, Vector3 rotation, Vector3 scale) { _components = new List <PulsarComponent>(); _componentProperties = new List <PulsarComponent>(); _name = name; _scene = scene; _debugRenderer = debugRenderer; if (scene != null) { _node = scene.CreateChild(_name); if (_node != null) { _node.AddComponent(this); _pulsarActions = new PulsarActions(_node); } } SetPosition(position); SetRotation(rotation); SetScale(scale); CreateEntity(); ReceiveSceneUpdates = true; }
protected virtual void Dispose(bool disposing) { if (!IsDisposed) { if (disposing) { // Dispose managed resources. SpriteBatch.Dispose(); MeshRenderer.Dispose(); _decalRenderer.Dispose(); AlphaBlendSceneRenderer.Dispose(); _cloudMapRenderer.Dispose(); _waterWavesRenderer.Dispose(); _sceneCaptureRenderer.Dispose(); _planarReflectionRenderer.Dispose(); _shadowMapRenderer.Dispose(); _shadowMaskRenderer.Dispose(); LightBufferRenderer.Dispose(); _lensFlareRenderer.Dispose(); _skyRenderer.Dispose(); _fogRenderer.Dispose(); _internalDebugRenderer.Dispose(); Scene.Dispose(false); PostProcessors.Dispose(); DebugRenderer.Dispose(); } // Release unmanaged resources. IsDisposed = true; } }
public ClientWorld(MasterRenderer renderer) { Renderer = renderer; debugRenderer = Renderer.GetRenderer3D <DebugRenderer>(); entRenderer = Renderer.GetRenderer3D <EntityRenderer>(); }
public PostProcessingGraphicsScreen(IServiceLocator services) : base(services.GetInstance <IGraphicsService>()) { _sampleFramework = services.GetInstance <SampleFramework>(); _spriteBatch = new SpriteBatch(GraphicsService.GraphicsDevice); _clearGBufferRenderer = new ClearGBufferRenderer(GraphicsService); _rebuildZBufferRenderer = new RebuildZBufferRenderer(GraphicsService); _meshRenderer = new MeshRenderer(); _skyRenderer = new SkyRenderer(GraphicsService); _billboardRenderer = new BillboardRenderer(GraphicsService, 2048); Scene = new Scene(); PostProcessors = new PostProcessorChain(GraphicsService); // Use 2D texture for reticle. var contentManager = services.GetInstance <ContentManager>(); _reticle = contentManager.Load <Texture2D>("Reticle"); // Use the sprite font of the GUI. var uiContentManager = services.GetInstance <ContentManager>("UIContent"); var spriteFont = uiContentManager.Load <SpriteFont>("UI Themes/BlendBlue/Default"); DebugRenderer = new DebugRenderer(GraphicsService, spriteFont) { DefaultColor = new Color(0, 0, 0), DefaultTextPosition = new Vector2F(10), }; }
public static void Postfix() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Physics.Raycast(ray, out RaycastHit raycastHit, 150f, BuildingAligner.LayerMask); bool altIsDown = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt); if (altIsDown) { var game = GameManager.getInstance().getGameState() as GameStateGame; BuildingAligner.ActiveModule = game.GetActiveModule(); BuildingAligner.ActiveModuleSize = game.GetActiveModuleSizeIndex(); var newLocation = BuildingAligner.RenderAvailablePositions(raycastHit.point); BuildingAligner.ActiveModule.setPosition(newLocation); //TryAlign(ref raycastHit); } // Only run this if we just released a key and the other alt isn't also down if ((Input.GetKeyUp(KeyCode.LeftAlt) || Input.GetKeyUp(KeyCode.RightAlt)) && !altIsDown) { BuildingAligner.Rendering = false; BuildingAligner.LastInputPoint = Vector3.zero; DebugRenderer.ClearGroup(BuildingAligner.GroupName); } }
public BoxEntity(string name, PulsarScene scene, DebugRenderer debugRenderer, bool inDesign) { _name = name; _scene = scene; if (_scene != null) { _node = _scene.CreateChild(_name); if (_node != null) { _baseEntity = _node.CreateComponent <BaseEntity>(); _baseEntity.Name = name; _baseEntity.Node = _node; _baseEntity.PulsarScene = scene; _baseEntity.SetDebugRenderer(debugRenderer); InDesign = inDesign; _baseEntity.InDesign = inDesign; base.BaseEntity = _baseEntity; CreateEntity(); } } PulsarComponentClass = ComponentClass.Node; PulsarComponentType = ComponentType.NodeProperties; RegisterForMessages(); }
public Player(MasterRenderer renderer, World world, SimpleCamera camera, Vector3 position, Team team) : base(position, 11, 5, 2.5f) { this.masterRenderer = renderer; this.World = world; this.camera = camera; Team = team; if (!GlobalNetwork.IsServer) { debugRenderer = renderer.GetRenderer3D <DebugRenderer>(); entRenderer = renderer.GetRenderer3D <EntityRenderer>(); base.Renderer.VoxelObject = new DebugVOCube(world.GetTeamColor(team).ToColor4(), 1); flashlight = new Light(Vector3.Zero, LightType.Spot, 2, Color.White, new Vector3(1, 0, 0.002f)) { Radius = MathHelper.ToRadians(45), Visible = false }; renderer.Lights.Add(flashlight); } HitFeedbackPositions = new List <Vector3>(); Viewbob = GlobalNetwork.IsClient ? new ItemViewbob(this) : null; ItemManager = new ItemManager(renderer, this, world, Viewbob); }
public AvatarRagdollSample(Microsoft.Xna.Framework.Game game) : base(game) { // This sample uses for a DebugRenderer for the rendering rigid bodies. _debugRenderer = new DebugRenderer(GraphicsService, SpriteFont); // Add a custom game object which controls the camera. _cameraObject = new CameraObject(Services); _cameraObject.ResetPose(new Vector3F(0, 1, -3), ConstantsF.Pi, 0); GameObjectService.Objects.Add(_cameraObject); // Add some objects which allow the user to interact with the rigid bodies. _grabObject = new GrabObject(Services); _ballShooterObject = new BallShooterObject(Services) { Speed = 20 }; GameObjectService.Objects.Add(_grabObject); GameObjectService.Objects.Add(_ballShooterObject); // Add some default force effects. Simulation.ForceEffects.Add(new Gravity()); Simulation.ForceEffects.Add(new Damping()); // Add a ground plane in the simulation. Simulation.RigidBodies.Add(new RigidBody(new PlaneShape(Vector3F.UnitY, 0)) { MotionType = MotionType.Static }); // Create a random avatar. _avatarDescription = AvatarDescription.CreateRandom(); _avatarRenderer = new AvatarRenderer(_avatarDescription); }
public PyramidEntity(PulsarScene scene, PulsarApplication application, DebugRenderer debugRenderer) { _scene = scene; _application = application; _debugRenderer = debugRenderer; CreateEntity(); }
/// <summary> /// Visualizes the <see cref="AngularLimit"/> of a <see cref="BallJoint"/>. /// </summary> /// <param name="debugRenderer">The debug renderer.</param> /// <param name="joint">The joint.</param> /// <param name="limit">The limit.</param> /// <param name="scale"> /// A scale factor that determines the size of the drawn elements. /// </param> /// <param name="drawOverScene"> /// If set to <see langword="true"/> the object is drawn over the graphics scene (depth-test /// disabled). /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="debugRenderer" />, <paramref name="joint" />, or <paramref name="limit" /> /// is <see langword="null" />. /// </exception> public static void DrawAngularLimit(this DebugRenderer debugRenderer, BallJoint joint, AngularLimit limit, float scale, bool drawOverScene) { if (debugRenderer == null) { throw new ArgumentNullException("debugRenderer"); } if (joint == null) { throw new ArgumentNullException("joint"); } if (limit == null) { throw new ArgumentNullException("limit"); } Vector3 jointPosition = joint.BodyA.Pose.ToWorldPosition(joint.AnchorPositionALocal); // A transformation that converts from constraint anchor space to world space. Pose constraintToWorld = limit.BodyA.Pose * new Pose(limit.AnchorOrientationALocal); // Draw an arc for each rotation axis. DrawArc(debugRenderer, constraintToWorld, jointPosition, Vector3.UnitX, Vector3.UnitY, limit.Minimum.X, limit.Maximum.X, scale, Color.Red, drawOverScene); DrawArc(debugRenderer, constraintToWorld, jointPosition, Vector3.UnitY, Vector3.UnitX, limit.Minimum.Y, limit.Maximum.Y, scale, Color.Green, drawOverScene); DrawArc(debugRenderer, constraintToWorld, jointPosition, Vector3.UnitZ, Vector3.UnitX, limit.Minimum.Z, limit.Maximum.Z, scale, Color.Blue, drawOverScene); }
public void CreatePlane() { var planeNode = CreateChild("MainPlane"); planeNode.Scale = new Vector3(30, 1, 30); ScenePlane = planeNode.CreateComponent <StaticModel>(); ScenePlane.Model = MainApplication.ResourceCache.GetModel("Models/Plane.mdl"); ScenePlane.SetMaterial(MainApplication.ResourceCache.GetMaterial("Materials/StoneTiled.xml")); //give it a rigidbody RigidBody planeRigidBody = planeNode.CreateComponent <RigidBody>(); planeRigidBody.Mass = 0; //a mass of zero means it is a static entity planeRigidBody.UseGravity = false; //Make a collision box around the plane CollisionShape planeCollisionShape = planeNode.CreateComponent <CollisionShape>(); planeCollisionShape.Size = new Vector3(30, 1, 30); DebugRenderer renderer = GetComponent <DebugRenderer>(); if (renderer != null) { ScenePlane.DrawDebugGeometry(renderer, true); } }
//int snippetMain(int, const char*const*) public SampleHelloWorld(bool render = false) { //static const PxU32 frameCount = 100; //initPhysics(false); const uint frameCount = 100; initPhysics(false); //SharpPhysX Debug Renderer - no equivalent C++ line if (render) { DebugRenderer.InitFor(gScene, 100); } //for(PxU32 i=0; i<frameCount; i++) // stepPhysics(false); //cleanupPhysics(false); for (int i = 0; i < frameCount; i++) { stepPhysics(false); if (render) { DebugRenderer.Update(); //SharpPhysX Debug Renderer } } cleanupPhysics(false); }
public override void Initialize() { GUIFont = Game.Content.Load <SpriteFont>("font"); camera = new Camera2D(Game.GraphicsDevice.Viewport); camera.Stretch = new Vector2( Game.GraphicsDevice.Viewport.Width / targetResolution.X, Game.GraphicsDevice.Viewport.Height / targetResolution.Y ); gameRenderer = new GameRenderer(Game, gameScene, camera); animator = new Animator(Game, gameScene); phys = new PhysicsBasicEngine(Game, gameScene); gui = new GUILogic(Game, camera, _userInput); debugRenderer = new DebugRenderer(Game, gameScene, camera); debugRenderer.Visible = false; Game.Components.Add(phys); Game.Components.Add(animator); Game.Components.Add(gameRenderer); Game.Components.Add(gui); Game.Components.Add(debugRenderer); level.InitLevel(gameScene); createGameGui(); UnitSpawner.Scene = gameScene; CopyAI ai = new CopyAI(gameScene, level.player2Base); base.Initialize(); }
/// <inheritdoc/> protected override void OnRender(RenderContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } _numberOfDraws++; var graphicsDevice = GraphicsService.GraphicsDevice; context.CameraNode = CameraNode; DebugRenderer.Render(context); DrawTitleSafeArea(graphicsDevice); // Draw FPS text. _internalDebugRenderer.Clear(); _internalDebugRenderer.DrawText( _stringBuilder, new Vector2F((int)(context.Viewport.Width - _textWidth - 5), 0), Color.Yellow); _internalDebugRenderer.Render(context); context.CameraNode = null; }
void SubscribeToEvents() { SubscribeToEvent <PostRenderUpdateEvent>(e => { // If draw debug mode is enabled, draw viewport debug geometry, which will show eg. drawable bounding boxes and skeleton // bones. Note that debug geometry has to be separately requested each frame. Disable depth test so that we can see the // bones properly if (drawDebug) { GetSubsystem <Renderer>().DrawDebugGeometry(false); } if (currentPath.Count > 0) { // Visualize the current calculated path DebugRenderer debug = scene.GetComponent <DebugRenderer>(); debug.AddBoundingBox(new BoundingBox(endPos - new Vector3(0.1f, 0.1f, 0.1f), endPos + new Vector3(0.1f, 0.1f, 0.1f)), new Color(1.0f, 1.0f, 1.0f), true); // Draw the path with a small upward bias so that it does not clip into the surfaces Vector3 bias = new Vector3(0.0f, 0.05f, 0.0f); debug.AddLine(jackNode.Position + bias, currentPath[0] + bias, new Color(1.0f, 1.0f, 1.0f), true); if (currentPath.Count > 1) { for (int i = 0; i < currentPath.Count - 1; ++i) { debug.AddLine(currentPath[i] + bias, currentPath[i + 1] + bias, new Color(1.0f, 1.0f, 1.0f), true); } } } }); }
private void Render(RenderContext context) { context.CameraNode = _cameraObject.CameraNode; var graphicsDevice = context.GraphicsService.GraphicsDevice; graphicsDevice.Clear(Color.White); // Find all objects within camera frustum. var query = Scene.Query <CameraFrustumQuery>(_cameraObject.CameraNode, context); // Draw figure nodes. graphicsDevice.DepthStencilState = DepthStencilState.DepthRead; graphicsDevice.BlendState = BlendState.AlphaBlend; FigureRenderer.Render(query.SceneNodes, context, RenderOrder.BackToFront); UIScreen.Draw(context.DeltaTime); // Draw debug information. DebugRenderer.Render(context); context.CameraNode = null; }
public void SetDebugRenderer(DebugRenderer debugRenderer) { if (_baseEntity != null) { _baseEntity.SetDebugRenderer(debugRenderer); } }
public PulsarCamera(string name, PulsarScene scene, DebugRenderer debugRenderer) { //Debug.Print("PulsarCamera_Constructor - Creating camera - " + name); _name = name; _scene = scene; if (_scene != null) { _node = _scene.CreateChild(_name); //Debug.Print("PulsarCamera_Constructor - Created Node - " + name); if (_node != null) { _baseEntity = _node.CreateComponent <BaseEntity>(); //Debug.Print("PulsarCamera_Constructor - Created _baseEntity"); _baseEntity.Name = name; //Debug.Print("PulsarCamera_Constructor - Set baseEntity name to " + name); _baseEntity.Node = _node; //Debug.Print("PulsarCamera_Constructor - Set baseEntity Node"); _baseEntity.PulsarScene = scene; //Debug.Print("PulsarCamera_Constructor - Calling CreateEntity..."); CreateEntity(); //Debug.Print("PulsarCamera_Constructor - Setting debugRenderer"); _baseEntity.SetDebugRenderer(debugRenderer); base.BaseEntity = _baseEntity; _camera.DrawDebugGeometry(debugRenderer, false); //CreateEntity(); } } }
//int snippetMain(int, const char*const*) public SampleMultiThreading(bool render = false) { render_ = render; //initPhysics(); initPhysics(); //SharpPhysX Debug Renderer if (render_) { DebugRenderer.InitFor(gScene); } //for(PxU32 i=0; i<100; ++i) //stepPhysics(); for (uint i = 0; i < 100; ++i) { stepPhysics(); if (render_) { DebugRenderer.Update(); //SharpPhysX Debug Renderer } } //cleanupPhysics(); cleanupPhysics(); }
public SampleGraphicsScreen(IServiceLocator services) : base(services.GetInstance <IGraphicsService>()) { _sampleFramework = services.GetInstance <SampleFramework>(); Name = "SampleScreen"; ClearBackground = false; BackgroundColor = new Color(220, 220, 220); DrawReticle = false; UseFixedWidthFont = false; // Use 2D texture for reticle. var contentManager = services.GetInstance <ContentManager>(); _reticle = contentManager.Load <Texture2D>("Reticle"); // Get the sprite fonts used in the UI theme. var uiContentManager = services.GetInstance <ContentManager>("UIContent"); _defaultFont = uiContentManager.Load <SpriteFont>("UI Themes/BlendBlue/Default"); _fixedWidthFont = uiContentManager.Load <SpriteFont>("UI Themes/BlendBlue/Console"); // Set up 2D camera such that (0, 0) is upper, left corner of screen and // (screenWidth, screenHeight) is lower, right corner of screen. var graphicsDevice = GraphicsService.GraphicsDevice; int screenWidth = graphicsDevice.PresentationParameters.BackBufferWidth; int screenHeight = graphicsDevice.PresentationParameters.BackBufferHeight; var projection = new OrthographicProjection { Near = 0, Far = 2000, Left = 0, Right = screenWidth, Top = 0, Bottom = screenHeight, }; var camera = new Camera(projection); _cameraNode2D = new CameraNode(camera) { PoseWorld = new Pose(new Vector3F(0, 0, 1000)), }; // Initialize renderers. _spriteBatch = new SpriteBatch(graphicsDevice); _meshRenderer = new MeshRenderer(); _billboardRenderer = new BillboardRenderer(GraphicsService, 2048); DebugRenderer2D = new DebugRenderer(GraphicsService, _defaultFont) { SpriteFont = _defaultFont, DefaultColor = new Color(0, 0, 0), DefaultTextPosition = new Vector2F(10) }; DebugRenderer = new DebugRenderer(GraphicsService, _defaultFont) { SpriteFont = _defaultFont, DefaultColor = new Color(0, 0, 0), DefaultTextPosition = new Vector2F(10) }; Scene = new Scene(); }
/// <summary> /// Visualizes the <see cref="TwistSwingLimit"/> of a <see cref="BallJoint"/>. /// </summary> /// <param name="debugRenderer">The debug renderer.</param> /// <param name="joint">The joint.</param> /// <param name="limit">The limit.</param> /// <param name="scale"> /// A scale factor that determines the size of the drawn elements. /// </param> /// <param name="drawOverScene"> /// If set to <see langword="true"/> the object is drawn over the graphics scene (depth-test /// disabled). /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="debugRenderer" />, <paramref name="joint" />, or <paramref name="limit" /> /// is <see langword="null" />. /// </exception> public static void DrawTwistSwingLimit(this DebugRenderer debugRenderer, BallJoint joint, TwistSwingLimit limit, float scale, bool drawOverScene) { if (debugRenderer == null) { throw new ArgumentNullException("debugRenderer"); } if (joint == null) { throw new ArgumentNullException("joint"); } if (limit == null) { throw new ArgumentNullException("limit"); } // ----- Draw swing cone. // The tip of the swing cone: Vector3 coneTip = joint.BodyA.Pose.ToWorldPosition(joint.AnchorPositionALocal); // The first point on the swing cone: var previousConePoint = limit.GetPointOnCone(0, coneTip, scale); // Draw swing cone. const int numberOfSegments = 24; const float segmentAngle = ConstantsF.TwoPi / numberOfSegments; Color color = Color.Violet; for (int i = 0; i < numberOfSegments; i++) { var conePoint = limit.GetPointOnCone((i + 1) * segmentAngle, coneTip, scale); // Line from cone tip to cone base. debugRenderer.DrawLine(coneTip, conePoint, color, drawOverScene); // Line on the cone base. debugRenderer.DrawLine(previousConePoint, conePoint, color, drawOverScene); previousConePoint = conePoint; } // ----- Draw twist axis. // The x-axis is the twist direction. Vector3 twistAxis = Vector3.UnitX; // The twist axis relative to body B. Vector3 twistAxisDirectionBLocal = limit.AnchorOrientationBLocal * twistAxis; // The twist axis relative to world space. Vector3 twistAxisDirection = limit.BodyB.Pose.ToWorldDirection(twistAxisDirectionBLocal); // (A similar computation is used in DrawArc() below.) // Line in twist direction. debugRenderer.DrawLine(coneTip, coneTip + twistAxisDirection * scale, Color.Red, drawOverScene); // A transformation that converts from constraint anchor space to world space. Pose constraintToWorld = limit.BodyA.Pose * new Pose(limit.AnchorOrientationALocal); // Draw an arc that visualizes the twist limits. DrawArc(debugRenderer, constraintToWorld, coneTip, Vector3.UnitX, Vector3.UnitY, limit.Minimum.X, limit.Maximum.X, scale, Color.Red, drawOverScene); }
public EditorWorld(EditorScreen screen) { this.screen = screen; terrainPhys = new TerrainPhysicsExtension(); renderer = MasterRenderer.Instance; debugRenderer = renderer.GetRenderer3D <DebugRenderer>(); }
public override void Update(GameTime gameTime) { Scene.Update(gameTime.ElapsedGameTime); DebugRenderer.Clear(); base.Update(gameTime); }
void Start() { InitTexture(); inferencer.Init(PalmDetection, HandLandmark3D, UseGPU, PalmDetectionLerpFrameCount, HandLandmark3DLerpFrameCount); debugPlane = GameObject.Find("TensorFlowLite"); debugRenderer = debugPlane.GetComponent <DebugRenderer>(); debugRenderer.Init(inferencer.InputWidth, inferencer.InputHeight, debugPlane); }
public void Dispose() { _spriteBatch.Dispose(); _meshRenderer.Dispose(); _billboardRenderer.Dispose(); DebugRenderer2D.Dispose(); DebugRenderer.Dispose(); Scene.Dispose(false); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { m_cam.Target = Vector3.Zero; m_cam.Distance = CRUST_RADIUS * 2; m_DebugRenderComp = new DebugRenderer(this, m_cam, Content); base.Initialize(); }
public RenderModule(GraphicsDevice device, ContentManager content) { this.device = device; viewport = device.Viewport; debug = new DebugRenderer(device); drawEffect = content.Load<Effect>("draw"); Camera.Viewport = device.Viewport; drawIDEffect = content.Load<Effect>("id"); mousePickTarget = new RenderTarget2D(device, 1, 1, false, SurfaceFormat.Color, DepthFormat.Depth24); mousePickBlend.AlphaBlendFunction = BlendFunction.Add; mousePickBlend.AlphaDestinationBlend = Blend.Zero; mousePickBlend.AlphaSourceBlend = Blend.One; }
/// <summary> /// Initialize the game root /// </summary> public static void Initialize( GraphicsDevice graphics, ContentManager content ) { Enemies = new List<GameObject>(); Debug = new DebugRenderer( graphics, content ); mGraphicsDevice = graphics; Renderer = new Renderer( graphics ); Random = new Random(); }
private void DrawNewStuff() { // Draw stuff - it is fun! _debugRenderer = _scene.GetComponent<DebugRenderer>(); _debugRenderer.AddCircle(Vector3.Zero, new Vector3(1, 1, 1), 3.0f, Color.Cyan, 33, false); }
protected override void Initialize() { _serviceContainer = new ServiceContainer(); ServiceLocator.SetLocatorProvider(() => _serviceContainer); _serviceContainer.Register(typeof(Game), null, this); _serviceContainer.Register(typeof(ContentManager), null, Content); // Adds the input service, which manages device input, button presses etc. _inputManager = new InputManager(false); _serviceContainer.Register(typeof(IInputService), null, _inputManager); // Adds the UI service which manages UI screens _uiManager = new UIManager(this, _inputManager); _serviceContainer.Register(typeof(IUIService), null, _uiManager); _graphicsManager = new GraphicsManager(GraphicsDevice, Window, Content); Services.AddService(typeof(IGraphicsService), _graphicsManager); _serviceContainer.Register(typeof(IGraphicsService), null, _graphicsManager); _animationManager = new AnimationManager(); _serviceContainer.Register(typeof(IAnimationService), null, _animationManager); _gameObjectManager = new GameObjectManager(); _serviceContainer.Register(typeof(IGameObjectService), null, _gameObjectManager); _debugRenderer = new DebugRenderer(_graphicsManager, Content.Load<SpriteFont>("UI/MiramonteBold")); _serviceContainer.Register(typeof(DebugRenderer), null, _debugRenderer); _serviceContainer.Register(typeof(ContentManager), null, Content); _spriteBatch = new SpriteBatch(GraphicsDevice); _serviceContainer.Register(typeof(SpriteBatch), null, _spriteBatch); _gameLog = new GameLog(); _serviceContainer.Register(typeof(GameLog), null, _gameLog); _gameSettings = new GameSettings(); _serviceContainer.Register(typeof(GameSettings), null, _gameSettings); var uiTheme = Content.Load<Theme>("UI/UITheme"); UIRenderer renderer = new UIRenderer(this, uiTheme); var screen = new UIScreen("Default", renderer) { Background = new Color(0, 0, 0, 0), }; _uiManager.Screens.Add(screen); _mainGameComponent = new MainGameComponent(this); Components.Add(new StartScreenComponent(this)); Components.Add(new GamerServicesComponent(this)); //_updateAnimation = () => _animationManager.Update(_deltaTime); base.Initialize(); }