当前位置: 首页>>代码示例>>C++>>正文


C++ ObjModel类代码示例

本文整理汇总了C++中ObjModel的典型用法代码示例。如果您正苦于以下问题:C++ ObjModel类的具体用法?C++ ObjModel怎么用?C++ ObjModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: id

void World::initShips()
{
	// space ship
	PhysicsObjectId id(PhysicsObjectId::TYPE_SHIP, PhysicsObjectId::FLEET_PLAYER, 0);
	m_playerShip.init("Grapple", Const::SHIP_SIZE);
	m_playerShip.setId(id);
	m_playerShip.setPosition(Const::SHIP_POSITION);
	m_playerShip.setAmmo(8);
	m_playerShip.setHealth(Const::PLAYER_HEALTH);
	m_playerShip.setSpeed(Const::MOVE_PER_FRAME);


	// space ships
	id.m_type = PhysicsObjectId::TYPE_SHIP;
	id.m_fleet = PhysicsObjectId::FLEET_ENEMY;
	ObjModel model;
	model.load(Const::MODEL_DIR + Const::ENEMY_SHIP_MODEL_NAME + Const::EXTENSION);
	DisplayList displayList = model.getDisplayList();
	for (int i = 1; i <= Const::MOON_COUNT; i++)
	{
		for (int j = 0; j < Const::SHIPS_PER_MOON; j++){
			int index = (i - 1) * Const::SHIPS_PER_MOON + j;
			id.m_index = index;
			Vector3 position = m_planetoids[i].getPosition() + Vector3::getRandomUnitVector()*(m_planetoids[i].getScaledSize() + 500.0);
			m_ships[index].initPhysics(id, position, 1.0, 0, displayList, Const::ENEMY_SHIP_SIZE);
			m_ships[index].setHealth(1);
			m_ships[index].setUnitAi(new StemCell::UnitAiMoonGuard(m_ships[index], *this, m_planetoids[i].getId()));
			m_ships[index].setManeuverability(Const::SHIP_MAX_SPEED,Const::SHIP_ACCELERATION,Const::ROTATION_RATE);
		}
	}
}
开发者ID:whitelight2134,项目名称:spacewar,代码行数:31,代码来源:World.cpp

示例2: ALLOC

    ObjModel* ObjModel::create(
        izanagi::IMemoryAllocator* allocator,
        izanagi::graph::CGraphicsDevice* device,
        const char* path)
    {
        void* buf = ALLOC(allocator, sizeof(ObjModel));
        VRETURN_NULL(buf);

        IZ_BOOL result = IZ_FALSE;

        ObjModel* instance = new(buf)ObjModel;
        {
            instance->m_Allocator = allocator;
            instance->AddRef();

            result = instance->load(
                allocator,
                device,
                path);
        }

        if (!result) {
            SAFE_RELEASE(instance);
        }

        return instance;
    }
开发者ID:,项目名称:,代码行数:27,代码来源:

示例3: DrawModel

void DrawModel(ObjModel &model)
{
  glEnableClientState(GL_VERTEX_ARRAY);
  glVertexPointer(3, GL_FLOAT, 0, model.GetVertices());

  glEnableClientState(GL_NORMAL_ARRAY);
  glNormalPointer(GL_FLOAT, 0, model.GetNormals());

  glDrawArrays(GL_TRIANGLES, 0, model.GetTotalVerts());

  glDisableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
}
开发者ID:aashish24,项目名称:myexp,代码行数:13,代码来源:main.cpp

示例4: load

void ObjLoader::load(ObjModel &model, const char *modelpath, const char * texturepath, bool invertUV)
{
	if (texturepath != NULL)
	{
		loadTexture(model.getTexture(), texturepath);
	}

	parse(modelpath);
	bindToMesh(model, invertUV);
}
开发者ID:nnarain,项目名称:sgl-wrapper,代码行数:10,代码来源:ObjLoader.cpp

示例5: fopen

//--------------------------------------------------
void Scene::loadObjects(string filename, Object* obj)
{
	string name;
	name = "./Daten/Groups/";
	name.append(filename);
	name.append(".txt");

	ErrorLog *log = ErrorLog::getInstance();
	stringstream logStream;
	logStream << endl;
	logStream << "loading objects..." << endl << endl;
	log->reportError(logStream.str());

	FILE *fp = fopen(name.c_str(), "r");

	if (!fp)
	{
		logStream.str("");
		logStream << "Error, no input file!" << endl;
		log->reportError(logStream.str());
		return;
	}

	int res = 0;
	while (res != EOF)
	{
		char name[256] = "";
		float plz[6];
		res = fscanf(fp, "%s %f %f %f %f %f %f\n", &name, &plz[0], &plz[1], &plz[2], &plz[3], &plz[4], &plz[5]);

		ObjModel *model = new ObjModel();
		model->load(name, texturLoader, shLoader);

		Object *newObj = new Object();
		newObj->addModel(model);
		newObj->setPosition(plz[0], plz[1], plz[2]);
		newObj->setRotation(plz[3], plz[4], plz[5]);

		obj->addObject(newObj);
	}
}
开发者ID:davidhalter-archive,项目名称:cgr-shader,代码行数:42,代码来源:scene.cpp

示例6: getCvarAddress_S

void Rendar::bspFromObjModel(string modelName)	{
	string* path = getCvarAddress_S("r_modelPath");
	string canonicalPath = *path + "obj/" + modelName;

	ObjModel* obj = new ObjModel();
	obj->loadObjFile(canonicalPath);

	vec3_t mapDimensions;
	obj->getDimensions(mapDimensions);

	float width = 0;

	if( mapDimensions[0] > mapDimensions[2] )	{
		width = mapDimensions[0];
	}
	else	{
		width = mapDimensions[2];
	}

	cout << " Widest dimension: " << width << endl;

	bspRoot = new bsp_node_t;
	bspRoot->root = true;

	/*	// debugging stuffs
	polygon_t* p = obj->polygonList;
	int myPolyCount = 0;
	while( p )	{
		myPolyCount++;
		p = p->next;
	}

	Con_print("myPolyCount: %d", myPolyCount);
	*/

	generateBSPTree(bspRoot, obj->polygonList, width);
	nameAndCachePolygons(bspRoot);

	delete obj;
}
开发者ID:nonsensicalthinking,项目名称:rendar,代码行数:40,代码来源:Rendar.cpp

示例7: main

int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glEnable(GL_DEPTH_TEST);
	glutInitWindowPosition(100, 100);
	winWidth = 1300, winHeight = 800;
	glutInitWindowSize(winWidth, winHeight);
	glutCreateWindow("Traffic Simulation");
	glewInit();

	// Load the 3D models.
	trafficLight.ReadFile("Models/TrafficLight.obj");
	trafficLight2.ReadFile("Models/TrafficLight.obj");
	trafficLight3.ReadFile("Models/TrafficLight.obj");
	trafficLight4.ReadFile("Models/TrafficLight.obj");
	//cout << "\n|||||||||||\n";
	car.ReadFile("Models/taxi.obj");
	//cout << "\n|||||||||||\n";
	surveillanceCamera.ReadFile("Models/camera.obj");
	//cout << "\n|||||||||||\n";
	init();
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutKeyboardFunc(keyboard);
	glutSpecialFunc(specialKey);
	glutTimerFunc(0, timer, updateInterval);
	glutMainLoop();
	

	system("pause");
}
开发者ID:rhaye012,项目名称:Reginald-Hayes-Code-sample,代码行数:32,代码来源:main.cpp

示例8: init

void init()
{
	initDisplay();
	
	player1.load("chr_old.obj");
	car1.load("car1.obj");
	road.load("Road_Wide.obj");
	grass.load("Grass.obj");


}
开发者ID:AbdulazizAlaa,项目名称:OpenRoad,代码行数:11,代码来源:crossy.cpp

示例9: drawRoad

void drawRoad(int i)
{
	glPushMatrix();
		glTranslatef(0, -1.0f, stepObj[i].z);
		glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
		if(stepObj[i].type == 0){
			road.draw();
			drawCar(10.0f, 0, 0.09f, i);
		}else if(stepObj[i].type == 1){
			grass.draw();
		}
	glPopMatrix();
		

}
开发者ID:AbdulazizAlaa,项目名称:OpenRoad,代码行数:15,代码来源:crossy.cpp

示例10: display

void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	// clear the screen - any drawing before here will not display

	glLoadIdentity();
	// set up the camera here
    camera.setCamera();

	// camera is set up - any drawing before here will display incorrectly
    
    // Draw Skybox
    glPushMatrix();
        glTranslatef(camera.getPosition().x,
                     camera.getPosition().y,
                     camera.getPosition().z);
        glDepthMask(GL_FALSE);
        skybox.draw();
        glDepthMask(GL_TRUE);
    glPopMatrix();

    // Draw Saturn
    glPushMatrix();
        glTranslatef(saturnInfo.x, 0.f, saturnInfo.z);
        glScalef(saturnInfo.radius, saturnInfo.radius, saturnInfo.radius);
        saturn.draw();
    glPopMatrix();
    
    // Draw Moons
    for (int i = 0; i < 10; i++)
    {
        glPushMatrix();
            glTranslatef(moonInfo[i].x, 0.f, moonInfo[i].z);
            glScalef(moonInfo[i].radius, moonInfo[i].radius, moonInfo[i].radius);
            moons[i].draw();
        glPopMatrix();
    }
    
    // Draw rings
    glPushMatrix();
        glTranslatef(ringInfo.x, 0.f, ringInfo.z);
        glScalef(ringInfo.radius, ringInfo.radius, ringInfo.radius);
        ring.draw();
    glPopMatrix();
    
	// send the current image to the screen - any drawing after here will not display
	glutSwapBuffers();
}
开发者ID:streibeb,项目名称:cs409,代码行数:48,代码来源:main.cpp

示例11: init

void init(int argc, char** argv)
{
	/**
	* This function initializes the graphics properties of the whole game
	*/
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_MULTISAMPLE);		//Double Buffering - RGBAlpha - 3D - Ani-Aliasing
	glutInitWindowSize(winsizex, winsizey); 											//Window size
	glutCreateWindow("PAC-MINION"); 														//Create a window
	glutFullScreen();																	//Start with full screen mode
	glutIgnoreKeyRepeat(1);																//Ignoring key repaeat, Since we have key states
	glClearDepth(1);			
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);												//Initial color flush
	glEnable(GL_DEPTH_TEST); 															//Make sure 3D drawing works when one object is in front of another
	glEnable(GL_LIGHTING);																//Enable Lighting
	glEnable(GL_LIGHT0);																//Light 0 is enabled
	glShadeModel (GL_SMOOTH);	
	glEnable(GL_COLOR_MATERIAL);														//Enabling coloring in 3d materials
	glEnable(GL_BLEND); 																//Enable the OpenGL Blending functionality  
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);									//Function to be used for blending the graphical objects 
	GLfloat light_position[] = { 0.0, 0.0, 1.0, 0.0 };
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);									//Setting the light position
	GLfloat light_ambient[] = { 0.2, 0.2, 0.2, 1.0 };
	glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);									//Setting the ambient light intensity
	minion.genList();																	//Generating the drawing list of thw minion
	
}
开发者ID:aravindsagar,项目名称:pac-minion,代码行数:27,代码来源:pac_1_cpp.cpp

示例12: init

void init()
{
	FILE* f = fopen("media/lighting/camera.txt", "r");

	xyz pos;
	while (!feof(f))
	{
		fscanf(f, "%f %f %f", &pos.x, &pos.y, &pos.z);
		camera_pos.push_back(pos);
	}

	fclose(f);
	
	FOVY = 54.495f;
	mgr=new TheoraVideoManager();
	clip=mgr->createVideoClip(new TheoraMemoryFileDataSource("media/lighting/lighting" + resourceExtension), TH_RGB);
	clip->setAutoRestart(1);
	//clip->setPlaybackSpeed(0.5f);
	
	tex_id = createTexture(nextPow2(clip->getWidth()),nextPow2(clip->getHeight()));
	diffuse_map = loadTexture("media/lighting/diffuse_map.tga");
	
	room.load("media/lighting/room.obj", diffuse_map);

	glDisable(GL_CULL_FACE);
	glCullFace(GL_BACK);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
	glDepthFunc(GL_LESS);
	glEnable(GL_COLOR_MATERIAL);
}
开发者ID:modjke,项目名称:theoraplayer,代码行数:31,代码来源:video_lighting.cpp

示例13: drawCar

void drawCar(float  y, float z, float scale, int i)
{
	glPushMatrix();
		glTranslatef(0, 1, count_steps[i]);
		glScalef(scale,scale,scale);
		//glRotatef(90.0f, 0.0f, 1.0f, 0.0f);        
		car1.draw();
	glPopMatrix();
}
开发者ID:AbdulazizAlaa,项目名称:OpenRoad,代码行数:9,代码来源:crossy.cpp

示例14: player

void player()
{
	glPushMatrix();
        glTranslatef(playerX, playerY, playerZ);
		glRotatef(playerAngle, 0.0f, 1.0f, 0.0f);
        glScalef(playerSX, playerSY, playerSZ);
        player1.draw();
    glPopMatrix();
}
开发者ID:AbdulazizAlaa,项目名称:OpenRoad,代码行数:9,代码来源:crossy.cpp

示例15: init

void init(void)
{
	
	glClearColor(0.0, 0.0, 1.0, 1.0);	// background color = white
	glColor3f(0.0, 0.0, 0.0);		// drawing color = black
	glLineWidth(2.0f);
	glEnable(GL_DEPTH_TEST);
	fog_status=true;
	//fog_enable();
	physics_delta_time=(1/PHYSICS_UPDATE_RATE);
	AI_delta_time=(1/_FAST_AI_UPDATE_RATE);
	ai_slow_value=SLOW_AI_UPDATE_FRACTION;
	delta_time=0;
	frame=0;
	spiky_obj.load("fish.obj");
	submarine_obj.load("submarine_body.obj");
	whale_body.load("whale4s.obj");
	p_whale_x=525;
    p_whale_y=500;
    p_whale_z=-500;
	pwx=525;
    pwy=500;
    pwz=-500;
    v_whale_x=8;
    v_whale_y=8;
    v_whale_z=-12; 
	dv_whale_x=0;
    dv_whale_y=0;
    dv_whale_z=0;
	fast_AI_ESCORT=true;
	target_fish_no=-99;
	sphere=false;
	shark_target_fish=false;
	for(int i=0;i<256;i++)
	{
		key_pressed[i]=false;
	}
	alutInit(0, NULL);
//	alutLoadWAVFile("FreedomDance.wav", &format, &data, &size, &freq, &loop);

// Generate the sources


}
开发者ID:radhey20,项目名称:fish-submarine-game,代码行数:44,代码来源:assign1.cpp


注:本文中的ObjModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。