private void resetRound(int side) { court.reset_point_scored(); ground_marker_node.RemoveChild(vball.getTransformNode()); vball = new VolleyBall(1f, GROUND_MARKER_SIZE / 2f, bounceSound, false); // Perform initial manipulations if (side == 0) { vball.translate(PLAYER_BALL_START); } else { vball.translate(OPPONENT_BALL_START); } ball_drop_delay = true; ball_drop_countdown = 0; }
protected override void Draw(GameTime gameTime) { // Set the render target for rendering the AR scene scene.SceneRenderTarget = arViewRenderTarget; // Set the scene background size to be the size of the AR scene viewport scene.BackgroundBound = arViewRect; // Set the camera to be the AR camera scene.CameraNode = arCameraNode; // Associate the overlaid model with the ground marker for rendering it in AR scene scene.RootNode.RemoveChild(overlayNode.Parent); groundMarkerNode.AddChild(overlayNode.Parent); // Don't render the marker board and camera representation markerBoardGeom.Enabled = false; vrCameraRepNode.Enabled = false; // Show the video background scene.ShowCameraImage = true; // Render the AR scene scene.Draw(gameTime.ElapsedGameTime, gameTime.IsRunningSlowly); // Set the render target for rendering the VR scene scene.SceneRenderTarget = vrViewRenderTarget; // Set the scene background size to be the size of the VR scene viewport scene.BackgroundBound = vrViewRect; // Set the camera to be the VR camera scene.CameraNode = vrCameraNode; // Remove the overlaid model from the ground marker for rendering it in VR scene groundMarkerNode.RemoveChild(overlayNode.Parent); scene.RootNode.AddChild(overlayNode.Parent); // Render the marker board and camera representation in VR scene markerBoardGeom.Enabled = true; vrCameraRepNode.Enabled = true; // Update the transformation of the camera representation in VR scene based on the // marker array transformation if (groundMarkerNode.MarkerFound) { vrCameraRepTransNode.WorldTransformation = Matrix.Invert(groundMarkerNode.WorldTransformation); } // Do not show the video background scene.ShowCameraImage = false; // Re-traverse the scene graph since we have modified it, and render the VR scene scene.RenderScene(false, true); // Set the render target back to the frame buffer State.Device.SetRenderTarget(null); // Render the two textures rendered on the render targets State.SharedSpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque); State.SharedSpriteBatch.Draw(arViewRenderTarget, arViewRect, Color.White); State.SharedSpriteBatch.Draw(vrViewRenderTarget, vrViewRect, Color.White); State.SharedSpriteBatch.End(); }
public void Draw(TimeSpan elapsedTime) { // Reset the XNA viewport to our centered and resized viewport State.Device.Viewport = viewport; // Set the render target for rendering the AR scene scene.SceneRenderTarget = arViewRenderTarget; scene.BackgroundColor = Color.Black; // Set the scene background size to be the size of the AR scene viewport scene.BackgroundBound = arViewRect; // Set the camera to be the AR camera scene.CameraNode = arCameraNode; // Associate the overlaid model with the ground marker for rendering it in AR scene scene.RootNode.RemoveChild(overlayRoot); groundMarkerNode.AddChild(overlayRoot); // Don't render the marker board and camera representation markerBoardGeom.Enabled = false; vrCameraRepNode.Enabled = false; // Show the video background scene.BackgroundTexture = videoTexture; // Render the AR scene scene.Draw(elapsedTime, false); // Set the render target for rendering the VR scene scene.SceneRenderTarget = vrViewRenderTarget; scene.BackgroundColor = Color.CornflowerBlue; // Set the scene background size to be the size of the VR scene viewport scene.BackgroundBound = vrViewRect; // Set the camera to be the VR camera scene.CameraNode = vrCameraNode; // Remove the overlaid model from the ground marker for rendering it in VR scene groundMarkerNode.RemoveChild(overlayRoot); scene.RootNode.AddChild(overlayRoot); // Render the marker board and camera representation in VR scene markerBoardGeom.Enabled = true; vrCameraRepNode.Enabled = true; // Update the transformation of the camera representation in VR scene based on the // marker array transformation if (groundMarkerNode.MarkerFound) { vrCameraRepTransNode.WorldTransformation = Matrix.Invert(groundMarkerNode.WorldTransformation); } // Do not show the video background scene.BackgroundTexture = null; // Re-traverse the scene graph since we have modified it, and render the VR scene scene.RenderScene(false, true); // Adjust the viewport to be centered arViewRect.X += viewport.X; vrViewRect.X += viewport.X; // Set the render target back to the frame buffer State.Device.SetRenderTarget(null); State.Device.Clear(Color.Black); // Render the two textures rendered on the render targets State.SharedSpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque); State.SharedSpriteBatch.Draw(arViewRenderTarget, arViewRect, Color.White); State.SharedSpriteBatch.Draw(vrViewRenderTarget, vrViewRect, Color.White); State.SharedSpriteBatch.End(); // Reset the adjustments arViewRect.X -= viewport.X; vrViewRect.X -= viewport.X; }