예제 #1
0
// Constructor
BattleGround::BattleGround(void)
        : end(false)
{
    // Default settings
    //setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
    setAmbientLight(Ogre::ColourValue(1,1,1));
    // Create camera
    look_node = getManager().getRootSceneNode()->createChildSceneNode();
    cam_node = getManager().getRootSceneNode()->createChildSceneNode();
    useCamera(addCamera("BattleGround Camera", *cam_node, *look_node));

    // Ground
    addObject("cube", Ogre::Vector3(0,-5,0), Ogre::Vector3(10,1,1));
    addObject("cube", Ogre::Vector3(-23,7,0), Ogre::Vector3(3,0.5,1));
    addObject("cube", Ogre::Vector3(23,7,0), Ogre::Vector3(3,0.5,1));
    for (int i=0; i<5; i++)
        addObject("cube", Ogre::Vector3(0,5*i,0), Ogre::Vector3(0.6,0.6,0.6), 100);

    setStartingPosition(-10,10);
    setStartingPosition(10,10);

#if DEBUG_PHYSIC_SHAPES
    createDebugDrawer(getManager());
#endif

    bool hydrax = false, skyx = false;
    FtsEvaluator ev(ScriptManager::get().getL());
    ev.evalBool("Config.Hydrax", hydrax);
    ev.evalBool("Config.SkyX", skyx);

    if(hydrax)
        createWaterPlane();
    if(skyx)
        createSky();
}
예제 #2
0
void SingleplayerGame::createScene(std::vector<std::string> partyNames){
    auto scnMgr = mRenderer->mSceneManager;
    auto root = scnMgr->getRootSceneNode();
    Ogre::Camera* camera = mRenderer->mCamera;
    mRoomRoot = root->createChildSceneNode();
    scnMgr->setSkyBox(true, "Examples/MorningSkyBox", 5000, true);


    // Set ambient light
    scnMgr->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3));
    scnMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
 
    // Create a light
    mMainLight = scnMgr->createLight(BaseGame::mainLightName);
    mMainLight->setPosition(0, 500, 0);
    mMainLight->setType(Ogre::Light::LT_POINT);
    mMainLight->setDiffuseColour(.5, .5, .5);

    // Create ground plane
    ground = new Plane(scnMgr, mRoomRoot);

    // Add test objects
    Player* p = new Player(scnMgr, mRoomRoot,
            mPlayerBank->getPlayerInfo(partyNames[0]),
            Ogre::Vector3(500, 0, 200), mSoundBank);
    myParty.push_back(p);

    Player* p2 = new Player(scnMgr, mRoomRoot,
            mPlayerBank->getPlayerInfo(partyNames[1]),
            Ogre::Vector3(500, 0, 0), mSoundBank);
    myParty.push_back(p2);

    Player* p3 = new Player(scnMgr, mRoomRoot,
            mPlayerBank->getPlayerInfo(partyNames[2]),
            Ogre::Vector3(500, 0, -200), mSoundBank);
    myParty.push_back(p3);
    

    Player* p4 = new Player(scnMgr, mRoomRoot,
            mPlayerBank->getPlayerInfo("Mecha-Scoot"),
            Ogre::Vector3(-500, 0, 200), mSoundBank);
    enemyParty.push_back(p4);

    Player* p5 = new Player(scnMgr, mRoomRoot,
            mPlayerBank->getPlayerInfo("SSJVirginia"),
            Ogre::Vector3(-500, 0, 0), mSoundBank);
    enemyParty.push_back(p5);

    Player* p6 = new Player(scnMgr, mRoomRoot,
            mPlayerBank->getPlayerInfo("Metal Scoot"),
            Ogre::Vector3(-500, 0, -200), mSoundBank);
    enemyParty.push_back(p6);

    // Set Camera Position
    cameraInitialPosition = Ogre::Vector3(1100, 250, 700);
    cameraInitialLookAt = Ogre::Vector3(0, 0, 0);
    camera->setPosition(cameraInitialPosition);
    camera->lookAt(cameraInitialLookAt);
}
예제 #3
0
void Window::enableGlFeatures() {
  glEnable(GL_DEPTH_TEST);
  
  glDepthFunc(GL_LESS);
  glEnable(GL_CULL_FACE);
  glCullFace(GL_BACK);
  glShadeModel(GL_SMOOTH);
  setAmbientLight();
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glEnable(GL_BLEND);
}
예제 #4
0
void Window::enableGlFeatures(){
  glEnable(GL_TEXTURE_2D);
  glEnable(GL_DEPTH_TEST);
  glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
  glDepthFunc(GL_LESS);
  glEnable(GL_CULL_FACE);
  glCullFace(GL_BACK);
  setAmbientLight();
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glEnable(GL_BLEND);
  glEnable(GL_MULTISAMPLE_ARB);
}
예제 #5
0
// initialize initializes the general display design coordinator, creates the 
// primitive sets, textures, objects, lights, sounds, cameras, and text items
//
void Design::initialize() {

       // general display design
    //
   Reflectivity redish = Reflectivity(red);
   Reflectivity greenish = Reflectivity(green);
   Reflectivity bluish = Reflectivity(blue);
   Reflectivity whitish = Reflectivity(white);
   setProjection(0.9f, 1.0f, 1000.0f);
   setAmbientLight(1, 1, 1);
   // camera at a distance - in lhs coordinates
    // camera at a distance - in lhs coordinates
   iCamera* camera = CreateCamera();
   camera->translate(0, 190,-500);
   camera->setRadius(17.8f);
   
    lastUpdate = now;	

    hud = CreateHUD(0.72f, 0.01f, 0.27f, 0.99f, CreateTexture(HUD_IMAGE));
    // cameras ----------------------------------------------------------------

   velocitytxt_=CreateText(Rectf(0.05f,0.27f,0.95f,0.37f),hud,L"",TEXT_HEIGHT,TEXT_TYPEFACE,TEXT_LEFT);
   deltatxt_=CreateText(Rectf(0.05f,0.17f,0.95f,0.27f),hud,L"",TEXT_HEIGHT,TEXT_TYPEFACE,TEXT_LEFT);
   positiontxt_=CreateText(Rectf(0.05f,0.38f,0.95f,0.48f),hud,L"",TEXT_HEIGHT,TEXT_TYPEFACE,TEXT_LEFT);

   lasttextupdate=now;

   // game ----------------------------------------------------------------------
   setBackground(CreateTexture(L"farm.png"));
   catcher = CreatePhysicsBox(-40, -5, 0, 40, 5, 0, &bluish, 1, PHYS_Floating, true);
   iAPIWindow* win = getWindow();
   catcher->translate(0, -70, 0);

   truck = CreatePhysicsBox(-100, -2, 0, 100, 2, 0, &redish, 1, PHYS_Floating, true);
   truck->translate(300, -50, 0);

   Reflectivity yellowish = Reflectivity(yellow);

   iPhysics* fallingBox = CreatePhysicsBox(-10, -10, -10, 10, 10, 10, &yellowish, 1, PHYS_Falling, true);
   fallingBox->translate(-350, 350, 0);
   fallingBox->setVelocity(Vector(5, 20, 0));
   fallingBox->addBodyForce(Vector(0, -10, 0));
   fallingBox->setCollision(CreateCSphere(fallingBox, 5));
   objects.insert(objects.end(), fallingBox);

   wchar_t str[MAX_DESC + 1];
   StringCbPrintfW(str, MAX_DESC, L"Score: 0");
   velocitytxt_->set(str);

   StringCbPrintfW(str, MAX_DESC, L"Life left: 5"); 
   deltatxt_->set(str);
}
예제 #6
0
// initialize initializes the general display design coordinator, creates the 
// primitive sets, textures, objects, lights, sounds, cameras, and text items
//
void Design::initialize() {

    // general parameters
    //
	Reflectivity redish = Reflectivity(red);
	Reflectivity greenish = Reflectivity(green);
	Reflectivity bluish = Reflectivity(blue);
	Reflectivity whitish = Reflectivity(white);
	iGraphic* box;
    setProjection(0.9f, 1.0f, 1000.0f);
    setAmbientLight(0.9f, 0.9f, 0.9f);

    iCamera* camera = CreateCamera();
    camera->translate(0,150,0);
    camera->setRadius(17.8f);
	camera->rotatex(3.1459/2.0f);



    int i=0;
    for(i=0;i<map_.numvert();i++){
		 box   = CreateBox(-3, -3, -3 * MODEL_Z_AXIS,  3, 3, 3 * MODEL_Z_AXIS);
		CreateObject(box,&redish)->translate(map_.vx(i),map_.vy(i),map_.vz(i));
    }
    for(int j=0;j<map_.numvert();j++){
      LList<EdgeInfo>& edgelist=map_.edges(j);
      Node<EdgeInfo>* curr;
      while(curr=edgelist.curr()){
        int from=curr->data().from();
        int to=curr->data().to();
        if(from < to){
          Vector frompos=map_.pos(from);
          Vector topos=map_.pos(to);
		  float speed= curr->data().speed();
		  iGraphic* path=CreatePath(frompos.x,frompos.y,frompos.z,topos.x,topos.y,topos.z);
		  Reflectivity* pathcolour=(speed<FAST)?((speed<MEDIUM)?&redish:&bluish):&greenish;
		  CreateObject(path,pathcolour);
          #if DEBUG==1
          fprintf(debugfile,"from/to: %d %d\n",from,to);          
          fprintf(debugfile,"frompos %f %f %f\n",frompos.x,frompos.y,frompos.z);
          fprintf(debugfile,"topos %f %f %f\n",topos.x,topos.y,topos.z);
          fprintf(debugfile,"v %f %f %f\n",v.x,v.y,v.z);
          fprintf(debugfile,"edglen= %f\n",edgelen);
          #endif
		  i++;
        }
        edgelist.gonext();
      }
    }
	bucket_=CreatePhysicsBox(-2,-2,-2,2,2,2,&bluish,1,PHYS_FixedInSpace);
    whichbox_=0;
    Vector boxloc=map_.pos(whichbox_);
    bucket_->translate(boxloc.x,boxloc.y+4,boxloc.z);
	box = CreateBox(-3.1, -3.1, -3.1 * MODEL_Z_AXIS,  3.1, 3.1, 3.1 * MODEL_Z_AXIS);
	(highlighter_ = CreateObject(box,&greenish))->translate(map_.vx(0),map_.vy(0),map_.vz(0));
	selectloc_=0;
	lastFireTime_=0;
	ismoving_=false;
	searchroutine_=GREEDY;


	hud = CreateHUD(0.72f, 0.01f, 0.27f, 0.99f, CreateTexture(HUD_IMAGE));


	velocitytxt_=CreateText(Rectf(0.05f,0.27f,0.95f,0.37f),hud,L"",TEXT_HEIGHT,TEXT_TYPEFACE,TEXT_LEFT);
	deltatxt_=CreateText(Rectf(0.05f,0.17f,0.95f,0.27f),hud,L"",TEXT_HEIGHT,TEXT_TYPEFACE,TEXT_LEFT);
	positiontxt_=CreateText(Rectf(0.05f,0.38f,0.95f,0.48f),hud,L"",TEXT_HEIGHT,TEXT_TYPEFACE,TEXT_LEFT);


	lasttextupdate=now;
	
}