コード例 #1
0
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {

#ifdef __APPLE__
	core = new CocoaCore(view, 640,480,false,false,0,0,90);	  
#else
	core = new SDLCore(view, 640,480,false,false,0,0,90);	  
#endif

	CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);

	PhysicsScene *scene = new PhysicsScene();

	ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 10, 10);
	ground->loadTexture("Resources/green_texture.png");
	scene->addPhysicsChild(ground, PhysicsSceneEntity::SHAPE_PLANE, 0.0);

	for(int i=0; i < 100; i++) {
		ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 0.5,0.5,0.5);
		box->loadTexture("Resources/pink_texture.png");
		box->Roll(-45 + (rand() % 90));
		box->Pitch(-45 + (rand() % 90));		
		box->setPosition(-2 + (rand() % 4), i*0.5, -2 + (rand() % 4));
		scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 1.0);
	}
	
	scene->getDefaultCamera()->setPosition(7,7,7);
	scene->getDefaultCamera()->lookAt(Vector3(0,0,0));
	
}
コード例 #2
0
ファイル: wrapClasses.cpp プロジェクト: TheGreenBox/helium
ProGameObject::ProGameObject( P::Core* _core )
    : HeliumGameCore( _core ) 
{
    CoreServices::getInstance()->getResourceManager()->addArchive(g_helium_resource_path+"/default.pak");
    CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
    
    keyboardInput->addEventHandler( P::KEY_1, new AddDice());
    keyboardInput->addEventHandler( P::KEY_2, new AddBoll());
    keyboardInput->addEventHandler( P::KEY_3, new AddBarrel());

    keyboardInput->addEventHandler( P::KEY_d, new YCameraMove());
    keyboardInput->addEventHandler( P::KEY_a, new YNegativeCameraMove());
    keyboardInput->addEventHandler( P::KEY_w, new XCameraMove());
    keyboardInput->addEventHandler( P::KEY_s, new XNegativeCameraMove());
    
    objectWorld.getEngineScenePt()->getDefaultCamera()->setPosition(17,17,17);
	objectWorld.getEngineScenePt()->getDefaultCamera()->lookAt(Vector3(0,0,0));

	ScenePrimitive* ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 16, 16);
	ground->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	objectWorld.getEngineScenePt()->addPhysicsChild(ground, PhysicsSceneEntity::SHAPE_PLANE, 0.0);
    
    ScenePrimitive* wall = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 16, 4);
	wall->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	wall->setPosition( 0, 2, 8 );
	objectWorld.getEngineScenePt()->addPhysicsChild(wall, PhysicsSceneEntity::SHAPE_PLANE, 0.0);
    
    wall = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 16, 4);
	wall->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	wall->setPosition( 0, 2, -8 );
	objectWorld.getEngineScenePt()->addPhysicsChild(wall, PhysicsSceneEntity::SHAPE_PLANE, 0.0);

    wall = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 16, 4);
	wall->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	wall->setYaw( 90 );
	wall->setPosition( 8, 2, 0 );
	objectWorld.getEngineScenePt()->addPhysicsChild(wall, PhysicsSceneEntity::SHAPE_PLANE, 0.0);

    wall = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 16, 4);
	wall->loadTexture(g_helium_resource_path + "/simple_stone_texture.png");
	wall->setYaw( 90 );
	wall->setPosition( -8, 2, 0 );
	objectWorld.getEngineScenePt()->addPhysicsChild(wall, PhysicsSceneEntity::SHAPE_PLANE, 0.0);
    
    HeliumExitScreenButton exitBt(this);
    this->getScreenWorldPt()->addObject( &exitBt );
}
コード例 #3
0
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {

	core = new POLYCODE_CORE(view, 640,480,false,false,0,0,90);

	CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);

	Scene *scene = new Scene();
	ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 5,5);
	ground->loadTexture("Resources/green_texture.png");
	scene->addEntity(ground);

	ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 1,1,1);
	box->loadTexture("Resources/pink_texture.png");
	box->setPosition(0.0, 0.5, 0.0);
	scene->addEntity(box);
	
	scene->getDefaultCamera()->setPosition(7,7,7);
	scene->getDefaultCamera()->lookAt(Vector3(0,0,0));

}
コード例 #4
0
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) {

#ifdef __APPLE__
	core = new CocoaCore(view, 640,480,false,0,90);	  
#else
	core = new SDLCore(view, 640,480,false,0,90);	  
#endif

	CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);

	Screen *hud = new Screen();
	ScreenLabel *label = new ScreenLabel("Click on a shape to select it.", 16);
	hud->addChild(label);	

	scene = new CollisionScene();

	ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 10, 10);
	ground->loadTexture("Resources/green_texture.png");
	scene->addEntity(ground);

	box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 1,1,1);
	box->loadTexture("Resources/pink_texture.png");
	box->setPosition(0,1,0);
	scene->addCollisionChild(box, CollisionSceneEntity::SHAPE_MESH);

	box = new ScenePrimitive(ScenePrimitive::TYPE_CONE, 1,1,10);
	box->loadTexture("Resources/pink_texture.png");
	box->setPosition(1,1,2);
	scene->addCollisionChild(box, CollisionSceneEntity::SHAPE_CONE);

	box = new ScenePrimitive(ScenePrimitive::TYPE_CYLINDER, 2,0.5,10);
	box->loadTexture("Resources/pink_texture.png");
	box->setPosition(2,1,-1);
	scene->addCollisionChild(box, CollisionSceneEntity::SHAPE_CYLINDER);

	
	scene->getDefaultCamera()->setPosition(7,7,7);
	scene->getDefaultCamera()->lookAt(Vector3(0,0,0));
	core->getInput()->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);	
	
	lastEntity = NULL;
}
コード例 #5
0
ファイル: HelloPolycodeApp.cpp プロジェクト: Sarcasm/Polycode
HelloPolycodeApp::HelloPolycodeApp(PolycodeView *view) : EventHandler() {

    core = new POLYCODE_CORE(view, 640,480,false,false,0,0,90);

    CoreServices::getInstance()->getResourceManager()->addArchive("Resources/default.pak");
    CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);

    Screen *hud = new Screen();

    onGroundLabel = new ScreenLabel("Arrow keys to control, spacebar to brake, press R to reset car", 16);
    hud->addChild(onGroundLabel);

    scene = new PhysicsScene();

    ScenePrimitive *ground = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 30, 30);
    ground->loadTexture("Resources/green_texture.png");
    scene->addPhysicsChild(ground, PhysicsSceneEntity::SHAPE_PLANE, 0.0);

    // Some obstacles
    ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 4,4,6);
    box->setPitch(25.0);
    box->setPosition(7,-1.05, 0.0);
    box->setColor(0.5,0.5,1.0,1.0);
    box->loadTexture("Resources/green_texture.png");
    scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 0.0);

    box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 4,4,6);
    box->setPitch(25.0);
    box->setPosition(-7,-1.05, 0.0);
    box->setColor(0.5,0.5,1.0,1.0);
    box->loadTexture("Resources/green_texture.png");
    scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 0.0);

    box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 20,2,5);
    box->setPosition(0.0,1.0, -4.3);
    box->setColor(0.5,0.5,1.0,1.0);
    box->loadTexture("Resources/green_texture.png");
    scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 0.0);

    for(int i=0; i < 10; i++) {
        ScenePrimitive *box = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 0.7,0.7,0.7);
        box->loadTexture("Resources/pink_texture.png");
        box->Roll(-45 + (rand() % 90));
        box->Pitch(-45 + (rand() % 90));
        box->setPosition(-3 + (rand() % 6), 2 + i*0.5, -5 + (rand() % 3));
        scene->addPhysicsChild(box, PhysicsSceneEntity::SHAPE_BOX, 1.0);
    }

    // The vehicle
    vehicle = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 1.0,0.5,2.0);
    vehicle->loadTexture("Resources/pink_texture.png");
    vehicle->setColor(1.0, 1.0, 0.0, 1.0);
    vehicle->setPosition(6,1,5);
    vehicleController = scene->addVehicleChild(vehicle, 5.0, 1.0);

    ScenePrimitive *wheel = new ScenePrimitive(ScenePrimitive::TYPE_SPHERE, 0.3, 10, 10);
    wheel->loadTexture("Resources/pink_texture.png");
    wheel->setColor(0.0, 1.0, 0.0, 1.0);
    vehicleController->addWheel(wheel, Vector3(0.6,0,-0.5), Vector3(0,-1,0), Vector3(-1,0,0), 0.2,  0.3, true);
    scene->addEntity(wheel);

    wheel = new ScenePrimitive(ScenePrimitive::TYPE_SPHERE, 0.3, 10, 10);
    wheel->loadTexture("Resources/pink_texture.png");
    wheel->setColor(0.0, 1.0, 0.0, 1.0);
    vehicleController->addWheel(wheel, Vector3(-0.6,0,-0.5), Vector3(0,-1,0), Vector3(-1,0,0), 0.2,  0.3, true);
    scene->addEntity(wheel);

    wheel = new ScenePrimitive(ScenePrimitive::TYPE_SPHERE, 0.3, 10, 10);
    wheel->loadTexture("Resources/pink_texture.png");
    wheel->setColor(0.0, 1.0, 0.0, 1.0);
    vehicleController->addWheel(wheel, Vector3(0.6,0,0.5), Vector3(0,-1,0), Vector3(-1,0,0), 0.2,  0.3, false);
    scene->addEntity(wheel);

    wheel = new ScenePrimitive(ScenePrimitive::TYPE_SPHERE, 0.3, 10, 10);
    wheel->loadTexture("Resources/pink_texture.png");
    wheel->setColor(0.0, 1.0, 0.0, 1.0);
    vehicleController->addWheel(wheel, Vector3(-0.6,0,0.5), Vector3(0,-1,0), Vector3(-1,0,0), 0.2,  0.3, false);
    scene->addEntity(wheel);

    steeringValue = 0;
    engineForce = 0;
    breaking = false;

    testBox = new ScenePrimitive(ScenePrimitive::TYPE_BOX, 4, 4, 4);
    testBox->loadTexture("Resources/pink_texture.png");
    testBox->setColor(0.3,0.5, 1.0,0.4);
    testBox->setPosition(-5,2,7);
    scene->addCollisionChild(testBox, PhysicsSceneEntity::SHAPE_BOX);


    scene->getDefaultCamera()->setPosition(16,16,16);
    scene->getDefaultCamera()->lookAt(Vector3(0,0,0));

    core->getInput()->addEventListener(this, InputEvent::EVENT_KEYDOWN);
    core->getInput()->addEventListener(this, InputEvent::EVENT_KEYUP);
}
コード例 #6
0
ファイル: PolyGenericScene.cpp プロジェクト: aaajiao/Polycode
void GenericScene::addGrid(String gridTexture) {
	ScenePrimitive *gridMesh = new ScenePrimitive(ScenePrimitive::TYPE_PLANE, 20,20,0);
	gridMesh->loadTexture(gridTexture);
	gridMesh->setPitch(-90.0f);
	addEntity(gridMesh);
}