Пример #1
0
void Game::loadTerrain(){
  ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
    "resources/other/heightmap.png",
    0,                  // parent node
    -1,                 // node id
    core::vector3df(0.f, 0.f, 0.f),     // position
    core::vector3df(0.f, 0.f, 0.f),     // rotation
    core::vector3df(40.f, 4.4f, 40.f),  // scale
    video::SColor ( 255, 255, 255, 255 ),   // vertexColor
    5,                  // maxLOD
    scene::ETPS_17,             // patchSize
    4                   // smoothFactor
    );
    terrain->setMaterialFlag(video::EMF_LIGHTING, false);
    terrain->setMaterialTexture(0, driver->getTexture("resources/other/heightmap_texture.png"));
    terrain->setPosition(vector3df(0, 0, 0));
    ITriangleSelector* selector = smgr->createTerrainTriangleSelector(terrain, 0);
    terrain->setTriangleSelector(selector);
    scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
    selector, camera, core::vector3df(10,10,10),
    core::vector3df(0,-9,0),
    core::vector3df(0,50,0));
    camera->addAnimator(anim);
    scene::ISceneNode* skybox=smgr->addSkyBoxSceneNode(
    driver->getTexture("resources/textures/skybox/coulee_up.jpg"),
    driver->getTexture("resources/textures/skybox/coulee_dn.jpg"),
    driver->getTexture("resources/textures/skybox/coulee_rt.jpg"),
    driver->getTexture("resources/textures/skybox/coulee_lf.jpg"),
    driver->getTexture("resources/textures/skybox/coulee_ft.jpg"),
    driver->getTexture("resources/textures/skybox/coulee_bk.jpg"));
}
Пример #2
0
bool MapObject::createGround(posi_t const& size)
{
    _mapSize = size;
    
    std::string const& heightmap = _assets->getFileName(MAP, HEIGHT_MAP, 0);
    ITerrainSceneNode* node = _smgr->addTerrainSceneNode(heightmap.c_str(), getParentNode(), NODE_ID_MAP);
    _node = node;
    if (!_node)//throw exception ?
	return false;
    
    scaleOnCase();
    updateNodePosition();
    
    _node->setMaterialFlag(EMF_LIGHTING, true);
    ////    _node->setMaterialFlag(EMF_FOG_ENABLE, true);
    ////    _node->setMaterialType(video::EMT_DETAIL_MAP);
    _node->setMaterialTexture(0, _assets->getTexture(MAP, TEXTURE, 0));
    //    vector3df caseSize = _helper->getCaseSize();
    //    posf_t  scaleTexture((float)x * caseSize.X, (float)y * caseSize.Z);
    //    _node->getMaterial(0).getTextureMatrix(0).setTextureScale(scaleTexture.first,scaleTexture.second);
    _node->getMaterial(0).getTextureMatrix(0).setTextureScale(_mapSize.first*2, _mapSize.second*2); //TODO : rendre ça propre
    
    _selector = _smgr->createTerrainTriangleSelector(node);
    if (!_selector)
	return false;
    node->setTriangleSelector(_selector);
    
    initCases();
    return true;
}
Пример #3
0
void Game::init()
{
#ifdef WIN32
	device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(640, 480));
#else
	device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480));
#endif
	
	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();
	
	device->setWindowCaption(L"Not So Much Super Offroad - By Andreas Kröhnke");
	
	IMeshSceneNode *node = smgr->addMeshSceneNode( smgr->getMesh("data/car3.3ds")->getMesh(0) );
	GameObject *car = new GameObject();
	car->setSceneNode(node);
	node->setMaterialFlag(EMF_LIGHTING, false);
	node->setScale(vector3df(0.09,0.09,0.09));
	node->setRotation(vector3df(0,0,0));
	node->setPosition(vector3df(3454,500,1256));
	//node->setDebugDataVisible(EDS_BBOX);
	object->push_back(car);
	
	ITerrainSceneNode *terrain = smgr->addTerrainSceneNode("data/level1.bmp");
	GameObject *go_terrain = new GameObject();
	go_terrain->setSceneNode(terrain);
	terrain->setMaterialFlag(EMF_LIGHTING, false);
	terrain->setScale(core::vector3df(18, 3.0f, 18));
	terrain->setMaterialFlag(video::EMF_LIGHTING, false);
	terrain->setMaterialTexture(0, driver->getTexture("data/terrain-texture.jpg"));
	terrain->setMaterialTexture(1, driver->getTexture("data/detailmap3.jpg"));
	terrain->setMaterialType(video::EMT_DETAIL_MAP);
	terrain->scaleTexture(1.0f, 20.0f);
	terrain->setDebugDataVisible(EDS_BBOX);
	object->push_back(go_terrain);
	
	// Camera
	Camera *cam = new Camera();
	cam->setSceneNode(smgr->addCameraSceneNode());
	object->push_back(cam);
	cam->followNode(car->getSceneNode());
	
	reciever = new EventReciever();
	reciever->setSteer(car->getSceneNode());
	device->setEventReceiver(reciever);
	
	// create triangle selector for the terrain	
	ITriangleSelector* selector = smgr->createTerrainTriangleSelector(terrain, 0);
	terrain->setTriangleSelector(selector);
	selector->drop();
	
	// create collision response animator and attach it to the camera
	ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(selector, car->getSceneNode(), core::vector3df(10,10,10),
																			core::vector3df(0,-5.0f,0), 
																			core::vector3df(0,0,0)
	);
	
	car->getSceneNode()->addAnimator(anim);
	anim->drop();
	
	// Skybox
	smgr->addSkyBoxSceneNode(
							 driver->getTexture("data/irrlicht2_up.jpg"),
							 driver->getTexture("data/irrlicht2_dn.jpg"),
							 driver->getTexture("data/irrlicht2_lf.jpg"),
							 driver->getTexture("data/irrlicht2_rt.jpg"),
							 driver->getTexture("data/irrlicht2_ft.jpg"),
							 driver->getTexture("data/irrlicht2_bk.jpg"));
	
	// Checkpoints
	pair<vector3df, vector3df> cp1(vector3df(3112,393,1234), vector3df(90,90,0));
	addCheckPoint(cp1.first, cp1.second);
	pair<vector3df, vector3df> cp2(vector3df(2531,281,1389), vector3df(90,120,0));
	addCheckPoint(cp2.first, cp2.second);
	addCheckPoint(vector3df(2304,160,1826), vector3df(90,140,0));
	addCheckPoint(vector3df(2132,111,2672), vector3df(90,120,0));
	addCheckPoint(vector3df(1130,415,3313), vector3df(90,75,0));
	addCheckPoint(vector3df(746,471,1753), vector3df(90,0,0));
	addCheckPoint(vector3df(1985,269,1457), vector3df(90,-120,0));
	addCheckPoint(vector3df(2475,146,2868), vector3df(90,-120,0));
	addCheckPoint(vector3df(3707,417,2915), vector3df(90,-60,0));
	
	// Arrows
	addArrow(vector3df(3012,320,1234), vector3df(100,-55,0));
	addArrow(vector3df(2531,220,1389), vector3df(100,-10,0));
	//addArrow(vector3df(2304,110,1826), vector3df(90,10,0));
	addArrow(vector3df(2232,20,2272), vector3df(90,-20,0));

	// HUD
	info = guienv->addStaticText(L"USE ARROW KEYS TO PLAY",
								 rect<int>(10,10,200,60), true);
	info->setOverrideColor(SColor(255, 255, 255, 255));

	//IGUIStaticText *quick_info = guienv->addStaticText(L"Arrow keys to play\n", rect<int>(10,50,200,50), true);
	//quick_info->setOverrideColor(SColor(255,255,255,255));
	initSound();
}
Пример #4
0
int main()
{
	int idCenario = 0;
	
	int quadId;

	vector3df p1, p2, p3, p4;

	SMatrix mtxCenario; 

	CArquivoMatrizes *_fileMtx = new CArquivoMatrizes();

	CSampleSceneNode *myQuad[2500];

	CGerEventos eventos;

	IrrlichtDevice *device =  createDevice(EDT_OPENGL, dimension2d<s32>(800, 600), 16, false,false,false, &eventos);

	device->setWindowCaption(L"Editor de matrizes - Warbugs");

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();

	

	smgr->addCameraSceneNodeFPS();
	//smgr->addCameraSceneNode(0, vector3df(0,100,0), vector3df(0,0,0));

	smgr->loadScene(pathCenario[idCenario]);
	mtxCenario = _fileMtx->getMatrix(idCenario);

	ITerrainSceneNode *sceneTerrain = (ITerrainSceneNode*)smgr->getSceneNodeFromType(ESNT_TERRAIN, 0);
	ITriangleSelector *sceneTris = smgr->createTerrainTriangleSelector(sceneTerrain, 0);
	sceneTerrain->setTriangleSelector(sceneTris);

	for(int i=0; i<50; i++) // z
	{
		for(int j=0; j<50;j++) // x
		{
			//if(
			//{
				p1.X = 10.0;
				p1.Y = 1.0;
				p1.Z = 0.0;

				p2.X = 10.0;
				p2.Y = 1.0;
				p2.Z = 500.0;

				p3.X = 0.0;
				p3.Y = 1.0;
				p3.Z = 500.0;

				p4.X = 0.0;
				p4.Y = 1.0;
				p4.Z = 0.0;

				quadId = j + (i * 10);
				myQuad[quadId] = new CSampleSceneNode(smgr->getRootSceneNode(), smgr, quadId, p1, p2, p3, p4);
			//}
		}
	}

	while(device->run())
	{
		driver->beginScene(true, true, SColor(0,100,100,100));

		smgr->drawAll();

		driver->endScene();
	}

	device->drop();

	return 0;
}