Exemplo n.º 1
0
void init()
{
	initDisplay();
	
	player1.load("chr_old.obj");
	car1.load("car1.obj");
	road.load("Road_Wide.obj");
	grass.load("Grass.obj");


}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
    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;
    }
Exemplo n.º 4
0
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);
		}
	}
}
Exemplo n.º 5
0
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


}
Exemplo n.º 6
0
void init()
{
    for (int i = 0; i < 256; i++)
    {
        key_pressed[i] = false;
    }
    
    for (int i = 0; i < 20; i++)
    {
        special_key_pressed[i] = false;
    }
    
    initDisplay();
    camera.setPosition(Vector3(70000.0, 0.0, 70000.0));
    skybox.load("Models/Skybox.obj");
    saturn.load(saturnInfo.filename);
    for (int i = 0; i < 10; i++)
    {
        moons[i].load(moonInfo[i].filename);
    }
    ring.load(ringInfo.filename);
}
Exemplo n.º 7
0
//--------------------------------------------------
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);
	}
}
Exemplo n.º 8
0
//--------------------------------------------------
Scene::Scene(Input *input)
{
	camera = new Camera();
	cameraSpeed = 0.3f;
	this->input = input;

	sun = new Light(GL_LIGHT0);

	//SetupOpenGL

	//Blending
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GREATER, 0.01f);

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	glEnable(GL_NORMALIZE);

	glDisable(GL_COLOR_MATERIAL);
	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

	texturLoader = new Texture();
	shLoader = new Shaderloader();

	mainObj = new Object();
	loadObjects("default", mainObj);

	terrain = new Terrain(texturLoader);
	skybox = new Skybox(texturLoader);
	water = new Object();
	ObjModel* watermod = new ObjModel();
	watermod->load("water", texturLoader, shLoader);
	water->addModel(watermod);

	armor = new ObjModel();
	armor->load("ruestung_old", texturLoader, shLoader);
	armorRotation = 0.0;

	torch1 = new ParticleSystem(texturLoader, Vector3f(15.0 - 300, 202.0, 26.0 + 700));
	torch2 = new ParticleSystem(texturLoader, Vector3f(287.0 - 300, 202.0, 26.0 + 700));

	helpText = new Text(texturLoader);

	//Save ModelMatrix
	glLoadIdentity();
	mainObj->saveModelMatrix();


	camera->move(200, -170, -500);

	// for students: uncomment this if you implemented environment mapping
	envShader = new Shader();
	envShader->load("./Daten/Shaders/Env_Mapping.vert", "./Daten/Shaders/Env_Mapping.frag");
	// end for students

	// set up our dynamic cubemap
	// uncomment this if you implemented environment mapping
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	glGenTextures(1, &envText);
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, envText);
	// end

	// set up some parameters
	// uncomment this if you implemented environment mapping
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
	//end

	// set up min and max filters
	// uncomment this if you implemented environment mapping
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	for (int i = 0; i < 6; i++)
	{
		glTexImage2D(cubeMapDefines[i], 0, GL_RGBA, CUBE_MAP_SIZE, CUBE_MAP_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
	}

	glDisable(GL_TEXTURE_CUBE_MAP_ARB);

	shadowMode = 0;

	//create shadowmap-texture

	shMapW = width;
	shMapH = height;

	shadowMap = 0;
	glGenTextures(1, &shadowMap);
	glBindTexture(GL_TEXTURE_2D, shadowMap);
	glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32_ARB, shMapW, shMapH, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

	shadowMapping = new Shader();
	shadowMapping->load("./Daten/Shaders/Shadow_Mapping.vert", "./Daten/Shaders/Shadow_Mapping.frag");
	shadowMappingAliased = new Shader();
	shadowMappingAliased->load("./Daten/Shaders/Shadow_Mapping.vert",
														 "./Daten/Shaders/Shadow_Mapping_Aliased.frag");

	// load toon shader
	toonShader = new Shader();
	toonShader->load("./Daten/Shaders/toon.vert", "./Daten/Shaders/toon.frag");
}
Exemplo n.º 9
0
void World :: init ()
{
	if(!isInitialized())
	{
        // Skybox Init
        ObjModel sb;
        sb.load("Models/Skybox.obj");
        skybox = sb.getDisplayList();
        
        // Planet Init
        ObjModel p;
        p.load(planetInfo.filename);
        DisplayList p_dl = p.getDisplayList();
        PhysicsObjectId p_id = PhysicsObjectId(PhysicsObjectId::TYPE_PLANETOID,
                                             PhysicsObjectId::FLEET_NATURE,
                                             0);
        planet.initPlanetoid(p_id, planetInfo.position, planetInfo.radius, p_dl, 1.f);
        
        // Moon Init
        for (int i = 0; i < MOON_COUNT; i++)
        {
            ObjModel m;
            m.load(moonInfo[i].filename);
            DisplayList m_dl = m.getDisplayList();
            PhysicsObjectId m_id = PhysicsObjectId(PhysicsObjectId::TYPE_PLANETOID,
                                                   PhysicsObjectId::FLEET_NATURE,
                                                   i + 1);
            moons[i].initPlanetoid(m_id, moonInfo[i].position, moonInfo[i].radius, m_dl, 1.f);
        }
        
        // Ship Init
        ObjModel s;
        s.load("Models/Grapple.obj");
        DisplayList s_dl = s.getDisplayList();
        for (int i = 0; i < SHIP_COUNT; i++)
        {
            PhysicsObjectId s_id = PhysicsObjectId(PhysicsObjectId::TYPE_SHIP,
                                                   PhysicsObjectId::FLEET_ENEMY,
                                                   i);
            
            int moonIndex = rand() % MOON_COUNT;
            Vector3 pos = moonInfo[moonIndex].position
                            + Vector3::getRandomUnitVector()
                            * (moonInfo[moonIndex].radius + 500.0);
            
            ships[i].initPhysics(s_id, pos, 100.f, Vector3::getRandomUnitVector(), s_dl, 1.f);
            ships[i].setHealth(1);
            ships[i].setAmmo(0);
            ships[i].setSpeed(0.f);
        }
        
        // Add Bullets
        ObjModel b;
        b.load("Models/Bolt.obj");
        DisplayList b_dl = b.getDisplayList();
        for (int i = 0; i < BULLET_COUNT; i++)
        {
            PhysicsObjectId b_id = PhysicsObjectId(PhysicsObjectId::TYPE_BULLET,
                                                   PhysicsObjectId::FLEET_MAX,
                                                   i);
            bullets[i].initPhysics(b_id, {0, 0, 0}, 1.f, {0, 0, 0}, b_dl, 2.5f);
        }

		assert(mp_explosion_manager != NULL);
		mp_explosion_manager->init("Explode1.png", 15);
	}

	assert(invariant());
}
Exemplo n.º 10
0
void init()
{
	initDisplay();
	bucket.load("models/bucket/firebucket.obj");
}
Exemplo n.º 11
0
void init()
{
	initDisplay();
	bucket.load("firebucket.obj");
    bucket_list = bucket.getDisplayList();
}