/// <summary> /// This will create a BasicModel and a PhysicsObject for each in game object. /// </summary> /// <param name="game"></param> /// <param name="pos"></param> /// <param name="mdlname"></param> /// <param name="texname"></param> /// <returns></returns> public GameObject createGameObject(Game game, Vector3 pos, string mdlname, string texname) { BasicModel bmodel = createBasicModel(mdlname, texname); PhysicsObject physobj = createPhysicsObject(pos, bmodel.model.Meshes[0].BoundingSphere); GameObject gobj = new GameObject(game, pos, bmodel, physobj); components.Add(gobj); return(gobj); }
/// <summary> /// Load the model and texture asset. Create a BasicModel using those assets and add /// it to ModelManager. The function also returns the BasicModel created. /// </summary> /// <param name="mdlname"></param> /// <param name="texname"></param> /// <returns></returns> public BasicModel createBasicModel(string mdlname, string texname) { Model mdl = content.Load<Model>(@"Models/" + mdlname); Texture2D tex = content.Load<Texture2D>(@"Textures/" + texname); BasicModel bmodel = new BasicModel(mdl, tex); modelmgr.addBasicModel(bmodel); return bmodel; }
/// <summary> /// Load the model and texture asset. Create a BasicModel using those assets and add /// it to ModelManager. The function also returns the BasicModel created. /// </summary> /// <param name="mdlname"></param> /// <param name="texname"></param> /// <returns></returns> public BasicModel createBasicModel(string mdlname, string texname) { Model mdl = content.Load <Model>(@"Models/" + mdlname); Texture2D tex = content.Load <Texture2D>(@"Textures/" + texname); BasicModel bmodel = new BasicModel(mdl, tex); modelmgr.addBasicModel(bmodel); return(bmodel); }
public GameObject(Game game, Vector3 pos, BasicModel mdl, PhysicsObject pobj) : base(game) { basicmodel = mdl; physobj = pobj; //Default values setPosition(pos); rotation = Quaternion.CreateFromYawPitchRoll(0, 0, 0); scale = 1f; world = Matrix.Identity; }
//Initialise game objects and create the level here. Need to more camera create to GameWorld and this function. public void loadLevel(Game game) { //Create static objects for (int i = 0; i < level.size; i++) { for (int j = 0; j < level.size; j++) { Vector3 pos = level.centerOfCell(i, j); pos.Y = groundHeight + 1; switch (level.map[i, j]) { //Player case 1: createPlayer(game, pos); break; //Enemy case 2: createEnemy(game, pos); break; //Obstacle case 3: createObstacle(game, pos); break; } } } BasicModel floor = createBasicModel("cube", "floor"); floor.scale *= Matrix.CreateScale(64, 1, 64); floor.translation = Matrix.CreateTranslation(32, -2.5f, 32); //Collision events between player and enemy physworld.addCollisionEvent(enemy.body.physobj, player.fist.physobj); physworld.addCollisionEvent(player.body.physobj, enemy.fist.physobj); }
public void addBasicModel(BasicModel mdl) { models.Add(mdl); }