Ejemplo n.º 1
0
static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
	switch (cmd) {
	case APP_CMD_SAVE_STATE:
		// The system has asked us to save our current state.  Do so.
		break;
	case APP_CMD_INIT_WINDOW:
		// The window is being shown, get it ready.
		if (app->window != NULL) {
			setupGraphics(app);
//			renderFrame();
		}
		break;
	case APP_CMD_TERM_WINDOW:
		// The window is being hidden or closed, clean it up.
		break;
	case APP_CMD_GAINED_FOCUS:
		// When our app gains focus, we start monitoring the accelerometer.
		break;
	case APP_CMD_LOST_FOCUS:
		// When our app loses focus, we stop monitoring the accelerometer.
		// This is to avoid consuming battery while not being used.
		// Also stop animating.
		break;
	}
}
Ejemplo n.º 2
0
JNIEXPORT void JNICALL Java_com_fbrs_electraengine_GL2JNILib_init(JNIEnv * env, jobject obj,  jint width, jint height, jstring vertexShader, jstring fragShader)
{
	jboolean *isCopy;
	gVertexShader = env->GetStringUTFChars(vertexShader, isCopy);
	gFragmentShader = env->GetStringUTFChars(fragShader, isCopy);
	setupGraphics(width, height);
}
Ejemplo n.º 3
0
SkeletonDemo::SkeletonDemo( hkDemoEnvironment* env )
:	hkDefaultAnimationDemo(env)
{
	// Load the data
	m_loader = new hkLoader();

	// Convert the scene
	{
		hkString assetFile = hkAssetManagementUtil::getFilePath("Resources/Animation/HavokGirl/hkRig.hkx");
		hkRootLevelContainer* container = m_loader->load( assetFile.cString() );
		HK_ASSERT2(0x27343437, container != HK_NULL , "Could not load asset");
		hkaAnimationContainer* ac = reinterpret_cast<hkaAnimationContainer*>( container->findObjectByType( hkaAnimationContainerClass.getName() ));

		HK_ASSERT2(0x27343435, ac && (ac->m_numSkeletons > 0), "No skeleton loaded");
		m_skeleton = ac->m_skeletons[0];
	}

	//
	// Setup the camera
	//
	{
		hkVector4 from( 3,3,1 );
		hkVector4 to  ( 0,0,0 );
		hkVector4 up  ( 0.0f, 0.0f, 1.0f );
		setupDefaultCameras( env, from, to, up, 0.1f, 100 );
	}

	setupGraphics();
}
Ejemplo n.º 4
0
void HodginDidItApp::setup()
{
	setupIO();
	setupCiCamera();
	setupGraphics();
	setupShaders();
	setupFbos();
}
Ejemplo n.º 5
0
CompoundBodiesDemo::CompoundBodiesDemo(hkDemoEnvironment* env)
:	hkDefaultPhysicsDemo(env)
{
	//
	// Setup the camera
	//
	{
		hkVector4 from(0.0f, 10.0f, 30.0f);
		hkVector4 to  (0.0f,  0.0f,  0.0f);
		hkVector4 up  (0.0f,  1.0f,  0.0f);
		setupDefaultCameras( env, from, to, up );
	}

	//
	// Create the world
	//
	{
		hkpWorldCinfo info;
		info.setBroadPhaseWorldSize( 100.0f );
		info.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM);
		m_world = new hkpWorld( info );
		m_world->lock();

		// Register ALL agents (though some may not be necessary)
		hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher());

		setupGraphics();
	}

	// Create the base
	{
		hkVector4 baseSize( 20.0f, 1.0f, 20.0f);
		hkVector4 basePos(   0.0f,-0.5f,  0.0f);
		hkpRigidBody* baseRigidBody = GameUtils::createBox(baseSize, 0.0f, basePos);
		m_world->addEntity( baseRigidBody );

		baseRigidBody->removeReference();
	}



	hkPseudoRandomGenerator generator(747);
		// Create 10 wibblies
	for(int i = 0; i < 10; i++)
	{

		hkVector4 pos( generator.getRandRange(-3.0f,3.0f) , i * 3.0f + 1.5f, generator.getRandRange(-3.0f,3.0f));
		hkpRigidBody* wibbly = createWibbly(pos, &generator);
		m_world->addEntity( wibbly );

		wibbly->removeReference();

		hkVector4 vel(generator.getRandRange(-2.0f,2.0f), generator.getRandRange(-2.0f,2.0f), generator.getRandRange(-2.0f,2.0f));
		wibbly->setAngularVelocity(vel);
	}

	m_world->unlock();
}
Ejemplo n.º 6
0
JNIEXPORT void JNICALL Java_ondrej_platek_bind_NativeRenderer_initG(JNIEnv * env, jobject mythis)  {
    AppCtx * c =  reinterpret_cast<AppCtx*>(extractInt(env, mythis, "pAppCtx"));
    if(c == NULL) {
      LOGE("NativeRender_init context is NULL");
    }
    else {
        setupGraphics(c);
    }
}
Ejemplo n.º 7
0
MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow)
{
  ui->setupUi(this);

  setupGraphics();
  this->setFocus();
}
Ejemplo n.º 8
0
WorldRaycastDemo::WorldRaycastDemo(hkDemoEnvironment* env)
:	hkDefaultPhysicsDemo(env)
{
	//
	// Setup the camera.
	//
	{
		hkVector4 from(30.0f, 8.0f, 25.0f);
		hkVector4 to  ( 4.0f, 0.0f, -3.0f);
		hkVector4 up  ( 0.0f, 1.0f,  0.0f);
		setupDefaultCameras(env, from, to, up);
	}

	//
	// Create the world.
	//
	{
		hkpWorldCinfo info;
		info.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM); 
		
		// Set gravity to zero so body floats.
		info.m_gravity.set(0.0f, 0.0f, 0.0f);	
		info.setBroadPhaseWorldSize( 100.0f );
		m_world = new hkpWorld(info);
		m_world->lock();

		// Disable backface culling, since we have mopp's etc.
		setGraphicsState(HKG_ENABLED_CULLFACE, false);

		setupGraphics();
	}

	// register all agents(however, we put all objects into the some group,
	// so no collision will be detected
	hkpAgentRegisterUtil::registerAllAgents( m_world->getCollisionDispatcher() );

	// Add a collision filter to the world to allow the bodies interpenetrate
	{
		hkpGroupFilter* filter = new hkpGroupFilter();
		filter->disableCollisionsBetween( hkpGroupFilterSetup::LAYER_DEBRIS, hkpGroupFilterSetup::LAYER_DEBRIS );
		m_world->setCollisionFilter( filter );
		filter->removeReference();
	}

	//
	// Set the simulation time to 0
	//
	m_time = 0;


	//
	// Create some bodies (reuse the ShapeRaycastApi demo)
	//
	createBodies();

	m_world->unlock();
}
Ejemplo n.º 9
0
BackfacesCulledRayHitCollectorDemo::BackfacesCulledRayHitCollectorDemo(hkDemoEnvironment* env)
:	hkDefaultPhysicsDemo(env)
{
	//
	// Setup the camera.
	//
	{
		hkVector4 from( -9.0f, 6.0f, -6.0f);
		hkVector4 to  ( 0.0f, 0.0f, 0.0f);
		hkVector4 up  ( 0.0f, 1.0f,  0.0f);
		setupDefaultCameras(env, from, to, up);
	}

	//
	// Create the world.
	//
	{
		hkString filename; // We have a different binary file depending on the compiler and platform
		filename.printf("Resources/Physics/Objects/hemisphere_L%d%d%d%d.hkx",
			hkStructureLayout::HostLayoutRules.m_bytesInPointer,
			hkStructureLayout::HostLayoutRules.m_littleEndian? 1 : 0,
			hkStructureLayout::HostLayoutRules.m_reusePaddingOptimization? 1 : 0,
			hkStructureLayout::HostLayoutRules.m_emptyBaseClassOptimization? 1 : 0);
		hkIstream infile( filename.cString() );
		HK_ASSERT( 0x215d080c, infile.isOk() );
		m_physicsData = hkpHavokSnapshot::load(infile.getStreamReader(), &m_loadedData);

		m_hemisphereRb = m_physicsData->findRigidBodyByName("hemisphere");
		m_boxRb = m_physicsData->findRigidBodyByName("box");

		hkpWorldCinfo *info = m_physicsData->getWorldCinfo();
 		info->setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM);
 		info->m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_CONTINUOUS;

		// Set gravity to zero so body floats.
		info->m_gravity.set(0.0f, 0.0f, 0.0f);	
		info->setBroadPhaseWorldSize( 1000.0f );
		info->m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_DO_NOTHING;

		m_world = m_physicsData->createWorld();
		m_world->lock();

		hkpConstraintCollisionFilter* collisionFilter = new hkpConstraintCollisionFilter();
		m_world->setCollisionFilter(collisionFilter);
		collisionFilter->removeReference();
		
		// for drawing purposes
		hkpBroadPhaseBorder* border = new hkpBroadPhaseBorder( m_world, hkpWorldCinfo::BROADPHASE_BORDER_DO_NOTHING );
		m_world->setBroadPhaseBorder(border);
		border->removeReference();

		setupGraphics();

		m_world->unlock();
	}	
}
Ejemplo n.º 10
0
JNIEXPORT void JNICALL Java_com_android_spinningcube_SpinningCubeLib_init(JNIEnv * env, jobject obj,  jint width, jint height, jstring vShader, jstring fShader)
{
    if(!gVertexShader && !gFragmentShader) {
	gVertexShader = env->GetStringUTFChars(vShader, 0);
	gFragmentShader = env->GetStringUTFChars(fShader, 0);
    }
    setupGraphics(width, height);
    stats_init(&stats);

}
Ejemplo n.º 11
0
AddRemoveBodiesDemo::AddRemoveBodiesDemo(hkDemoEnvironment* env)
:	hkDefaultPhysicsDemo(env),
	m_frameCount(0),
	m_currentBody(0)
{
	for( int i = 0; i < NUM_BODIES; i++ )
	{
		m_bodies[i] = HK_NULL;		
	}	

	//
	// Setup the camera
	//
	{
		hkVector4 from(0.0f, 30.0f, 50.0f);
		hkVector4 to  (0.0f,  0.0f,  0.0f);
		hkVector4 up  (0.0f,  1.0f,  0.0f);
		setupDefaultCameras(env, from, to, up);

		float lightDir[] = { -1, -0.5f , -0.25f};
		float lightAabbMin[] = { -15, -15, -15};
		float lightAabbMax[] = { 15, 15, 15};
		setLightAndFixedShadow(lightDir, lightAabbMin, lightAabbMax );
	}


	//
	// Setup and create the hkpWorld
	//
	{
		hkpWorldCinfo info;
		info.m_gravity = hkVector4(0.0f, -9.8f, 0.0f);
		info.setBroadPhaseWorldSize(1000.0f);
		info.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_8ITERS_MEDIUM);
		info.m_collisionTolerance = 0.01f; 
		
		m_world = new hkpWorld( info );
		m_world->lock();

		setupGraphics();		
	}

	// Register the single agent required (a hkpBoxBoxAgent)
	{
		hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher());
	}

	// Create the rigid bodies
	createBodies();

	// Create the ground
	createGround();

	m_world->unlock();
}
Ejemplo n.º 12
0
//--------------------------------------------------------------
void testApp::setup(){
	
	setupOsc();
	setupKinect();
	setupGraphics();
	mode = Donk::Mode::getInstance();
	// default starting mode
	nextMode = "buzz";
	mode->setMode(nextMode);

}
KdTreeVsBroadphaseDemo::KdTreeVsBroadphaseDemo(hkDemoEnvironment* env)
:	hkDefaultPhysicsDemo(env), 
	m_flattenRays(false),
	m_rand(1337)
{

	{
		m_worldSizeX = 2.0f * hkMath::sqrt(hkReal(m_env->m_cpuMhz));
		m_worldSizeY = 3;
		m_worldSizeZ = m_worldSizeX;
	}

	// Setup the camera and graphics
	{
		// setup the camera
		hkVector4 from(0.0f, m_worldSizeZ*2.f, -m_worldSizeZ);
		hkVector4 to  (0.0f, 0.0f,  0.0f);
		hkVector4 up  (0.0f, 1.0f,  0.0f);
		setupDefaultCameras( env, from, to, up, 1.0f, 5000.0f );
	}


	{
		hkpWorldCinfo cinfo;
		cinfo.m_gravity.setAll(0);
		cinfo.m_broadPhaseWorldAabb.m_max.set( m_worldSizeX,  10.0f*m_worldSizeY,  m_worldSizeZ);
		cinfo.m_broadPhaseWorldAabb.m_min.setNeg4(	cinfo.m_broadPhaseWorldAabb.m_max );	
		cinfo.m_useKdTree = true;
		m_world = new hkpWorld(cinfo);
		m_world->lock();
	}

	{
		hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher());
	}

	//
	// Add a lot of rigid bodies to the world
	//
	{
		hkAabb worldAabb; 
		worldAabb.m_max.set( m_worldSizeX,  10.0f*m_worldSizeY,  m_worldSizeZ);
		worldAabb.m_min.setNeg4( worldAabb.m_max );	

		hkpMotion::MotionType motionType = hkpMotion::MOTION_FIXED;
		KdTreeDemoUtils::createRandomBodies(m_world, worldAabb, numBodies, motionType, &m_rand, m_collidables);

	}


	setupGraphics();
	
	m_world->unlock();
}
Ejemplo n.º 14
0
void VehicleManagerDemo::setUpWorld()
{
	m_tag = 0;

	// Initially "controller" is at (0,0), ie. neither pointing left/right nor up/down.
	m_inputXPosition = 0.0f;
	m_inputYPosition = 0.0f;

	//
	// Setup the camera. Actually overwritten by step function, and when we first add the vehicle.
	//
	{
		hkVector4 from(0.0f, 0.0f, 10.0f);
		hkVector4 to(0.0f, 0.0f, 0.0f);
		hkVector4 up(0.0f, 1.0f, 0.0f);
		setupDefaultCameras( m_env, from, to, up );
	}

	//
	// Create the world.
	//
	{
		hkpWorldCinfo info;
		info.m_collisionTolerance = 0.1f;
		info.m_gravity.set(0.0f, -9.8f, 0.0f);
		info.setBroadPhaseWorldSize(2050.0f) ;
		info.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM);
		info.m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_MULTITHREADED;
		m_world = new hkpWorld( info );
		m_world->lock();

		// Register all agents.
		hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher());
		// Graphics.
		setupGraphics();
	}

	//
	// Create a filter, so that the ray casts of car do not collide with the ragdolls
	//
	{
		hkpGroupFilter* filter = new hkpGroupFilter();
		//filter->disableCollisionsBetween( WHEEL_LAYER, RAGDOLL_LAYER );

		m_world->setCollisionFilter( filter );
		filter->removeReference();
	}

	// Build the landscape to drive on and add it to m_world.
	buildLandscape();

	m_reorientAction = HK_NULL;
	m_world->unlock();
}
Ejemplo n.º 15
0
ZChessCraft::ZChessCraft(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ZChessCraft)
{
    ui->setupUi(this);

    setupChessModel();
    setupGraphics();
    setupChessboard();
    setupChessmen();
    setupComputer();
}
Ejemplo n.º 16
0
void PackfileImportExport::setup()
{
	m_world = new hkpWorld( *m_physicsData->getWorldCinfo() );
	m_world->lock();
	hkpAgentRegisterUtil::registerAllAgents( m_world->getCollisionDispatcher() );
	for ( int i = 0; i < m_physicsData->getPhysicsSystems().getSize(); ++i )
	{
		m_world->addPhysicsSystem( m_physicsData->getPhysicsSystems()[i] );
	}
	setupGraphics();
	m_world->unlock();
}
Ejemplo n.º 17
0
//--------------------------------------------------------------
void testApp::setup(){
	HOLD_COUNT = 200;
	setupGraphics();
	setupVision();
	presenceDetector.setup();
	

	thanksSign.setup();
	lastTimeFinishedRecording = -1000;


	video = new RamVideo();
	video->setup(480, 640, MAX_VIDEO_LENGTH);

	triggerDepth = 100;
	drawDebug = false;
	
	
	minRecordingInterval = 4;
	
	carousel.setVideoFeed(&videoFeed);
	
	
	gui.addToggle("Draw Debug", drawDebug);
	
	gui.addSlider("Count down time", HOLD_COUNT, 80, 350);
	gui.addSlider("Min Time between recordings", minRecordingInterval, 2, 20);
	gui.addSlider("Carousel video duration", carousel.frameDuration, 10, 200);
	gui.addSlider("Carousel inactivity delay", carouselDelay, 0, 5);
	gui.addSlider("Slide time pct", carousel.slideTime, 0.05, 1);
	gui.addTitle("Carousel");
	gui.addSlider("Overlap", carousel.overlap, 0, 260);
	gui.addTitle("Triggers");
	gui.addSlider("Triggers Horizontal", presenceDetector.triggersX, 0, VISION_HEIGHT);
	gui.addSlider("Triggers Vertical", presenceDetector.triggersY, 0, VISION_WIDTH);
	gui.addSlider("Triggers Radius", presenceDetector.triggerRadius, 0, 100);
	gui.addSlider("Trigger Depth", farThreshold, 0, 255);
	gui.addToggle("save all videos", saveAllVideos);
	gui.addToggle("clear all videos", clearAllVideos);
	dots.setup(480, 640);
	gui.setAlignRight(true);
	gui.setAutoSave(true);
	gui.loadFromXML();
	
	recording = false;
	clearAllVideos = false;
	saveAllVideos = false;
	
	//ofSetOrientation(OF_ORIENTATION_90_LEFT);
	
	
}
Ejemplo n.º 18
0
static int engine_init_shaders(struct engine* engine) {
    LOGI("from engine_init_shaders \n");
    
    setupGraphics(engine->width, engine->height);
    AAssetDir* assetDir = AAssetManager_openDir(engine->assetManager, "");
    AAssetDir_rewind(assetDir);
    const char* name=NULL;
    const char* vert=NULL, *frag=NULL;
    while ( (name = AAssetDir_getNextFileName(assetDir)) != NULL)
    {
        if (frag == NULL && NULL != strstr(name, gTagFrag)) //if we haven't found the fragment shader and 'name' is the fragment shader, save it.
            frag = name;
        if (vert == NULL && NULL != strstr(name, gTagVert)) //if we haven't found the vertex shader and the 'name' is the vertex shader, save it.
            vert = name;
        if (!vert && !frag) //if we found both files, we're done
            break;
    }
    //open the shader assets
    AAsset* fragAsset = AAssetManager_open(engine->assetManager, frag, AASSET_MODE_BUFFER);
    if (!fragAsset)
    {
        LOGE(" error opening %s\n", fragAsset);
        return;
    }
    AAsset* vertAsset = AAssetManager_open(engine->assetManager, vert, AASSET_MODE_BUFFER);
    if (!vertAsset)
    {
        LOGE(" error opening %s\n", vertAsset);
        return;
    }
    //access the shader asset buffer in preperation for reading
    const char* fragBuff = (const char*)AAsset_getBuffer(fragAsset);
    const char* vertBuff = (const char*)AAsset_getBuffer(vertAsset);
    
    setupGraphics(engine->width, engine->height); //minimaly initialize client graphics state
    LoadShaders(fragBuff, AAsset_getLength(fragAsset), vertBuff, AAsset_getLength(vertAsset)); //load the shaders
    
    AAssetDir_close(assetDir);
}
Ejemplo n.º 19
0
	Config::Config(KConfig *config, KileInfo *ki, QWidget* parent)
		: KPageDialog(parent),
		  m_config(config),
		  m_ki(ki)
	{
		setWindowTitle(i18n("Configure"));
		setModal(true);
		setObjectName("kileconfiguration");
		setFaceType(Tree);

		m_config->sync();

		// we need a dialog manager
		m_manager = new KConfigDialogManager(this,KileConfig::self());

		KPageWidgetItem* kilePageWidgetItem = addConfigFolder(i18n("Kile"), "kile");
		KPageWidgetItem* latexPageWidgetItem = addConfigFolder(i18n("LaTeX"), "latex-config");
		KPageWidgetItem* toolsPageWidgetItem = addConfigFolder(i18n("Tools"), "system-run");
		KPageWidgetItem* editorPageWidgetItem = addConfigFolder(i18n("Editor"), "accessories-text-editor");

		// setup all configuration pages
		setupGeneralOptions(kilePageWidgetItem);
		setupAppearance(kilePageWidgetItem);
		setupCodeCompletion(kilePageWidgetItem);   // complete configuration (dani)
		setupHelp(kilePageWidgetItem);
		setupScripting(kilePageWidgetItem);
		setupUsermenu(kilePageWidgetItem);
		setupLivePreview(kilePageWidgetItem);

		setupLatex(latexPageWidgetItem);
		setupEnvironment(latexPageWidgetItem);
		setupGraphics(latexPageWidgetItem);
		setupStructure(latexPageWidgetItem);
		setupSymbolView(latexPageWidgetItem);

		setupTools(toolsPageWidgetItem);
		setupQuickPreview(toolsPageWidgetItem);     // QuickPreview (dani)

		setupEditor(editorPageWidgetItem);

		m_configDialogSize = m_config->group("KileConfigDialog");
		KWindowConfig::restoreWindowSize(windowHandle(), m_configDialogSize);

		// setup connections
		//connect(m_manager, SIGNAL(widgetModified()), this, SLOT(slotWidgetModified()));
		connect(this, &KPageDialog::accepted, this, &Config::slotAcceptChanges);
		connect(this, &KPageDialog::accepted, m_manager, &KConfigDialogManager::updateSettings);
		connect(this, &KPageDialog::rejected, this, [=] () {
			m_config->markAsClean();
		});
	}
Ejemplo n.º 20
0
WindChimesDemo::WindChimesDemo(hkDemoEnvironment* env)
:	hkDefaultPhysicsDemo(env),
	m_loader(HK_NULL)
{
	const WindChimesVariant& variant =  g_variants[m_variantId];

	//
	// Create the sound manager.
	//

	//
	// Set up the camera
	//
	{
		hkVector4 from(6.0f, 0.0f, 3.0f);
		hkVector4 to  (0.0f, 0.0f, 0.0f);
		hkVector4 up  (0.0f, 0.0f, 1.0f);
		setupDefaultCameras( env, from, to, up );
	}

	hkString assetFile = hkAssetManagementUtil::getFilePath(variant.m_assetName);
	m_loader = new hkLoader();
	hkRootLevelContainer* container = m_loader->load( assetFile.cString() );
	HK_ASSERT2(0xaefe9356, container != HK_NULL , "Could not load asset");

	hkpPhysicsData* physics = static_cast<hkpPhysicsData*>( container->findObjectByType( hkpPhysicsDataClass.getName() ) );
	HK_ASSERT2(0x245982ae, physics != HK_NULL, "Could not find physics data in root level object" );
	{
		m_world = new hkpWorld( *physics->getWorldCinfo() );

		m_world->lock();

		hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher());

		setupGraphics();
	}

	m_world->addPhysicsSystem( physics->getPhysicsSystems()[0] );

	// There are 5 pipes in the circular chimes asset, called Chime0, Chime1...etc.
	for( int i = 0; i < variant.m_numChimes; i++ )
	{
		hkString chimeName;
		chimeName.printf( "Chime%d", i );
		hkpRigidBody* chime = physics->findRigidBodyByName( chimeName.cString() );
		HK_ASSERT(0x99862353, chime);

		new WindChimesCollisionListener( chime, i % variant.m_numDifferentChimeSizes );
	}
	m_world->unlock();
}
Ejemplo n.º 21
0
void Ship::init() {
	const char gVertexShader[] =
				"attribute vec4 vPosition;\n"
			    "void main() {\n"
			    "  gl_Position = vPosition;\n"
			    "}\n";
	const char gFragmentShader[] =
			    "precision mediump float;\n"
			    "void main() {\n"
			    "  gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
			    "}\n";
	if (!setupGraphics(gVertexShader, gFragmentShader, gProgram, gvPositionHandle))
		LOGE("Ship init error");
}
Ejemplo n.º 22
0
JNIEXPORT void JNICALL Java_jk_j_1JNILib_init(JNIEnv * env, jobject obj, jobject activity, jint width, jint height)
{
	jclass android_content_Context =env->GetObjectClass(activity);

	jmethodID midGetPackageName = env->GetMethodID(android_content_Context, "getPackageName", "()Ljava/lang/String;");

	jstring packageName= (jstring)env->CallObjectMethod(activity, midGetPackageName);
	const char *aa = env->GetStringUTFChars(packageName, NULL);

	if (strcmp(aa, APP_PACKAGE_NAME) != 0)
	{
		hasPermission = false;
	}
    setupGraphics(width, height);
}
hkDemo::Result WorldSnapshotWithContactPointsDemo::stepDemo()
{
	Result r = hkDefaultPhysicsDemo::stepDemo();
	if( r != DEMO_OK )
	{
		return r;
	}

	// The first button in the pad will load the last saved scene
	if( m_env->m_gamePad->wasButtonPressed( HKG_PAD_BUTTON_1 ) )
	{
		hkString filename = hkAssetManagementUtil::getFilePath( SCRATCH_FILE );
		hkIstream in(filename.cString());
		if( in.isOk() )
		{
			cleanupWorld();
			cleanupGraphics();

			hkpWorld::IgnoreForceMultithreadedSimulation ignoreForceMultithreaded;
			m_world = loadWorld(filename.cString(), &m_physicsData, &m_loadedData);

			m_debugViewerNames.pushBack( hkpActiveContactPointViewer::getName() );
			m_debugViewerNames.pushBack( hkpInactiveContactPointViewer::getName() );

			setupGraphics();
		}
		else
		{
			m_env->m_textDisplay->outputText("Please save before attempting to load", 20U, m_env->m_window->getHeight()/2, 0xffffffffU, 60);
		}
	}
	else if (m_env->m_gamePad->wasButtonPressed (HKG_PAD_BUTTON_2) )
	{
		// The second button in the pad will save the current scene
		saveWorld(m_world, SCRATCH_FILE, true);
	}
	else if (m_env->m_gamePad->wasButtonPressed (HKG_PAD_BUTTON_3) )
	{
		// The second button in the pad will save the current scene
		saveWorld(m_world, SCRATCH_FILE, false);
	}

	m_world->lock();
	m_world->updateCollisionFilterOnWorld( HK_UPDATE_FILTER_ON_WORLD_FULL_CHECK, HK_UPDATE_COLLECTION_FILTER_PROCESS_SHAPE_COLLECTIONS);
	m_world->unlock();

	return DEMO_OK;
}
Ejemplo n.º 24
0
DestructibleBridgeDemo::DestructibleBridgeDemo(hkDemoEnvironment* env)
	:	hkDefaultPhysicsDemo(env)
{

	const DestructibleBridgeVariant& variant = g_variants[m_variantId];

	//
	// Setup the camera
	//
	{
		hkVector4 from( 0.0f, 20.0f, -160.0f);
		hkVector4 to  ( 0.0f,  0.0f,    0.0f);
		hkVector4 up  ( 0.0f,  1.0f,    0.0f);
		setupDefaultCameras(env, from, to, up);
	}

	//
	// Create the world
	//
	{
		hkpWorldCinfo worldInfo;
		{
			worldInfo.m_gravity.set(0.0f, -9.81f, 0.0f);
			worldInfo.setBroadPhaseWorldSize(1000.0f);
		}
		m_world = new hkpWorld(worldInfo);
		m_world->lock();

		// Register ALL agents (though some may not be necessary)
		hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher());
		setupGraphics();
	}

	//
	//	Create the break off utility
	//
	{
		m_breakUtil = new hkpBreakOffPartsUtil( m_world, this );
	}

	// create the terrain and the bridge(s)
	setupTerrain();

	// create the airplanes
	setupAirplanes(variant.m_type, variant.m_numPlanes);

	m_world->unlock();
}
Ejemplo n.º 25
0
int main(int argc, char *argv[])
{
	ESContext esContext;
	UserData  userData;

	esInitContext(&esContext);
	esContext.userData = &userData;


	esCreateWindow(&esContext, TEXT("Hello Triangle"), 800, 600, ES_WINDOW_RGB);

	setupGraphics(800, 600);

	esRegisterDrawFunc(&esContext, Draw);

	esMainLoop(&esContext);
}
Ejemplo n.º 26
0
    CTest(): spApp(core::IApplication::Create())
    {
        spApp->addTask(core::PTask(new core::CRenderTask(2)));
        spApp->addTask(core::PTask(new core::CGameTask(1)));
        spApp->addTask(core::PTask(new core::CInputTask(0)));

        //инициализация рендера
        setupGraphics();

        //инициализация ввода
        setupInput();


        //инициализация камер
        setupCameras();

        spApp->Run();
    }
Ejemplo n.º 27
0
RobotProjet::RobotProjet(RS232& serialPort):
AbstractRobot(serialPort),
_corp(8),
_roueGauche(sf::Vector2f(26,100)),
_roueDroite(sf::Vector2f(26,100)),
_widget(0)
{
  _corp.setPoint(0, sf::Vector2f(45, 0));
  _corp.setPoint(1, sf::Vector2f(330-45, 0));
  _corp.setPoint(2, sf::Vector2f(330, 45));
  _corp.setPoint(3, sf::Vector2f(330, 330-45));
  _corp.setPoint(4, sf::Vector2f(330-45, 330));
  _corp.setPoint(5, sf::Vector2f(45, 330));
  _corp.setPoint(6, sf::Vector2f(0, 330-45));
  _corp.setPoint(7, sf::Vector2f(0, 45));
  _color= sf::Color(157,172,230,255);
  _texture.loadFromFile("projet_robot.png");
  _corp.setTexture(&_texture,true);
  setupGraphics();
}
Ejemplo n.º 28
0
hkResult BrowseDemo::readAndSetupPackfile(const char* filename)
{
	hkRefPtr<hkResource> res = hkSerializeUtil::load(filename);
	if( res )
	{
		// Keep a handle to the loaded data
		m_packfileData = res;

		// Get the top level object in the file
		m_contents = res->getContents<hkRootLevelContainer>();
		HK_ASSERT2(0xa6451543, m_contents != HK_NULL, "Could not load root level obejct" );

		if( hkpPhysicsData* physicsData = static_cast<hkpPhysicsData*>( m_contents->findObjectByType( hkpPhysicsDataClass.getName() ) ) )
		{
			//HK_ASSERT2(0xa6451544, physicsData != HK_NULL, "Could not find physics data in root level object" );
			//HK_ASSERT2(0xa6451535, physicsData->getWorldCinfo() != HK_NULL, "No physics cinfo in loaded file - cannot create a hkWorld" );
			if( physicsData->getWorldCinfo() )
			{
				// Create a world and add the physics systems to it
				m_world = new hkpWorld( *physicsData->getWorldCinfo() );
				m_world->lock();

				// Register all collision agents
				hkpAgentRegisterUtil::registerAllAgents( m_world->getCollisionDispatcher() );

				// Add all the physics systems to the world
				for ( int i = 0; i < physicsData->getPhysicsSystems().getSize(); ++i )
				{
					m_world->addPhysicsSystem( physicsData->getPhysicsSystems()[i] );
				}

				// Setup graphics - this creates graphics objects for all rigid bodies and phantoms in the world
				setupGraphics();
				m_world->unlock();
			}
		}
	}

	return res ? HK_SUCCESS : HK_FAILURE;
}
Ejemplo n.º 29
0
//-----------------------------------------------------------
// program entry point
//-----------------------------------------------------------
int main( void )
//-----------------------------------------------------------
{
	// setup things
	setupInterrupts();
	setupGraphics();
	resetBall();

	// start main loop
	while( 1 )
	{
		// update game logic
		processLogic();

		// wait for new frame
		swiWaitForVBlank();

		// update graphics
		updateGraphics();
	}
	return 0;
}
Ejemplo n.º 30
0
/**
 * Process the next main command.
 */
static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
    struct engine* engine = (struct engine*)app->userData;
    switch (cmd) {
        case APP_CMD_SAVE_STATE:
            // The system has asked us to save our current state.  Do so.
            engine->app->savedState = malloc(sizeof(struct saved_state));
            *((struct saved_state*)engine->app->savedState) = engine->state;
            engine->app->savedStateSize = sizeof(struct saved_state);
            break;
        case APP_CMD_INIT_WINDOW:
            // The window is being shown, get it ready.
            if (engine->app->window != NULL) {
                engine_init_display(engine);

				setupGraphics(engine->width, engine->height);

				InitSensor();
				
                engine_draw_frame(engine);
            }
            break;
        case APP_CMD_TERM_WINDOW:
            // The window is being hidden or closed, clean it up.
            engine_term_display(engine);
            break;
        case APP_CMD_GAINED_FOCUS:
			//_EnableSensor();
			StartSensor();
			engine->animating = 1;
            break;
        case APP_CMD_LOST_FOCUS:
			//_DisableSensor();
            // Also stop animating.
            engine->animating = 0;
			PauseSensor();
            //engine_draw_frame(engine);
            break;
    }
}