예제 #1
0
void AppResize( JNIEnv*  env, jobject  thiz, jint w, jint h )
{
	std::string		apkpath;
	FileSystemZip*	pFileSystem = NULL;

	g_winVideoScreenX = w;
	g_winVideoScreenY = h;
		
	if (!BaseApp::GetBaseApp()->IsInitted())
	{
		srand( (unsigned)time(NULL) );

#ifdef _DEBUG
	LogMsg("Setup screen to %d %d", w, h);
#endif
		SetupScreenInfo(GetPrimaryGLX(), GetPrimaryGLY(), ORIENTATION_PORTRAIT);
				
		apkpath 	= GetAPKFile();
		
#ifdef _DEBUG
		LogMsg("Initializing BaseApp.  APK filename is %s", apkpath.c_str());
#endif				
		pFileSystem = new FileSystemZip();

		if( pFileSystem->Init_unz(apkpath) )
		{
			LogMsg("APK based Filesystem mounted.");
		}
		else
		{
			LogMsg("Error finding APK file to load resources (%s", apkpath.c_str());
		}

		pFileSystem->SetRootDirectory("assets");

		FileManager::GetFileManager()->MountFileSystem(pFileSystem);
				
		if (!BaseApp::GetBaseApp()->Init())
		{
			LogMsg("Unable to initalize BaseApp");
		}

		pthread_mutex_init(&s_mouselock, NULL);

		//let's also create our save directory on the sd card if needed, so we don't get errors when just assuming we can save
		//settings later in the app.
		CreateDirectoryRecursively("", GetAppCachePath());
	}

	BaseApp::GetBaseApp()->OnScreenSizeChange();
}
예제 #2
0
void QuakeShaderInitScene()
{
	if (!IrrlichtManager::GetIrrlichtManager()->GetDevice())
	{
		LogError("Error initializing Irrlicht");
		return;
	}
	IrrlichtManager::GetIrrlichtManager()->GetDevice()->getTimer()->setTime(0);
	
    scene::ISceneManager*   smgr   = IrrlichtManager::GetIrrlichtManager()->GetScene();
	IrrlichtDevice*         device = IrrlichtManager::GetIrrlichtManager()->GetDevice();
	
		   
	// Quake3 Shader controls Z-Writing
	smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
    
    //for Android
    FileSystemZip* pFileSystem = (FileSystemZip*) FileManager::GetFileManager()->GetFileSystem(0);
    
    //for Android
	if (pFileSystem)
        pFileSystem->SetRootDirectory("assets/game/quake");
	
	//hack so the textures can be found.  The quake map loader isn't all that smart
	device->getFileSystem()->changeWorkingDirectoryTo((GetBaseAppPath() + "game/quake").c_str());
    
	u32                     i;
    scene::IQ3LevelMesh*    mesh;
	scene::IMeshSceneNode*  node;
    scene::IMesh*           geometry;
    const scene::IMesh*     additional_mesh;
	
    mesh = (scene::IQ3LevelMesh*)smgr->getMesh("maps/20kdm2.bsp");
    
    if (mesh)
	{
		geometry = mesh->getMesh(quake3::E_Q3_MESH_GEOMETRY);
		node = smgr->addOctreeSceneNode(geometry, 0, -1, 4096);
	}
    
	if ( mesh )
	{
		// the additional mesh can be quite huge and is unoptimized
		additional_mesh = mesh->getMesh(quake3::E_Q3_MESH_ITEMS);
        
#ifdef SHOW_SHADER_NAME
		gui::IGUIFont *font = device->getGUIEnvironment()->getFont("media/fontlucida.png");
		u32 count = 0;
#endif
       
		for ( i = 0; i!= additional_mesh->getMeshBufferCount(); ++i )
		{
			const IMeshBuffer* meshBuffer = additional_mesh->getMeshBuffer(i);
			const video::SMaterial& material = meshBuffer->getMaterial();
            
			// The ShaderIndex is stored in the material parameter
			const s32 shaderIndex = (s32) material.MaterialTypeParam2;
            
			// the meshbuffer can be rendered without additional support, or it has no shader
			const quake3::IShader* shader = mesh->getShader(shaderIndex);
			if (0 == shader)
			{
				continue;
			}
            
			// we can dump the shader to the console in its
			// original but already parsed layout in a pretty
			// printers way.. commented out, because the console
			// would be full...
			// quake3::dumpShader ( Shader );
            
			node = smgr->addQuake3SceneNode(meshBuffer, shader);
            
#ifdef SHOW_SHADER_NAME
			count += 1;
			core::stringw name( node->getName() );
			node = smgr->addBillboardTextSceneNode(
                                                   font, name.c_str(), node,
                                                   core::dimension2d<f32>(80.0f, 8.0f),
                                                   core::vector3df(0, 10, 0));
#endif
		}
	}
  
    quake3::IEntity             search;
    s32                         index;
    s32                         notEndList;
    u32                         parsepos;
    f32                         angle;
    core::vector3df             pos;
    const quake3::SVarGroup*    group;
    scene::ICameraSceneNode*    camera;
	
    camera = smgr->addCameraSceneNodeFPS();
    	
	if ( mesh )
	{
		quake3::tQ3EntityList& entityList   = mesh->getEntityList();
		search.name                         = "info_player_deathmatch";
        index                               = entityList.binary_search(search);
        
		if (index >= 0)
		{
			do
			{
				group       = entityList[index].getGroup(1);
                
				parsepos    = 0;
				pos         = quake3::getAsVector3df(group->get("origin"), parsepos);
                
				parsepos    = 0;
				angle       = quake3::getAsFloat(group->get("angle"), parsepos);
                
				core::vector3df target(0.f, 0.f, 1.f);
				target.rotateXZBy(angle);
                
				camera->setPosition(pos);
				camera->setTarget(pos + target);
                
				++index;
                
				notEndList = index == 2;
			} while ( notEndList );
		}
	}
    

#ifdef _IRR_COMPILE_WITH_GUI_
    EventControlComponent* receiver = new EventControlComponent();
    receiver->AddGuiButton();
	device->setEventReceiver(receiver);
#endif

}