コード例 #1
0
ファイル: driver.c プロジェクト: khongton/Raycaster
int main() {
   /* Debugging Code */ 
   //double minX = 0.05859357, maxX = 0.44921857;
   //double minY = 2.03125, maxY = 2.421875;
   //int width = 20, height = 20;

   double minX = -10, maxX = 10, minY = -7.5, maxY = 7.5;
   int width = 512, height = 384;
   Canvas canvas;
   InitCanvas(&canvas, minX, maxX, minY, maxY, width, height);

   Point eye = CreatePoint(0.0, 0.0, -14.0);
   Point blueSphere = CreatePoint(1.0, 1.0, 0.0);
   Point redSphere = CreatePoint(0.5, 1.5, -3.0);
   Point lightPoint = CreatePoint(-100.0, 100.0, -100.0);

   Color blue = CreateColor(0.0, 0.0, 1.0);
   Color red = CreateColor(1.0, 0.0, 0.0);
   Color ambient = CreateColor(1.0, 1.0, 1.0);
   Color lightColor = CreateColor(1.5, 1.5, 1.5);
   
   Finish largeFinish = CreateFinish(0.2, 0.4, 0.5, 0.05);
   Finish smallFinish = CreateFinish(0.4, 0.4, 0.5, 0.05);

   Light light = CreateLight(lightPoint, lightColor);
   Sphere spheres[2];
   spheres[0] = CreateSphere(blueSphere, 2.0, blue, largeFinish);
   spheres[1] = CreateSphere(redSphere, 0.5, red, smallFinish);
   
   castAllRays(&canvas, eye, spheres, ambient, light, 2);
   return 0;
}
コード例 #2
0
static int Lua_CreateLight( lua_State* l )
{
    LightWorld* world = CheckLightWorldFromLua(l, 1);

    static const char* lightTypes[] =
    {
        "global",
        "point",
        NULL
    };

    const LightType type = (LightType)luaL_checkoption(l, 2, NULL, lightTypes);

    Light* light = CreateLight(world, type);
    if(light)
    {
        PushPointerToLua(l, light);
        ReferenceLight(light);
        return 1;
    }
    else
    {
        return luaL_error(l, "Can't create more lights.");
    }
}
コード例 #3
0
ファイル: C4Projectile.cpp プロジェクト: Xydrel/Infected
void CC4Projectile::SetParams(const SProjectileDesc& projectileDesc)
{
	if(CGameRules* pGameRules = g_pGame->GetGameRules())
	{
		if(projectileDesc.ownerId) //Can be 0 for late joiners
		{
			m_teamId = pGameRules->GetTeam(projectileDesc.ownerId);

			// if this is a team game, record which team placed this claymore...
			if(gEnv->bServer)
			{
				pGameRules->SetTeam(m_teamId, GetEntityId());
			}

			if(!gEnv->IsDedicated())
			{
				const EntityId clientId = g_pGame->GetIGameFramework()->GetClientActorId();
				int localPlayerTeam = pGameRules->GetTeam( clientId );
				m_OnSameTeam = m_teamId ? m_teamId == localPlayerTeam : clientId == projectileDesc.ownerId;

				if(gEnv->bServer)
				{
					CreateLight();
				}

				if(gEnv->bMultiplayer)
				{
					SetupUIIcon();
				}
			}
		}
	}
	
	CProjectile::SetParams(projectileDesc);
}
コード例 #4
0
extern "C" void Render()
{
    //RenderGradientBackground();
    CreateLight();
    SetupRenderState();

    world.frame++;

    if (world.isTextureMode && world.nextTextureTime>0 && (world.frame % world.nextTextureTime) == 0)
        LoadTexture();

    if (world.frame > world.nextEffectTime)
    {
        if ((rand() % 3)==0)
            incrementColor();
        //static limit = 0;if (limit++>3)
        world.effectType += 1;//+rand() % (ANIM_MAX-1);
        world.effectType %= world.effectCount;
        effects[world.effectType]->reset();
        world.nextEffectTime = world.frame + effects[world.effectType]->minDuration() +
                               rand() % (effects[world.effectType]->maxDuration() - effects[world.effectType]->minDuration());
    }
    effects[world.effectType]->apply();
    world.waterField->Step();
    world.waterField->Render();
    return;
}
コード例 #5
0
GraphicsManager::GraphicsManager()
{ // Initialises PSGL for to use for drawing and translating, sets up the draw settings
  // then creates the light and HUD.
  InitialisePSGL();
  SetupDraw();
  CreateLight();
  pHUD = new HUD();
} // Constructor()
コード例 #6
0
void Game::Initialise(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight)
{
	//Initialise Input
	m_Input = new Input;
	m_Input->Initialise(hinstance,hwnd,screenWidth,screenHeight);

	//Initialise Graphics
	m_Graphics = new GameRenderer;
	m_Graphics->Initialise(screenWidth, screenHeight, hwnd);


	//Initialise AntTweakBar
	TwInit(TW_DIRECT3D11, m_Graphics->GetDevice());
	TwWindowSize(screenWidth, screenHeight);

	//Create the camera
	m_Camera = new Camera;
	m_Camera->SetPosition(0, 25, -75);

	m_Camera->SetRotation(10, 0, 0);

	//Create the skybox
	m_sky = new Skybox;
	m_sky->Initialise(m_Graphics->GetDevice(), hwnd);
	m_sky->SetPosition(XMFLOAT3(0, 0, 0));

	//Create the ant tweak bar
	m_gameTweakBar = TwNewBar("Water Wave Simulation");
	int barSize[2] = { 200, 680 };
	TwSetParam(m_gameTweakBar, NULL, "size", TW_PARAM_INT32, 2, barSize);

	//Toggle wireframe on/off
	TwAddButton(m_gameTweakBar, "comment1", Callback, m_Graphics, " label='Toggle Wireframe' ");


	//Create the wave manager
	m_waveManager = new WaveManager;
	TwAddButton(m_gameTweakBar, "comment2", NextPreset, m_waveManager, " label='Next Preset' ");
	m_waveManager->Initialise(m_Graphics->GetDevice(), m_Graphics->GetDeviceContext(), m_gameTweakBar);
	
	m_waveManager->CreateWater(XMFLOAT3(-480, 0, -480), m_Graphics->GetDevice(), m_Graphics->GetDeviceContext(), hwnd);

	m_hwnd = hwnd;

	//Create terrain 
	Mesh* terrainMesh = new Mesh;
	terrainMesh->Initialise(m_Graphics->GetDevice(), m_Graphics->GetDeviceContext(), "terrain.txt", "../WaveSim/Data/Textures/sand.tga");
	//Use same mesh for multiple instances
	CreateGameobject(new GameObject, terrainMesh, XMFLOAT3(1500, -10, 2000));
	CreateGameobject(new GameObject, terrainMesh, XMFLOAT3(10, -10, 1000));
	CreateGameobject(new GameObject, terrainMesh, XMFLOAT3(-1000, -10, 0));
	Console::Log("Terrain Initalised...");
	//Create directional light
	CreateLight();
}
コード例 #7
0
ファイル: DLightActor.cpp プロジェクト: RaoMiao/freestyle
void DLightActor::CreateLight( const CStageLightSource& Light_, bool bDynamic_ )
{
	SVector vAtt;
	Light_.GetAttenuation( &vAtt.X, &vAtt.Y, &vAtt.Z );

	DLight Light;
	Light.CreatePoint( Light_.GetLocation(), Light_.GetRange(), Light_.GetDiffuse(), vAtt );
	Light.ActPulse( Light_.GetPulseEnable(), Light_.GetPulseAmplitude(), Light_.GetPulseFrequency() );

	CreateLight( Light, bDynamic_ );

}
コード例 #8
0
void Lighting::buildScene()
{
	// the root of our scenegraph.
	m_rootGroup = new osg::Group;

	// Load the cow model.
	m_rootGroup->addChild( LoadModel().get() );

	m_rootGroup->addChild( CreatePlane().get() );

	m_rootGroup->addChild( CreateLight().get() );
}
コード例 #9
0
ファイル: SecurityCamera.cpp プロジェクト: Arc0re/lithtech
LTBOOL SecurityCamera::InitialUpdate()
{
    SetNextUpdate(0.001f);

    g_pLTServer->GetObjectPos(m_hObject, &m_vPos);

	// Create the light...

	CreateLight();

    return LTTRUE;
}
コード例 #10
0
ファイル: FlashLight.cpp プロジェクト: rickyharis39/nolf2
void CFlashLight::TurnOn()
{
	CreateLight();

	if( m_hLight && !m_bOn )
	{
        m_bOn = LTTRUE;
		g_pCommonLT->SetObjectFlags(m_hLight, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);

		if (UpdateServer())
		{
			CAutoMessage cMsg;
			cMsg.Writeuint8(MID_PLAYER_CLIENTMSG);
			cMsg.Writeuint8(CP_FLASHLIGHT);
			cMsg.Writeuint8(FL_ON);
			g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED);
		}
	}
}
コード例 #11
0
// XBMC has loaded us into memory,
// we should set our core values
// here and load any settings we
// may have from our config file
extern "C" void Create(LPDIRECT3DDEVICE8 pd3dDevice, int iWidth, int iHeight, const char* szScreenSaverName, float ratio)
{
    memset(&world,0,sizeof(WaterSettings));

    strcpy(m_szScrName,szScreenSaverName);
    g_pd3dDevice = pd3dDevice;

    m_iWidth = iWidth;
    m_iHeight = iHeight;

    world.scaleX = 1.0f;
    if ( (ratio * iWidth / iHeight) > 1.5)
        world.scaleX = 1/1.333f;//0.91158f/ratio; widescreen mode
    // Load the settings
    LoadSettings();
    CreateLight();
    LoadEffects();

    if (world.isTextureMode)
    {
        LoadTexture();
        world.effectCount--; //get rid of logo effect
    }

    world.effectType = rand()%world.effectCount;
    //world.effectType = 5;
    world.frame = 0;
    world.nextEffectTime = 0;



    /*
    char buff[100];
    for(int j = 0; j < 15; j++)
    {
      buff[j] = (int)ratio + '0';
      ratio = (ratio - (int)ratio)*10;
    }
    buff[15] = 0;
    ((EffectText*)(effects[6]))->drawString(buff,0.6f,0.6f,1.3f,0.06f,-7.0f,7.8f);*/
    //world.widescreen = (float)iWidth/ (float)iHeight > 1.7f;
}
コード例 #12
0
ファイル: SecurityCamera.cpp プロジェクト: Arc0re/lithtech
LTBOOL SecurityCamera::InitialUpdate()
{
    SetNextUpdate(UPDATE_NEXT_FRAME);

	g_pLTServer->GetObjectPos(m_hObject, &m_vPos);

	// Create the light...

	CreateLight();
	
	// Setup the damage types that affect us...

	DamageFlags nCanDamageFlags = 0;
	m_damage.SetCantDamageFlags( ~nCanDamageFlags );

	nCanDamageFlags = DamageTypeToFlag( DT_BULLET ) | DamageTypeToFlag( DT_EXPLODE );
	m_damage.ClearCantDamageFlags( nCanDamageFlags );

    return LTTRUE;
}
コード例 #13
0
ファイル: EditorScene.cpp プロジェクト: qiomoip/space-express
HRESULT CEditorScene::Init()
{
	if(FAILED(CScene::Init()))
	{
		return E_FAIL;
	}

	if(FAILED(CreateEntity()))
	{
		return E_FAIL;
	}

	if(FAILED(CreateCamera()))
	{
		return E_FAIL;
	}

	if(FAILED(CreateLight()))
	{
		return E_FAIL;
	}
	return S_OK;
}
コード例 #14
0
//
// GenerateBots
//
void GenerateLights(void)
{
	int index = 0;

	for (index = 0; index < MAX_LIGHTS; index++)
	{
		light_ptrs[index] = CreateLight(index);

	} // end of the for 

	// for now only set the first one
	light_ptrs[0]->state = ALIVE_STATE;


	light_ptrs[1]->position[1] = 12.0f;


	light_ptrs[1]->state = ALIVE_STATE;
	light_ptrs[1]->position[0] = -1.0f;
	light_ptrs[1]->position[1] = LIGHT_HEIGHT_1;
	light_ptrs[1]->position[2] = 12.0f;


} // end of the function
コード例 #15
0
int
main(int argc, char *argv[])
{
    const SDL_VideoInfo *info;
    SDL_Surface *screen;
    int w, h;
    Uint8 video_bpp;
    Uint32 videoflags;
    int i, done;
    SDL_Event event;
    SDL_Surface *light;
    int mouse_pressed;
    Uint32 ticks, lastticks;


    /* Initialize SDL */
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
        return (1);
    }

    /* Alpha blending doesn't work well at 8-bit color */
#ifdef _WIN32_WCE
    /* Pocket PC */
    w = 240;
    h = 320;
#else
    w = 640;
    h = 480;
#endif
    info = SDL_GetVideoInfo();
    if (info->vfmt->BitsPerPixel > 8) {
        video_bpp = info->vfmt->BitsPerPixel;
    } else {
        video_bpp = 16;
        fprintf(stderr, "forced 16 bpp mode\n");
    }
    videoflags = SDL_SWSURFACE;
    for (i = 1; argv[i]; ++i) {
        if (strcmp(argv[i], "-bpp") == 0) {
            video_bpp = atoi(argv[++i]);
            if (video_bpp <= 8) {
                video_bpp = 16;
                fprintf(stderr, "forced 16 bpp mode\n");
            }
        } else if (strcmp(argv[i], "-hw") == 0) {
            videoflags |= SDL_HWSURFACE;
        } else if (strcmp(argv[i], "-warp") == 0) {
            videoflags |= SDL_HWPALETTE;
        } else if (strcmp(argv[i], "-width") == 0 && argv[i + 1]) {
            w = atoi(argv[++i]);
        } else if (strcmp(argv[i], "-height") == 0 && argv[i + 1]) {
            h = atoi(argv[++i]);
        } else if (strcmp(argv[i], "-resize") == 0) {
            videoflags |= SDL_RESIZABLE;
        } else if (strcmp(argv[i], "-noframe") == 0) {
            videoflags |= SDL_NOFRAME;
        } else if (strcmp(argv[i], "-fullscreen") == 0) {
            videoflags |= SDL_FULLSCREEN;
        } else {
            fprintf(stderr,
                    "Usage: %s [-width N] [-height N] [-bpp N] [-warp] [-hw] [-fullscreen]\n",
                    argv[0]);
            quit(1);
        }
    }

    /* Set video mode */
    if ((screen = SDL_SetVideoMode(w, h, video_bpp, videoflags)) == NULL) {
        fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
                w, h, video_bpp, SDL_GetError());
        quit(2);
    }
    FillBackground(screen);

    /* Create the light */
    light = CreateLight(82);
    if (light == NULL) {
        quit(1);
    }

    /* Load the sprite */
    if (LoadSprite(screen, "icon.bmp") < 0) {
        SDL_FreeSurface(light);
        quit(1);
    }

    /* Print out information about our surfaces */
    printf("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel);
    if ((screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
        printf("Screen is in video memory\n");
    } else {
        printf("Screen is in system memory\n");
    }
    if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
        printf("Screen has double-buffering enabled\n");
    }
    if ((sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
        printf("Sprite is in video memory\n");
    } else {
        printf("Sprite is in system memory\n");
    }

    /* Run a sample blit to trigger blit acceleration */
    MoveSprite(screen, NULL);
    if ((sprite->flags & SDL_HWACCEL) == SDL_HWACCEL) {
        printf("Sprite blit uses hardware alpha acceleration\n");
    } else {
        printf("Sprite blit dosn't uses hardware alpha acceleration\n");
    }

    /* Set a clipping rectangle to clip the outside edge of the screen */
    {
        SDL_Rect clip;
        clip.x = 32;
        clip.y = 32;
        clip.w = screen->w - (2 * 32);
        clip.h = screen->h - (2 * 32);
        SDL_SetClipRect(screen, &clip);
    }

    /* Wait for a keystroke */
    lastticks = SDL_GetTicks();
    done = 0;
    mouse_pressed = 0;
    while (!done) {
        /* Update the frame -- move the sprite */
        if (mouse_pressed) {
            MoveSprite(screen, light);
            mouse_pressed = 0;
        } else {
            MoveSprite(screen, NULL);
        }

        /* Slow down the loop to 30 frames/second */
        ticks = SDL_GetTicks();
        if ((ticks - lastticks) < FRAME_TICKS) {
#ifdef CHECK_SLEEP_GRANULARITY
            fprintf(stderr, "Sleeping %d ticks\n",
                    FRAME_TICKS - (ticks - lastticks));
#endif
            SDL_Delay(FRAME_TICKS - (ticks - lastticks));
#ifdef CHECK_SLEEP_GRANULARITY
            fprintf(stderr, "Slept %d ticks\n", (SDL_GetTicks() - ticks));
#endif
        }
        lastticks = ticks;

        /* Check for events */
        while (SDL_PollEvent(&event)) {
            switch (event.type) {
            case SDL_VIDEORESIZE:
                screen =
                    SDL_SetVideoMode(event.resize.w, event.resize.h,
                                     video_bpp, videoflags);
                if (screen) {
                    FillBackground(screen);
                }
                break;
                /* Attract sprite while mouse is held down */
            case SDL_MOUSEMOTION:
                if (event.motion.state != 0) {
                    AttractSprite(event.motion.x, event.motion.y);
                    mouse_pressed = 1;
                }
                break;
            case SDL_MOUSEBUTTONDOWN:
                if (event.button.button == 1) {
                    AttractSprite(event.button.x, event.button.y);
                    mouse_pressed = 1;
                } else {
                    SDL_Rect area;

                    area.x = event.button.x - 16;
                    area.y = event.button.y - 16;
                    area.w = 32;
                    area.h = 32;
                    SDL_FillRect(screen, &area,
                                 SDL_MapRGB(screen->format, 0, 0, 0));
                    SDL_UpdateRects(screen, 1, &area);
                }
                break;
            case SDL_KEYDOWN:
                if (event.key.keysym.sym == SDLK_ESCAPE) {
                    done = 1;
                }
                if (event.key.keysym.sym == SDLK_RETURN) {
                    SDL_WM_ToggleFullScreen(screen);
                }
                break;
            case SDL_QUIT:
                done = 1;
                break;
            default:
                break;
            }
        }
    }
    SDL_FreeSurface(light);
    SDL_FreeSurface(sprite);
    SDL_FreeSurface(backing);

    /* Print out some timing information */
    if (flashes > 0) {
        printf("%d alpha blits, ~%4.4f ms per blit\n",
               flashes, (float) flashtime / flashes);
    }

    SDL_Quit();
    return (0);
}
コード例 #16
0
ファイル: ProjectileFX.cpp プロジェクト: Arc0re/lithtech
LTBOOL CProjectileFX::CreateObject(ILTClient* pClientDE)
{
    if (!CSpecialFX::CreateObject(pClientDE) || !m_hServerObject) return LTFALSE;

	CGameSettings* pSettings = g_pInterfaceMgr->GetSettings();
    if (!pSettings) return LTFALSE;

    uint8 nDetailLevel = pSettings->SpecialFXSetting();

    LTVector vPos;
    LTRotation rRot;
	g_pLTClient->GetObjectPos(m_hServerObject, &vPos);
	g_pLTClient->GetObjectRotation(m_hServerObject, &rRot);

	//m_pClientDE->CPrint("Client start pos (%.2f, %.2f, %.2f)", vPos.x, vPos.y, vPos.z);
	//m_fStartTime = m_pClientDE->GetTime();

	if (nDetailLevel != RS_LOW)
	{
		if (m_nFX & PFX_SMOKETRAIL)
		{
			CreateSmokeTrail(vPos, rRot);
		}

		if (m_nFX & PFX_LIGHT)
		{
			CreateLight(vPos, rRot);
		}
	}

	if (m_nFX & PFX_FLARE)
	{
		CreateFlare(vPos, rRot);
	}

	if (m_nFX & PFX_FLYSOUND)
	{
		CreateFlyingSound(vPos, rRot);
	}


	// Do client-side projectiles in multiplayer games...

	if ( g_pClientMultiplayerMgr->IsConnectedToRemoteServer( ))
	{
		// Set the velocity of the "server" object if it is really just a local
		// object...

		if (m_bLocal)
		{
			VEC_COPY(m_vFirePos, vPos);

			m_fStartTime = m_pClientDE->GetTime();

            LTVector vVel, vF;
			vF = rRot.Forward();

			m_vPath = vF;

			// Special case of adjusting the projectile speed...

            LTFLOAT fVel = (LTFLOAT) m_pProjectileFX->nVelocity;
			if (m_bAltFire)
			{
                fVel = (LTFLOAT) m_pProjectileFX->nAltVelocity;
			}

            LTFLOAT fMultiplier = 1.0f;
            if (m_pClientDE->GetSConValueFloat("MissileSpeed", fMultiplier) != LT_NOTFOUND)
			{
				fVel *= fMultiplier;
			}

			vVel = vF * fVel;
			g_pPhysicsLT->SetVelocity(m_hServerObject, &vVel);
		}
	}

    return LTTRUE;
}
コード例 #17
0
LTBOOL CProjectileFX::CreateObject(ILTClient* pClientDE)
{
    if (!CSpecialFX::CreateObject(pClientDE) || !m_hServerObject) return LTFALSE;

	CGameSettings* pSettings = g_pInterfaceMgr->GetSettings();
    if (!pSettings) return LTFALSE;

    uint8 nDetailLevel = pSettings->SpecialFXSetting();

    LTVector vPos;
    LTRotation rRot;
	m_pClientDE->GetObjectPos(m_hServerObject, &vPos);
	m_pClientDE->GetObjectRotation(m_hServerObject, &rRot);

	if (nDetailLevel != RS_LOW)
	{
		if (m_nFX & PFX_SMOKETRAIL)
		{
			CreateSmokeTrail(vPos, rRot);
		}

		if (m_nFX & PFX_LIGHT)
		{
			CreateLight(vPos, rRot);
		}
	}

	if (m_nFX & PFX_FLARE)
	{
		CreateFlare(vPos, rRot);
	}

	if (m_nFX & PFX_FLYSOUND)
	{
		CreateFlyingSound(vPos, rRot);
	}


	// Do client-side projectiles in multiplayer games...

	if (g_pGameClientShell->IsMultiplayerGame())
	{
		// Set the velocity of the "server" object if it is really just a local
		// object...

		if (m_bLocal)
		{
			VEC_COPY(m_vFirePos, vPos);

			m_fStartTime = m_pClientDE->GetTime();

            LTVector vVel, vU, vR, vF;
			m_pClientDE->GetRotationVectors(&rRot, &vU, &vR, &vF);

			VEC_COPY(m_vPath, vF);

			// Special case of adjusting the projectile speed...

            LTFLOAT fVel = (LTFLOAT) m_pProjectileFX->nVelocity;
			if (m_bAltFire)
			{
                fVel = (LTFLOAT) m_pProjectileFX->nAltVelocity;
			}

            LTFLOAT fMultiplier = 1.0f;
            if (m_pClientDE->GetSConValueFloat("MissileSpeed", fMultiplier) != LT_NOTFOUND)
			{
				fVel *= fMultiplier;
			}

			VEC_MULSCALAR(vVel, vF, fVel);
			m_pClientDE->Physics()->SetVelocity(m_hServerObject, &vVel);
		}
	}

    return LTTRUE;
}
コード例 #18
0
ファイル: tunnel_part.c プロジェクト: flure/lack_of_disco
void TunnelPartInit(void)
{
	T_Mesh* mesh;
	int i;
	
	/* 
	 * Initialisation vidéo
	 */ 
	/* Modes video */
	videoSetMode(MODE_5_3D);
	videoSetModeSub(MODE_5_2D);
	lcdMainOnBottom();
	
	vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
	vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
	vramSetBankC(VRAM_C_SUB_BG_0x06200000);
	vramSetBankD(VRAM_D_TEXTURE_SLOT3);
	
	videoBgEnable(DISPLAY_BG0_ACTIVE | DISPLAY_BG2_ACTIVE);
	videoBgEnableSub(DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE);
	
	/* Le BG qui servira pour le tunnel */
	TunnelBgId = bgInitSub(2, BgType_Bmp16, BgSize_B16_256x256, 0, 0);
	TunnelBgPixels = (u16*)bgGetGfxPtr(TunnelBgId);
	bgSetPriority(TunnelBgId, 2); /* Le tunnel en fond */

	/* L'avant plan de l'éléphant */	
	FrontLayerId = bgInit(2, BgType_Bmp8, BgSize_B8_256x256, 8, 0);
	FrontLayerPixels = (u8*)bgGetGfxPtr(FrontLayerId);
	bgSetPriority(FrontLayerId, 0); /* En avant plan */
	decompress(bouleBitmap, FrontLayerPixels, LZ77Vram);
	decompress(boulePal, BG_PALETTE, LZ77Vram); 
	
	bgSetPriority(0, 1); /* La 3D entre les deux */
	
	
	/* Initialisation de la 3D */
    Init3DEngine();
    
	TunnelFxInit(TunnelBgPixels);
	        
    mesh = CreateMesh();
    mesh->display_list = DiscoElephant_mesh;
    mesh->alpha = 31;
    mesh->texturing = TRUE;
    mesh->lighting = TRUE;
    DiscoElephant = CreateObj3D(mesh);
    Scene = CreateScene();
    AddObject(Scene, DiscoElephant);
    
    Scene->lights[0] = CreateLight(floattov10(0), floattov10(0), floattov10(-1), RGB15(16, 0, 01), TRUE);
    Scene->lights[1] = CreateLight(floattov10(0), floattov10(0), floattov10(-1), RGB15(0, 16, 0), TRUE);
    Scene->lights[2] = CreateLight(floattov10(0), floattov10(0), floattov10(-1), RGB15(0, 0, 16), TRUE);
    Scene->lights[3] = CreateLight(floattov10(0), floattov10(0), floattov10(-1), RGB15(16, 16, 0), TRUE);
    
    glClearColor(0, 0, 0, 0);
    
    flare_tex = CreateTextureFromMemory((u8*)flareBitmap, GL_RGBA, 0, 16, 64, TRUE, LZ77Vram);
    
    for(i=0; i<4; i++) {
    	flares[i] = malloc(sizeof(*flares[i]));
    }
    
    flares[0]->position[0] = 0;
    flares[0]->position[1] = 0;
    flares[0]->position[2] = floattof32(-1);
    flares[0]->poly_alpha = 16;
    flares[0]->color = RGB15(31, 0, 0);
    flares[0]->size = floattov16(0.15f);
    flares[0]->texture_id = flare_tex->id;
    flares[0]->poly_id = 5;
    
    flares[1]->position[0] = 0;
    flares[1]->position[1] = 0;
    flares[1]->position[2] = floattof32(-1);
    flares[1]->poly_alpha = 16;
    flares[1]->color = RGB15(0, 31, 0);
    flares[1]->size = floattov16(0.15f);
    flares[1]->texture_id = flare_tex->id;
    flares[1]->poly_id = 6;
    
    flares[2]->position[0] = 0;
    flares[2]->position[1] = 0;
    flares[2]->position[2] = floattof32(-1);
    flares[2]->poly_alpha = 16;
    flares[2]->color = RGB15(0, 0, 31);
    flares[2]->size = floattov16(0.15f);
    flares[2]->texture_id = flare_tex->id;
    flares[2]->poly_id = 6;
    
    flares[3]->position[0] = 0;
    flares[3]->position[1] = 0;
    flares[3]->position[2] = floattof32(-1);
    flares[3]->poly_alpha = 16;
    flares[3]->color = RGB15(31, 31, 0);
    flares[3]->size = floattov16(0.15f);
    flares[3]->texture_id = flare_tex->id;
    flares[3]->poly_id = 7;
    
    tex = CreateTextureFromMemory((u8*)DiscoElephantBitmap, GL_RGB, 0, 16, 64, TRUE, LZ77Vram);
    DiscoElephant->mesh->texture_id = tex->id;
    DiscoElephant->mesh->texturing = TRUE;
    
	/* Initialisation du fade in depuis le blanc */
	REG_MASTER_BRIGHT = (1<<14);
	REG_MASTER_BRIGHT_SUB = REG_MASTER_BRIGHT;
	
	StartFlash(-1000); // pour éviter un flash à la première seconde
	
	glMaterialf(GL_AMBIENT, RGB15(16,16,16));
    glMaterialf(GL_SPECULAR, BIT(15) | RGB15(31,31,31));
	glMaterialShinyness();
}
コード例 #19
0
ファイル: taskbuild.cpp プロジェクト: pol51/colobot
bool CTaskBuild::EventProcess(const Event &event)
{
    Math::Matrix*       mat;
    Math::Vector        pos, dir, speed;
    Math::Point         dim;
    float           a, g, cirSpeed, dist, linSpeed;

    if ( m_engine->GetPause() )  return true;
    if ( event.type != EVENT_FRAME )  return true;
    if ( m_bError )  return false;

    m_time += event.rTime;

    m_progress += event.rTime*m_speed;  // other advance

    if ( m_phase == TBP_TURN )  // preliminary rotation?
    {
        a = m_object->GetAngleY(0);
        g = m_angleY;
        cirSpeed = Math::Direction(a, g)*1.0f;
        if ( cirSpeed >  1.0f )  cirSpeed =  1.0f;
        if ( cirSpeed < -1.0f )  cirSpeed = -1.0f;

        m_physics->SetMotorSpeedZ(cirSpeed);  // turns left/right
        return true;
    }

    if ( m_phase == TBP_MOVE )  // preliminary forward/backward?
    {
        dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0));
        linSpeed = 0.0f;
        if ( dist > 30.0f )  linSpeed =  1.0f;
        if ( dist < 30.0f )  linSpeed = -1.0f;
        m_physics->SetMotorSpeedX(linSpeed);  // forward/backward
        return true;
    }

    if ( m_phase == TBP_RECEDE )  // terminal back?
    {
        m_physics->SetMotorSpeedX(-1.0f);  // back
        return true;
    }

    if ( m_phase == TBP_TAKE )  // takes gun?
    {
        return true;
    }

    if ( m_phase == TBP_PREP )  // prepares?
    {
        return true;
    }

    if ( m_phase == TBP_TERM )  // ends?
    {
        return true;
    }

    if ( !m_bBuild )  // building to build?
    {
        m_bBuild = true;

        pos = m_metal->GetPosition(0);
        a   = m_object->GetAngleY(0);
        if ( !CreateBuilding(pos, a+Math::PI) )
        {
            m_metal->SetLock(false);  // usable again
            m_motion->SetAction(-1);
            m_object->SetObjectParent(14, 0);
            m_object->SetPosition(14, Math::Vector(-1.5f, 0.3f, -1.35f));
            m_object->SetAngleZ(14, Math::PI);
            m_camera->FlushEffect();
            Abort();
            m_bError = true;
            m_displayText->DisplayError(ERR_TOOMANY, m_object->GetPosition(0));
            return false;
        }
        CreateLight();
    }

    pos = m_buildingPos;
    pos.y += m_buildingHeight*m_progress;
    m_building->SetPosition(0, pos);  // the building rises

    m_building->SetZoom(0, m_progress*0.75f+0.25f);
    m_metal->SetZoom(0, 1.0f-m_progress);

    a = (2.0f-2.0f*m_progress);
    if ( a > 1.0f )  a = 1.0f;
    dir.x = (Math::Rand()-0.5f)*a*0.1f;
    dir.z = (Math::Rand()-0.5f)*a*0.1f;
    dir.y = (Math::Rand()-0.5f)*a*0.1f;
    m_building->SetCirVibration(dir);

    if ( !m_bBlack && m_progress >= 0.25f )
    {
        BlackLight();
    }

    if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
    {
        m_lastParticle = m_time;

        pos = m_metal->GetPosition(0);
        speed.x = (Math::Rand()-0.5f)*20.0f;
        speed.z = (Math::Rand()-0.5f)*20.0f;
        speed.y = Math::Rand()*10.0f;
        dim.x = Math::Rand()*6.0f+4.0f;
        dim.y = dim.x;
        m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIRE);

        pos = Math::Vector(0.0f, 0.5f, 0.0f);
        mat = m_object->GetWorldMatrix(14);
        pos = Transform(*mat, pos);
        speed = m_metal->GetPosition(0);
        speed.x += (Math::Rand()-0.5f)*5.0f;
        speed.z += (Math::Rand()-0.5f)*5.0f;
        speed -= pos;
        dim.x = 2.0f;
        dim.y = dim.x;
        m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ);

        if ( Math::Rand() < 0.3f )
        {
            m_sound->Play(SOUND_BUILD, m_object->GetPosition(0), 0.5f, 1.0f*Math::Rand()*1.5f);
        }
    }

    return true;
}
コード例 #20
0
CStdSerialize *RbClassFactory::CreateObject(std::string strClassType, std::string strObjectType, bool bThrowError)
{
	CStdSerialize *lpObject=NULL;

	strClassType = Std_ToUpper(Std_Trim(strClassType));

	if(strClassType == "RIGIDBODY")
		lpObject = CreateRigidBody(strObjectType, bThrowError);
	else if(strClassType == "JOINT")
		lpObject = CreateJoint(strObjectType, bThrowError);
	else if(strClassType == "ORGANISM")
		lpObject = CreateStructure(strObjectType, bThrowError);
	else if(strClassType == "STRUCTURE")
		lpObject = CreateStructure(strObjectType, bThrowError);
	else if(strClassType == "SIMULATOR")
		lpObject = CreateSimulator(strObjectType, bThrowError);
	else if(strClassType == "KEYFRAME")
		lpObject = CreateKeyFrame(strObjectType, bThrowError);
	else if(strClassType == "DATACHART")
		lpObject = CreateDataChart(strObjectType, bThrowError);
	else if(strClassType == "DATACOLUMN")
		lpObject = CreateDataColumn(strObjectType, bThrowError);
	else if(strClassType == "EXTERNALSTIMULUS")
		lpObject = CreateExternalStimulus(strObjectType, bThrowError);
	else if(strClassType == "ADAPTER")
		lpObject = CreateAdapter(strObjectType, bThrowError);
	else if(strClassType == "GAIN")
		lpObject = CreateGain(strObjectType, bThrowError);
	else if(strClassType == "HUDITEM")
		lpObject = CreateHudItem(strObjectType, bThrowError);
	else if(strClassType == "HUD")
		lpObject = CreateHud(strObjectType, bThrowError);
	else if(strClassType == "MATERIAL")
		lpObject = CreateMaterialItem(strObjectType, bThrowError);
	else if(strClassType == "SIMULATIONWINDOW")
		lpObject = CreateWindowItem(strObjectType, bThrowError);
	else if(strClassType == "LIGHT")
		lpObject = CreateLight(strObjectType, bThrowError);
	else if(strClassType == "NEURALMODULE")
		lpObject = CreateNeuralModule(strObjectType, bThrowError);
	else if(strClassType == "CONSTRAINTRELAXATION")
		lpObject = CreateConstraintRelaxation(strObjectType, bThrowError);
	else if(strClassType == "CONSTRAINTFRICTION")
		lpObject = CreateConstraintFriction(strObjectType, bThrowError);
	else if(strClassType == "ROBOTINTERFACE")
		lpObject = CreateRobotInterface(strObjectType, bThrowError);
	else if(strClassType == "ROBOTIOCONTROL")
		lpObject = CreateRobotIOControl(strObjectType, bThrowError);
	else if(strClassType == "ROBOTPARTINTERFACE")
		lpObject = CreateRobotPartInterface(strObjectType, bThrowError);
	else if(strClassType == "REMOTECONTROLLINKAGE")
		lpObject = CreateRemoteControlLinkage(strObjectType, bThrowError);
	else
	{
		lpObject = NULL;
		if(bThrowError)
			THROW_PARAM_ERROR(Std_Err_lInvalidClassType, Std_Err_strInvalidClassType, "ClassType", strClassType);
	}

	return lpObject;
}
コード例 #21
-1
ファイル: C4Projectile.cpp プロジェクト: Xydrel/Infected
//------------------------------------------
bool CC4Projectile::Init(IGameObject *pGameObject)
{
	bool ok = CProjectile::Init(pGameObject);

	// C4 should always be saved (unlike other projectiles)
	IEntity* pEntity = GetEntity();
	pEntity->SetFlags(pEntity->GetFlags() & ~ENTITY_FLAG_NO_SAVE);

	if(!gEnv->bServer)
	{
		CreateLight();
	}

	if(gEnv->bMultiplayer)
	{
		CGameRules *pGameRules = g_pGame->GetGameRules();
		pGameRules->RegisterTeamChangedListener(this);
		pGameRules->RegisterClientConnectionListener(this);
	}

	return ok;
}