コード例 #1
0
ファイル: TerrainManager.cpp プロジェクト: oksangman/Ant
void TerrainManager::CreateTerrain( unsigned int nTerrainPageX, unsigned int nTerrainPageY, unsigned int nTerrainSize, float fTerrainWorldSize, const Ogre::Vector3 &TerrainPos )
{
	m_nTerrainSize = nTerrainSize;
	m_fWorldTerrainSize = fTerrainWorldSize;
	m_TerrainPos = TerrainPos;
	
	const Ogre::String filename("terrain");
	const Ogre::String extension("dat");

	/*Ogre::ResourceGroupManager &rgm = Ogre::ResourceGroupManager::getSingleton();
	rgm.addResourceLocation("defaultsTexture", "FileSystem", "temp");
	rgm.initialiseResourceGroup("temp");*/

	DestroyTerrain();

	m_pkTerrainGroup = new Ogre::TerrainGroup(m_pkSceneManager, Ogre::Terrain::ALIGN_X_Z, m_nTerrainSize, m_fWorldTerrainSize);
	m_pkTerrainGroup->setFilenameConvention(filename, extension);
	m_pkTerrainGroup->setOrigin(m_TerrainPos);
	m_pkTerrainGroup->setResourceGroup("ControlCarChapter");

	ConfigTerrainDefaults();

	for (long x = 0; x <= nTerrainPageX; ++x)
		for (long y = 0; y <= nTerrainPageY; ++y)
			m_pkTerrainGroup->defineTerrain(x, y, 0.0f);
	m_pkTerrainGroup->loadAllTerrains(true);
	m_pkTerrainGroup->saveAllTerrains(true);
	m_pkTerrainGroup->removeAllTerrains();

	m_bCreate = true;

	LoadTerrain(filename, extension, nTerrainPageX, nTerrainPageY, "ControlCarChapter");
}
コード例 #2
0
ファイル: MAP.cpp プロジェクト: tuku/snoxd-koserver
///////////////////////////////////////////////////////////////////////
//	각 서버가 담당하고 있는 zone의 Map을 로드한다.
//
BOOL MAP::LoadMap(HANDLE hFile)
{
	LoadTerrain( hFile );
	m_N3ShapeMgr.Create((m_nMapSize - 1)*m_fUnitDist, (m_nMapSize-1)*m_fUnitDist);
	if( !m_N3ShapeMgr.LoadCollisionData(hFile) )
		return FALSE;

	if(	(m_nMapSize - 1) * m_fUnitDist != m_N3ShapeMgr.Width() || 
		(m_nMapSize - 1) * m_fUnitDist != m_N3ShapeMgr.Height() )
	{
		return FALSE;
	}

	int mapwidth = (int)m_N3ShapeMgr.Width();

	m_sizeRegion.cx = (int)(mapwidth/VIEW_DIST) + 1;
	m_sizeRegion.cy = (int)(mapwidth/VIEW_DIST) + 1;

	m_sizeMap.cx = m_nMapSize;
	m_sizeMap.cy = m_nMapSize;

	m_ppRegion = new CRegion*[m_sizeRegion.cx];
	for(int i=0; i<m_sizeRegion.cx; i++) {
		m_ppRegion[i] = new CRegion[m_sizeRegion.cy];
		m_ppRegion[i]->m_byMoving = 0;
	}

	LoadObjectEvent(hFile);
	LoadMapTile(hFile);

	InitializeCriticalSection( &g_region_critical );

	return TRUE;
}
コード例 #3
0
bool SMDFile::LoadMap(FILE *fp, std::string & mapName, bool bLoadWarpsAndRegeneEvents)
{
	m_MapName = mapName;

	LoadTerrain(fp);

	m_N3ShapeMgr->Create((m_nMapSize - 1)*m_fUnitDist, (m_nMapSize-1)*m_fUnitDist);
	if (!m_N3ShapeMgr->LoadCollisionData(fp)
		|| (m_nMapSize - 1) * m_fUnitDist != m_N3ShapeMgr->Width() 
		|| (m_nMapSize - 1) * m_fUnitDist != m_N3ShapeMgr->Height())
		return false;

	int mapwidth = (int)m_N3ShapeMgr->Width();

	m_nXRegion = (int)(mapwidth / VIEW_DISTANCE) + 1;
	m_nZRegion = (int)(mapwidth / VIEW_DISTANCE) + 1;

	LoadObjectEvent(fp);
	LoadMapTile(fp);

	if (bLoadWarpsAndRegeneEvents)
	{
		LoadRegeneEvent(fp);
		LoadWarpList(fp);
	}

	return true;
}
コード例 #4
0
ファイル: SMDFile.cpp プロジェクト: 66gs/snoxd-koserver
bool SMDFile::LoadMap(FILE *fp)
{
	LoadTerrain(fp);

	m_N3ShapeMgr->Create((m_nMapSize - 1)*m_fUnitDist, (m_nMapSize-1)*m_fUnitDist);
	if (!m_N3ShapeMgr->LoadCollisionData(fp)
		|| (m_nMapSize - 1) * m_fUnitDist != m_N3ShapeMgr->Width() 
		|| (m_nMapSize - 1) * m_fUnitDist != m_N3ShapeMgr->Height())
		return false;

	int mapwidth = (int)m_N3ShapeMgr->Width();

	m_nXRegion = (int)(mapwidth / VIEW_DISTANCE) + 1;
	m_nZRegion = (int)(mapwidth / VIEW_DISTANCE) + 1;

	LoadObjectEvent(fp);
	LoadMapTile(fp);

#if defined(EBENEZER)
	LoadRegeneEvent(fp);	
	LoadWarpList(fp);
#endif

	return true;
}
コード例 #5
0
ファイル: World.cpp プロジェクト: RGrant92/Klampt
int RobotWorld::LoadElement(const string& sfn)
{
  const char* fn = sfn.c_str();
  const char* ext=FileExtension(fn);
  if(0==strcmp(ext,"rob") || 0==strcmp(ext,"urdf")) {
    int res=LoadRobot(fn);
    if(res<0) {
      printf("Error loading robot file %s\n",fn);
      return -1;
    }
    return RobotID(res);
  }
  else if(0==strcmp(ext,"env") || Geometry::AnyGeometry3D::CanLoadExt(ext)) {
    int res=LoadTerrain(fn);
    if(res < 0) {
      printf("Error loading terrain file %s\n",fn);
      return -1;
    }
    return TerrainID(res);
  }
  else if(0==strcmp(ext,"obj")) {
    int res=LoadRigidObject(fn);
    if(res<0) {
      printf("Error loading rigid object file %s\n",fn);
      return -1;
    }
    return RigidObjectID(res);
  }
  else {
    printf("Unknown file extension %s on file %s\n",ext,fn);
    return -1;
  }
}
コード例 #6
0
ファイル: main.cpp プロジェクト: Wali8822/SceneNav
BOOL InitOpenGL()
{
	GLfloat pos[]={1.0,1.0,-6.0};
    g_eye[0]=0.0;
	g_eye[1]=0.0;
	g_eye[2]=-100.0;
	g_center[0]= 0.0;
	g_center[1]= 0.0;
	g_center[2]= 0.0;
	glClearColor(0.0,0.0,0.0,1.0);
	glClearDepth(1.0);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LINE_SMOOTH);
	glDepthFunc(GL_LEQUAL);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
	LoadTexture("floor.bmp");	
	g_obj.InitObject("tris.md2","tris.tga");
	g_obj.SetState(CROUCH_STAND);
	//g_loader.LoadModel("tris.md2");
	//g_loader.LoadSkin("tris.tga");
	//g_loader.SetAnim(POINT_A);
 //   g_loader.ScaleModel(1.5);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
	glTexEnvf(GL_TEXTURE_2D,GL_TEXTURE_ENV_MODE,GL_REPLACE);

	glLightfv(GL_LIGHT0,GL_POSITION,pos);

	//glEnable(GL_LIGHTING);
	//glEnable(GL_LIGHT0);
	glEnable(GL_TEXTURE);
	glEnable(GL_TEXTURE_2D);

	LoadTerrain("Terrain.bmp");

	g_envList=glGenLists(1);
	glNewList(g_envList,GL_COMPILE);
	glPushMatrix();
	glEnable(GL_TEXTURE);
	glBindTexture(GL_TEXTURE_2D,texname);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
	glTexEnvf(GL_TEXTURE_2D,GL_TEXTURE_ENV_MODE,GL_MODULATE);
	glBegin(GL_POLYGON);
	glTexCoord2d(0.0,0.0);glVertex3f(-500.0,0.0,500.0);
	glTexCoord2d(4.0,0.0);glVertex3f(500.0,0.0,500.0);
	glTexCoord2d(4.0,4.0);glVertex3f(500.0,0.0,-500.0);
	glTexCoord2d(0.0,4.0);glVertex3f(-500.0,0.0,-500.0);
	glEnd();	
#define SCALE_X            (1100.0f/32)
#define SCALE_Z            (1100.0f/32)
//    GLfloat x= -550.0;
//    GLfloat z= -550.0;
//	for (int i=0;i<MAP_X-1;x+=SCALE_X,++i)
//	{
//		z = -550.0;
//		for (int e=0;e < MAP_Z-1;z+=SCALE_Z,++e)
//		{
//	        glBegin(GL_QUADS);
//			glTexCoord2f(x,z);    glVertex3f(x,g_imageData[i][e],z);
//			glTexCoord2f(x+1,z);  glVertex3f(x+SCALE_X,g_imageData[i+1][e],z);
//			glTexCoord2f(x+1,z+1);glVertex3f(x+SCALE_X,g_imageData[i+1][e+1],z+SCALE_Z);
//			glTexCoord2f(x,z+1);  glVertex3f(x,g_imageData[i][e+1],z+SCALE_Z);
//            glEnd();
//		}
//	}
	

	glBindTexture(GL_TEXTURE_2D,texTop);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
	glBegin(GL_POLYGON);
	glTexCoord2d(0.0,0.0);glVertex3f(-500.0,500.0,500.0);
	glTexCoord2d(1.0,0.0);glVertex3f(500.0,500.0,500.0);
	glTexCoord2d(1.0,1.0);glVertex3f(500.0,500.0,-500.0);
	glTexCoord2d(0.0,1.0);glVertex3f(-500.0,500.0,-500.0);
	glEnd();

	glMatrixMode(GL_MODELVIEW);

	glBindTexture(GL_TEXTURE_2D,texFront);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
	glBegin(GL_POLYGON);
	glTexCoord2d(0.0,0.0);glVertex3f(-500.0,500.0,-500.0);
	glTexCoord2d(1.0,0.0);glVertex3f(500.0,500.0,-500.0);
	glTexCoord2d(1.0,1.0);glVertex3f(500.0,0.0,-500.0);
	glTexCoord2d(0.0,1.0);glVertex3f(-500.0,0.0,-500.0);
	glEnd();

	glBindTexture(GL_TEXTURE_2D,texRight);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
	glBegin(GL_POLYGON);
	glTexCoord2d(0.0,0.0);glVertex3f(-500.0,500.0,500.0);
	glTexCoord2d(1.0,0.0);glVertex3f(-500.0,500.0,-500.0);
	glTexCoord2d(1.0,1.0);glVertex3f(-500.0,0.0,-500.0);
	glTexCoord2d(0.0,1.0);glVertex3f(-500.0,0.0,500.0);
	glEnd();

	glBindTexture(GL_TEXTURE_2D,texLeft);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
	glBegin(GL_POLYGON);
	glTexCoord2d(0.0,0.0);glVertex3f(500.0,500.0,-500.0);
	glTexCoord2d(1.0,0.0);glVertex3f(500.0,500.0,500.0);
	glTexCoord2d(1.0,1.0);glVertex3f(500.0,0.0,500.0);
	glTexCoord2d(0.0,1.0);glVertex3f(500.0,0.0,-500.0);
	glEnd();

	glBindTexture(GL_TEXTURE_2D,texBack);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
	glBegin(GL_POLYGON);
	glTexCoord2d(0.0,0.0);glVertex3f(500.0,500.0,500.0);
	glTexCoord2d(1.0,0.0);glVertex3f(-500.0,500.0,500.0);
	glTexCoord2d(1.0,1.0);glVertex3f(-500.0,0.0,500.0);
	glTexCoord2d(0.0,1.0);glVertex3f(500.0,0.0,500.0);
	glEnd();

	glDisable(GL_TEXTURE);
	glPopMatrix();
	glEndList();
	return TRUE;
}
コード例 #7
0
ファイル: scene.cpp プロジェクト: DrDrake/bokehrendering
		//----------------------------------------------------------------------
		void LoadScene(		const std::string& _filename,
							ResourceManager& _resourceManager,
							SceneManager& _scene,
							bool _verbose)
		{
			// Load configuration file
			glf::io::ConfigLoader loader;
			glf::io::ConfigNode* root	= loader.Load(_filename);

			// Load models
			glf::io::ConfigNode* geometriesNode = loader.GetNode(root,"geometries");
			if(geometriesNode != NULL)
			{
				int nGeometries = loader.GetCount(geometriesNode);
				for(int i=0;i<nGeometries;++i)
				{
					glf::io::ConfigNode* geometryNode = loader.GetNode(geometriesNode,i);

					std::string name			= loader.GetString(geometryNode,"name");
					std::string folder			= loader.GetString(geometryNode,"folder");
					std::string filename		= loader.GetString(geometryNode,"file");
					glm::vec3 translate			= loader.GetVec3(geometryNode,"translate");
					glm::vec3 rotate			= loader.GetVec3(geometryNode,"rotate");
					float scale					= loader.GetFloat(geometryNode,"scale");
					glm::mat4 transform			=	glm::translate(translate.x,translate.y,translate.z) *
													glm::rotate(rotate.z,0.f,0.f,1.f) *
													glm::rotate(rotate.y,0.f,1.f,0.f) *
													glm::rotate(rotate.x,1.f,0.f,0.f) *
													glm::scale(scale,scale,scale);

					LoadModel(	glf::directory::ModelDirectory + folder + "/",
								filename,
								transform,
								_resourceManager,
								_scene,
								_verbose);
				}
			}

			// Load terrains
			glf::io::ConfigNode* terrainsNode = loader.GetNode(root,"terrains");
			if(terrainsNode != NULL)
			{
				int nTerrains = loader.GetCount(terrainsNode);
				for(int i=0;i<nTerrains;++i)
				{
					glf::io::ConfigNode* terrainNode = loader.GetNode(terrainsNode,i);

					std::string name			= loader.GetString(terrainNode,"name");
					std::string diffuse			= loader.GetString(terrainNode,"diffuse");
					std::string height			= loader.GetString(terrainNode,"height");

					float roughness				= loader.GetFloat(terrainNode,"roughness");
					float specularity			= loader.GetFloat(terrainNode,"specularity");

					glm::vec2 terrainSize		= loader.GetVec2(terrainNode,"terrainSize");
					glm::vec3 terrainOffset		= loader.GetVec3(terrainNode,"terrainOffset");
					int tileResolution			= 32; //loader.GetInt(terrainNode,"tileResolution");
					float heightFactor			= loader.GetFloat(terrainNode,"heightFactor");
					float tileFactor			= loader.GetFloat(terrainNode,"tileFactor");
					float tessFactor			= 15.f; //loader.GetFloat(terrainNode,"tessFactor");
					float projFactor			= 10.f; //loader.GetFloat(terrainNode,"projFactor");

					LoadTerrain(glf::directory::TextureDirectory,
								diffuse,
								height,
								roughness,
								specularity,
								terrainSize,
								terrainOffset,
								tileResolution,
								heightFactor,
								tessFactor,
								projFactor,
								tileFactor,
								_resourceManager,
								_scene,
								_verbose);
				}
			}

			// Compute bounds
			_scene.wBound = WorldBound(_scene);
			if(_verbose)
			{
				glf::Info("----------------------------------------------");
				glf::Info("World bound   : (%f,%f,%f) (%f,%f,%f)",
											_scene.wBound.pMin.x,
											_scene.wBound.pMin.y,
											_scene.wBound.pMin.z,
											_scene.wBound.pMax.x,
											_scene.wBound.pMax.y,
											_scene.wBound.pMax.z);
			}

			// Load lights
			//TODO

			// Load camera
			//TODO
		}
コード例 #8
0
ファイル: TERRAIN9.C プロジェクト: HintonBR/scratch
int                /* O - Exit status */
main(int  argc,    /* I - Number of command-line arguments */
     char *argv[]) /* I - Command-line arguments */
    {
    glutInit(&argc, argv);
#ifdef BOOK_COVER
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
#else
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
#endif /* BOOK_COVER */
    glutInitWindowSize(792, 573);
    glutCreateWindow("Terrain Using Vertex Culling Extension");
    glutDisplayFunc(Redraw);
    if (glutDeviceGet(GLUT_HAS_JOYSTICK))
        glutJoystickFunc(Joystick, 200);
    glutKeyboardFunc(Keyboard);
    glutMotionFunc(Motion);
    glutMouseFunc(Mouse);
    glutReshapeFunc(Resize);
    glutSpecialFunc(Special);

    BuildF16();

    LandTexture = TextureLoad("land.bmp", GL_FALSE, GL_LINEAR_MIPMAP_LINEAR,
                              GL_LINEAR, GL_REPEAT);
    SkyTexture  = TextureLoad("sky.bmp", GL_FALSE, GL_LINEAR, GL_LINEAR,
                              GL_CLAMP);

    LoadTerrain(36, -112);

    puts("QUICK HELP:");
    puts("");
    puts("ESC - Quit");
    puts("',' - Slow down, '<' - Slowest");
    puts("'.' - Speed up, '>' - Fastest");
    puts("'3' - Toggle terrain");
    puts("'a' - Toggle aircraft");
    puts("'f' - Toggle fog");
    puts("'l' - Toggle lighting");
    puts("'s' - Toggle sky/clouds");
    puts("'t' - Toggle texturing");
    puts("'w' - Toggle water");
    puts("'W' - Toggle wireframe");

    printf("GL_EXTENSIONS = %s\n", glGetString(GL_EXTENSIONS));

    if (strstr(glGetString(GL_EXTENSIONS), "EXT_cull_vertex") != NULL)
        {
        UseCullVertex        = 1;
	glCullParameterfvEXT = wglGetProcAddress("glCullParameterfvEXT");
	}
    else if (strstr(glGetString(GL_EXTENSIONS), "SGI_cull_vertex") != NULL)
        {
        UseCullVertex        = 1;
	glCullParameterfvEXT = wglGetProcAddress("glCullParameterfvSGI");
	}
    else
        UseCullVertex = 0;

    glutMainLoop();

    return (0);
    }