Exemple #1
0
 /// <summary>
 /// Initialize a Surface3D object.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="actor">The parent actor.</param>
 /// <param name="effectFileName">The effect file name.</param>
 public Surface(XiGame game, Actor3D actor, string effectFileName)
 {
     XiHelper.ArgumentNullCheck(game);
     this.game = game;
     this.actor = actor;
     EffectFileName = effectFileName;
 }
Exemple #2
0
 /// <summary>
 /// Create an Overlayer.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="overlayFileName">The initial overlay file nane.</param>
 public Overlayer(XiGame game, string overlayFileName)
 {
     XiHelper.ArgumentNullCheck(game, overlayFileName);
     this.game = game;
     this.overlayFileName = overlayFileName;
     SetUpDocument();
 }
Exemple #3
0
 /// <summary>
 /// Create an Overlayable object.
 /// </summary>
 /// <param name="game">The game.</param>
 public Overlayable(XiGame game)
 {
     XiHelper.ArgumentNullCheck(game);
     this.game = game;
     this.overlayName = GetType().FullName;
     game.Overlayer.AddOverlayable(this);
 }
Exemple #4
0
 public Dragger(XiGame game, double dragBeginDelay)
 {
     XiHelper.ArgumentNullCheck(game);
     if (dragBeginDelay < 0) throw new ArgumentException("Drag begin delay should be positive.");
     this.game = game;
     this.dragBeginDelay = dragBeginDelay;
 }
 /// <summary>
 /// Create box model physics.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="model">The visual model.</param>
 /// <param name="position">The position of the box entity.</param>
 /// <param name="mass">The physics mass.</param>
 public BoxModelPhysics(XiGame game, Model model, Vector3 position, float mass)
 {
     this.game = game;
     Vector3[] vertices;
     int[] indices;
     model.GetVerticesAndIndices(out vertices, out indices);
     BoundingBox boundingBox = BoundingBox.CreateFromPoints(vertices);
     body = new BEPUphysics.Entities.Box(
         position,
         Math.Max(Math.Abs(boundingBox.Max.X), Math.Abs(boundingBox.Min.X)) * 2,
         Math.Max(Math.Abs(boundingBox.Max.Y), Math.Abs(boundingBox.Min.Y)) * 2,
         Math.Max(Math.Abs(boundingBox.Max.Z), Math.Abs(boundingBox.Min.Z)) * 2,
         mass);
     /*
     this alternative method does not work and I don't know why -
     Box box = new Box(
         (boundingBox.Max + boundingBox.Min) * 0.5f,
         boundingBox.Max.X - boundingBox.Min.X,
         boundingBox.Max.Y - boundingBox.Min.Y,
         boundingBox.Max.Z - boundingBox.Min.Z,
         Mass);
     body = new CompoundBody();
     body.addBody(box);
     */
 }
Exemple #6
0
 /// <summary>
 /// Create a DirectionalShadow.
 /// </summary>
 public DirectionalShadow(XiGame game, OrthoCamera shadowCamera)
 {
     XiHelper.ArgumentNullCheck(game, shadowCamera);
     this.game = game;
     this.shadowCamera = shadowCamera;
     shadowMapTarget = new ManagedRenderTarget2D(game, Constants.DirectionalShadowMapSurfaceToScreenRatio, 1, SurfaceFormat.Single, MultiSampleType.None, 0, 0);
     screenQuad = ScreenQuadGeometry.Create<VerticesPositionNormalTexture>(game.GraphicsDevice);
 }
Exemple #7
0
 public EditorController(XiGame game)
 {
     XiHelper.ArgumentNullCheck(game);
     this.game = game;
     actors = CreateActors(game);
     SetUpContexts();
     ResetSettings();
 }
 /// <summary>
 /// Create sphere model physics.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="model">The visual model.</param>
 /// <param name="position">The position of the static mesh entity.</param>
 /// <param name="mass">The physics mass.</param>
 public StaticMeshModelPhysics(XiGame game, Model model, Vector3 position, float mass)
 {
     this.game = game;
     StaticTriangleGroup.StaticTriangleGroupVertex[] vertices;
     int[] indices;
     model.GetVerticesAndIndices(out vertices, out indices);
     TriangleMesh triangleMesh = new TriangleMesh(vertices, indices);
     staticTriangleGroup = new StaticTriangleGroup(triangleMesh);
 }
 /// <summary>
 /// Create sphere model physics.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="model">The visual model.</param>
 /// <param name="position">The position of the sphere entity.</param>
 /// <param name="mass">The physics mass.</param>
 public SphereModelPhysics(XiGame game, Model model, Vector3 position, float mass)
 {
     this.game = game;
     Vector3[] vertices;
     int[] indices;
     model.GetVerticesAndIndices(out vertices, out indices);
     BoundingSphere boundingSphere = BoundingSphere.CreateFromPoints(vertices);
     body = new Sphere(position, boundingSphere.Radius, mass);
 }
Exemple #10
0
 /// <summary>
 /// Create a PhysicsBoxDrawer.
 /// </summary>
 /// <param name="game">The game.</param>
 public PhysicsBoxDrawer(XiGame game)
 {
     XiHelper.ArgumentNullCheck(game);
     this.game = game;
     linesEffect = new BasicEffect(game.GraphicsDevice, null);
     linesEffect.LightingEnabled = false;
     linesEffect.VertexColorEnabled = true;
     linesVertexDeclaration = new VertexDeclaration(game.GraphicsDevice, VertexPositionColor.VertexElements);
 }
Exemple #11
0
 public EditorTreeViewWrapper(XiGame game, EditorController controller, TreeView treeView)
 {
     XiHelper.ArgumentNullCheck(game, controller, treeView);
     this.controller = controller;
     this.treeView = treeView;
     game.SimulationStructureChanged += game_SimulationStructureChanged;
     game.SimulationSelectionChanged += game_SimulationSelectionChanged;
     treeView.MouseDown += treeView_MouseDown;
     treeView.AfterSelect += treeView_AfterSelect;
 }
Exemple #12
0
 /// <summary>
 /// Create capsule model physics.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="model">The visual model.</param>
 /// <param name="position">The position of the sphere entity.</param>
 /// <param name="mass">The physics mass.</param>
 public CapsuleModelPhysics(XiGame game, Model model, Vector3 position, float mass)
 {
     this.game = game;
     Vector3[] vertices;
     int[] indices;
     model.GetVerticesAndIndices(out vertices, out indices);
     BoundingSphere boundingSphere = BoundingSphere.CreateFromPoints(vertices);
     body = new Capsule(position, boundingSphere.Radius, boundingSphere.Radius * 0.5f, mass);
     game.SceneSpace.Add(body);
 }
Exemple #13
0
 public EditorForm(XiGame game)
 {
     InitializeComponent();
     XiHelper.ArgumentNullCheck(game);
     this.game = game;
     wrapper = new EditorFormWrapper(game, this);
     wrapper.ConfigureSettings();
     buttonLimitFPS.Checked = game.IsFixedTimeStep;
     buttonPhysics.Checked = game.PhysicsEnabled;
 }
 /// <summary>
 /// Create a ManagedDepthStencilBuffer.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="surfaceToScreenRatio">The surface to screen ratio.</param>
 /// <param name="format">The format of the stencil buffer.</param>
 /// <param name="msType">The multi-sampling type of the texture produced by the render target.</param>
 /// <param name="msQuality">The multi-sampling quality of the texture produced by the render target.</param>
 public ManagedDepthStencilBuffer(XiGame game, float surfaceToScreenRatio,
     DepthFormat format, MultiSampleType msType, int msQuality)
 {
     XiHelper.ArgumentNullCheck(game);
     this.game = game;
     this.format = format;
     this.msType = msType;
     this.msQuality = msQuality;
     game.GraphicsDevice.DeviceReset += device_DeviceReset;
     SurfaceToScreenRatio = surfaceToScreenRatio;
 }
Exemple #15
0
        /// <summary>
        /// Create terrain physics.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <param name="terrain">The visual terrain.</param>
        public TerrainPhysics(XiGame game, Terrain terrain)
        {
            this.game = game;
            
            HeightMap heightMap = terrain.HeightMap;
            int width = heightMap.GetLength(0);
            int depth = heightMap.GetLength(1);
            Vector3 quadScale = heightMap.QuadScale;
            float[,] points = new float[width, depth];
            for (int x = 0; x < width; ++x)
                for (int z = 0; z < depth; ++z)
                    points[x, z] = heightMap.Points[x, z] * quadScale.Y;

            body = new BEPUphysics.Terrain(new Vector3(heightMap.Offset.X, 0.0f, heightMap.Offset.Y));
            body.SetData(points, QuadFormats.UpperLeftLowerRight, quadScale.X, quadScale.Z);
            body.AllowedPenetration = 1.0f;
            game.SceneSpace.Add(body);
        }
Exemple #16
0
 /// <summary>
 /// Create a ManagedRenderTarget2D.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="surfaceToScreenRatio">The surface to screen ratio.</param>
 /// <param name="levelCount">The number of mip-map levels of the texture produced by the render target.</param>
 /// <param name="format">The format of the render target.</param>
 /// <param name="msType">The multi-sampling type of the texture produced by the render target.</param>
 /// <param name="msQuality">The multi-sampling quality of the texture produced by the render target.</param>
 /// <param name="renderTargetIndex">The render target index.</param>
 public ManagedRenderTarget2D(
     XiGame game,
     float surfaceToScreenRatio,
     int levelCount,
     SurfaceFormat format,
     MultiSampleType msType,
     int msQuality,
     int renderTargetIndex)
 {
     XiHelper.ArgumentNullCheck(game);
     this.game = game;
     this.levelCount = levelCount;
     this.format = format;
     this.msType = msType;
     this.msQuality = msQuality;
     this.renderTargetIndex = renderTargetIndex;
     game.GraphicsDevice.DeviceReset += new EventHandler(device_DeviceReset);
     SurfaceToScreenRatio = surfaceToScreenRatio;
 }
Exemple #17
0
 /// <summary>
 /// Create a Simulatable object.
 /// </summary>
 /// <param name="game">The game.</param>
 public Simulatable(XiGame game) : base(game) { }
Exemple #18
0
 public CameraContext(XiGame game, EditorController controller) : base(game, controller)
 {
     cameraDragger = new CameraDragger(game, controller);
 }
Exemple #19
0
 /// <summary>
 /// Create an Actor3D.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="physicsEnabled">Is the actor's physics enabled?</param>
 public Actor3D(XiGame game, bool physicsEnabled) : base(game)
 {
     _physicsEnabled = physicsEnabled; // circumvent property to avoid virtual call
     SetUpEntity();
     game.Scene.AddActor(this);
 }
Exemple #20
0
 /// <summary>
 /// Create a NullDirectionalShadow.
 /// </summary>
 /// <param name="game">The game.</param>
 public NullDirectionalShadow(XiGame game)
 {
     camera = new OrthoCamera(game.GraphicsDevice);
 }
Exemple #21
0
 /// <summary>
 /// Create a Light3D object.
 /// </summary>
 /// <param name="game">The game.</param>
 public Light(XiGame game) : base(game, false) { }
Exemple #22
0
 /// <summary>
 /// Create an AmbientLight3D object.
 /// </summary>
 /// <param name="game">The game.</param>
 public AmbientLight(XiGame game) : base(game) { }
Exemple #23
0
 private static ActorGroup CreateActors(XiGame game)
 {
     ActorGroup actors = new ActorGroup(game);
     actors.RefreshOverlaidProperties();
     return actors;
 }
Exemple #24
0
 /// <summary>
 /// Create a NormalMappedSurface.
 /// </summary>
 public NormalMappedSurface(XiGame game, NormalMappedModel actor, string effectFileName, int meshIndex, int partIndex)
     : base(game, actor, effectFileName, meshIndex, partIndex)
 {
     NormalMapFileName = "Xi/3D/waves";
 }
Exemple #25
0
 /// <summary>
 /// Create a Label.
 /// </summary>
 /// <param name="game">The game.</param>
 public Label(XiGame game) : base(game) { }
Exemple #26
0
 /// <summary>
 /// Create an Actor3D.
 /// </summary>
 /// <param name="game">The game.</param>
 public Actor3D(XiGame game) : base(game)
 {
     SetUpEntity();
     game.Scene.AddActor(this);
 }
Exemple #27
0
 /// <summary>
 /// Create an XmlDocumentCache.
 /// </summary>
 /// <param name="game">The game.</param>
 public XmlDocumentCache(XiGame game)
 {
     this.game = game;
 }
Exemple #28
0
 /// <summary>
 /// Create an Actor2D.
 /// </summary>
 /// <param name="game">The game.</param>
 public Actor2D(XiGame game) : base(game)
 {
     SetUpFixture();
 }
Exemple #29
0
 /// <summary>
 /// Create a Recyclable object.
 /// </summary>
 /// <param name="game">The game.</param>
 public Recyclable(XiGame game) : base(game) { }
Exemple #30
0
 /// <summary>
 /// Create a PointLight3D object.
 /// </summary>
 /// <param name="game">The game.</param>
 public PointLight(XiGame game) : base(game) { }