public Sphere(Model sphere,LabGame game) { this.game = game; model = sphere; basicEffect = new BasicEffect(game.GraphicsDevice) { View = game.camera.View, Projection = game.camera.Projection, World = Matrix.Identity, //Texture = myModel.Texture, TextureEnabled = true, VertexColorEnabled = false }; BasicEffect.EnableDefaultLighting(model,true); const float MaxModelSize = 10.0f; //var scaling = MaxModelSize / modelBounds.Radius; //var scaling = MaxModelSize / model.Meshes[0].BoundingSphere.Radius; modelBounds = model.CalculateBounds(); view = Matrix.LookAtRH(new Vector3(0, 0, MaxModelSize * 2.5f), new Vector3(0, 0, 0), Vector3.UnitY); projection = Matrix.PerspectiveFovRH(0.9f, (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.1f, MaxModelSize * 10.0f); world = Matrix.Translation(-modelBounds.Center.X, -modelBounds.Center.Y, -modelBounds.Center.Z)*Matrix.Scaling(1); basicEffect.View = game.camera.View; basicEffect.Projection = game.camera.Projection; //modelBounds = model.CalculateBounds(); //pos = model.BoundingSphere.Center; // pos = new Vector3(-model.BoundingSphere.Center.X,-model.BoundingSphere.Center.Y,-model.BoundingSphere.Center.Z); pos = new Vector3(0, 0, 0); //basicEffect.World = Matrix.Translation(pos);// * Matrix.Scaling(1f); //effect = game.Content.Load<Effect>("Phong"); radius = model.Meshes[0].BoundingSphere.Radius; frictionConstant = 0.4f; }
public ShipModel(VisionContent vContent) : base(vContent.LoadEffect("effects/SimpleTextureEffect")) { _model = vContent.Load<Model>(@"Models/galleonmodel"); _texture = vContent.Load<Texture2D>(@"Models/galleon"); _boundingSphere = _model.CalculateBounds(); }
public ModelGameObject(Project2Game game, Model model, Vector3 position, Vector3 orientation, Vector3 scale) : base(game, position, orientation, scale) { this.model = model; if (model != null) { boundingSphere = model.CalculateBounds(WorldMatrix); } }
public Sphere(Model sphere,LabGame game) { this.game = game; model = sphere; basicEffect = new BasicEffect(game.GraphicsDevice) { View = game.camera.View, //View = Matrix.LookAtRH(game.camera.pos, game.camera.pos+game.camera.pos_relative_to_player, Vector3.UnitY), Projection = game.camera.Projection, //Projection = Matrix.PerspectiveFovRH((float)Math.PI / 4.0f, (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.01f, 15000.0f), World = Matrix.Identity, //Texture = myModel.Texture, TextureEnabled = true, VertexColorEnabled = false }; BasicEffect.EnableDefaultLighting(model,true); //const float MaxModelSize = 10.0f; //var scaling = MaxModelSize / modelBounds.Radius; //var scaling = MaxModelSize / model.Meshes[0].BoundingSphere.Radius; //modelBounds = model.CalculateBounds(); //view = Matrix.LookAtRH(new Vector3(0, 0, MaxModelSize * 2.5f), new Vector3(0, 0, 0), Vector3.UnitY); //projection = Matrix.PerspectiveFovRH(0.9f, (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.1f, MaxModelSize * 10.0f); //world = Matrix.Translation(-modelBounds.Center.X, -modelBounds.Center.Y, -modelBounds.Center.Z) * Matrix.Scaling(0.5f); //basicEffect.View = game.camera.View; //basicEffect.Projection = game.camera.Projection; //modelBounds = model.CalculateBounds(); //pos = model.BoundingSphere.Center; // pos = new Vector3(-model.BoundingSphere.Center.X,-model.BoundingSphere.Center.Y,-model.BoundingSphere.Center.Z); //pos = new Vector3(game.mazeLandscape.maze.startPoint.x, 3, game.mazeLandscape.maze.startPoint.y); pos = new Vector3(game.mazeLandscape.entranceX, 0, game.mazeLandscape.entranceZ); radius = model.CalculateBounds().Radius * scallingFactor + 0.6f; basicEffect.World = Matrix.Translation(new Vector3(model.CalculateBounds().Center.X, model.CalculateBounds().Center.Y, model.CalculateBounds().Center.Z)) * Matrix.Translation(pos);// * Matrix.Scaling(1f); effect = game.Content.Load<Effect>("modelShader"); texture = game.Content.Load<Texture2D>("wood"); //radius = model.Meshes[0].BoundingSphere.Radius * scallingFactor; frictionConstant = 0.03f; }
// Constructor. public Projectile(LabGame game, Model model, Vector3 pos, Vector3 vel, GameObjectType targetType) { this.game = game; this.model = model; this.pos = pos; this.vel = vel; this.type = GameObjectType.Projectile; this.targetType = targetType; squareHitRadius = hitRadius * hitRadius; BoundingSphere modelBounds = model.CalculateBounds(); scaling = size / modelBounds.Radius; originalWorld = Matrix.Translation(-modelBounds.Center.X, -modelBounds.Center.Y, -modelBounds.Center.Z) * Matrix.Scaling(scaling); //GetParamsFromModel(); basicEffect = new BasicEffect(game.GraphicsDevice) { View = game.camera.View, Projection = game.camera.Projection, //World = Matrix.Identity World = originalWorld }; }