示例#1
0
void TTscene::Initialize(void)
{
	m_pCam = new FreeCamera();
	AddSceneObject(m_pCam);
	SetActiveCamera(m_pCam->GetComponent<CameraComponent>());
	AddSceneObject(new Object3D(_T("Resources/goblin.ttmesh")));
	AddSceneObject(new Object3DStatic(_T("Resources/Models/environment.ttmesh")));
	AddSceneObject(new Skybox());
	
	auto pBlurMat = new BlurMaterial();
	pBlurMat->LoadEffect();
	AddPostProcessingEffect(new PostProcessingEffect(pBlurMat), 0);
	
	//AddSceneObject(new ParticleSystem() );
	AddSceneObject( new Terrain( tt::Vector3(100,30,100), 6, _T("Resources/Textures/HeightMap_128x128x16.raw") ) );

	MyServiceLocator::GetInstance()->GetService<IInputService>()->AddInputAction(InputActionId::ToggleVSync, 'V', KeyState::Pressed);

	g_pScript->Initialize();
}
示例#2
0
int DisconnectAllCameras()
{
    for (int i=0;i<ccd_ncam;i++)
    {
        err = SetActiveCamera(i);
    
        err = SBIGUnivDrvCommand(CC_CLOSE_DEVICE, NULL, NULL);
        if (err != CE_NO_ERROR )
        {
            fprintf (stderr, "SBIG close device error\n");
        }
       
        err = SBIGUnivDrvCommand(CC_CLOSE_DRIVER, NULL, NULL);
        if ( err != CE_NO_ERROR ) 
        {
            fprintf (stderr, "SBIG close driver error\n");
        } 
    }

    return(0); 
}
示例#3
0
void PrepareCamera(Camera * cam, const Rect & viewport, const Vec2i & projectionCenter) {
	
	SetActiveCamera(cam);
	
	g_preparedCamera.m_worldToView = glm::translate(toRotationMatrix(cam->angle), -cam->m_pos);
	GRenderer->SetViewMatrix(g_preparedCamera.m_worldToView);
	
	const Vec2f center = Vec2f(projectionCenter - viewport.topLeft());
	g_preparedCamera.m_viewToClip = createProjectionMatrix(Vec2f(viewport.size()), center, cam);
	GRenderer->SetProjectionMatrix(g_preparedCamera.m_viewToClip);
	
	// Change coordinate system from [-1, 1] x [-1, 1] to [0, width] x [0, height] and flip the y axis
	glm::mat4x4 ndcToScreen(1);
	ndcToScreen = glm::scale(ndcToScreen, Vec3f(Vec2f(viewport.size()) / 2.f, 1.f));
	ndcToScreen = glm::translate(ndcToScreen, Vec3f(1.f, 1.f, 0.f));
	ndcToScreen = glm::scale(ndcToScreen, Vec3f(1.f, -1.f, 1.f));
	g_preparedCamera.m_viewToScreen = ndcToScreen * g_preparedCamera.m_viewToClip;
	
	g_preparedCamera.m_worldToScreen = g_preparedCamera.m_viewToScreen * g_preparedCamera.m_worldToView;
	
	GRenderer->SetViewport(viewport);
	
}
 void Graphics::SetDefaultCamera()
 {
     SetActiveCamera(m_DefaultCamera);
 }
示例#5
0
void ARX_INTERFACE_ManageOpenedBook_Finish()
{

	Vec3f pos = Vec3f(0.f, 0.f, 2100.f);
	Anglef angle = Anglef::ZERO;
	
	EERIE_LIGHT * light = lightHandleGet(torchLightHandle);
	
	EERIE_LIGHT tl = *light;
	
	light->pos = Vec3f(500.f, -1960.f, 1590.f);
	light->exist = 1;
	light->rgb = Color3f(0.6f, 0.7f, 0.9f);
	light->intensity  = 1.8f;
	light->fallstart=4520.f;
	light->fallend = light->fallstart + 600.f;
	RecalcLight(light);
	
	EERIE_CAMERA * oldcam = ACTIVECAM;
	
	PDL[0] = light;
	TOTPDL=1;
	
	Vec2i tmpPos = Vec2i_ZERO;
	
	for(size_t i = 0; i < RUNE_COUNT; i++) {
		if(!gui::necklace.runes[i])
			continue;
		
		EERIE_3DOBJ * rune = gui::necklace.runes[i];
		
		bookcam.center.x = (382 + tmpPos.x * 45 + BOOKDEC.x) * g_sizeRatio.x;
		bookcam.center.y = (100 + tmpPos.y * 64 + BOOKDEC.y) * g_sizeRatio.y;
		
		SetActiveCamera(&bookcam);
		PrepareCamera(&bookcam, g_size);
		
		// First draw the lace
		angle.setPitch(0.f);
		
		if(player.hasRune((Rune)i)) {
			
			TransformInfo t1(pos, glm::toQuat(toRotationMatrix(angle)));
			DrawEERIEInter(gui::necklace.lacet, t1, NULL);
			
			if(rune->angle.getPitch() != 0.f) {
				if(rune->angle.getPitch() > 300.f)
					rune->angle.setPitch(300.f);
				
				angle.setPitch(std::sin(arxtime.get_updated() * (1.0f / 200)) * rune->angle.getPitch() * (1.0f / 40));
			}
			
			rune->angle.setPitch(rune->angle.getPitch() - framedelay * 0.2f);
			
			if(rune->angle.getPitch() < 0.f)
				rune->angle.setPitch(0.f);
			
			GRenderer->SetRenderState(Renderer::DepthWrite, true);
			GRenderer->SetRenderState(Renderer::AlphaBlending, false);
			
			// Now draw the rune
			TransformInfo t2(pos, glm::toQuat(toRotationMatrix(angle)));
			DrawEERIEInter(rune, t2, NULL);
			
			EERIE_2D_BBOX runeBox;
			UpdateBbox2d(*rune, runeBox);
			
			PopAllTriangleList();
			
			tmpPos.x++;
			
			if(tmpPos.x > 4) {
				tmpPos.x = 0;
				tmpPos.y++;
			}
			
			const Rect runeMouseTestRect(
			runeBox.min.x,
			runeBox.min.y,
			runeBox.max.x,
			runeBox.max.y
			);
			
			// Checks for Mouse floating over a rune...
			if(runeMouseTestRect.contains(Vec2i(DANAEMouse))) {
				long r=0;
				
				for(size_t j = 0; j < rune->facelist.size(); j++) {
					float n = PtIn2DPolyProj(rune, &rune->facelist[j], (float)DANAEMouse.x, (float)DANAEMouse.y);
					
					if(n!=0.f) {
						r=1;
						break;
					}
				}
				
				if(r) {
					GRenderer->SetRenderState(Renderer::AlphaBlending, true);
					GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
					
					TransformInfo t(pos, glm::toQuat(toRotationMatrix(angle)));
					DrawEERIEInter(rune, t, NULL);
					
					rune->angle.setPitch(rune->angle.getPitch() + framedelay*2.f);
					
					PopAllTriangleList();
					
					GRenderer->SetRenderState(Renderer::AlphaBlending, false);
					
					SpecialCursor=CURSOR_INTERACTION_ON;
					
					if(eeMouseDown1())
						if((size_t)LastRune != i) {
							PlayerBookDrawRune((Rune)i);
						}
						
						LastRune=i;
				}
			}
		}
	}
	
	GRenderer->SetCulling(Renderer::CullCCW);
	
	LastRune=-1;
	
	*light = tl;
	
	SetActiveCamera(oldcam);
	PrepareCamera(oldcam, g_size);
}
示例#6
0
int main(int argc, char *argv[]) {

    int arg=1;
    int sbig_type = NO_CAMERA;
    int info_mode = 0;
    int verbose = 0;
    char name[MAX_STRING] = "";
    char ra[MAX_STRING] = "";
    char dec[MAX_STRING] = "";
    char alt[MAX_STRING] = "";
    char az[MAX_STRING] = "";
    char imtype[8];
    int phase;
    float exptime;
    int err;

    /* Set an interrupt handler to trap Ctr-C nicely */
    if(signal(SIGINT, SIG_IGN) != SIG_IGN)
		signal(SIGINT, InterruptHandler);

    /*  set lockfile from the outset */
    get_lock();
    store_pid_in_lockfile();


    /* parse args */
    if (argc < 3) {
        error_exit(usage);
    };
    while (arg < argc - 2) 
    {
        switch (argv[arg++][1]) {
            case 'v':
                verbose = 1;
                SetVerbosity(verbose);
                break;
            case 'n':
                sscanf(argv[arg++], "%s", name);
                break;
             case 'r':
                sscanf(argv[arg++], "%s", ra);
                break;
             case 'd':
                sscanf(argv[arg++], "%s", dec);
                break;
             case 'a':
                sscanf(argv[arg++], "%s", alt);
                break;
             case 'z':
                sscanf(argv[arg++], "%s", az);
                break;
             default:
                error_exit(usage);
                break;
        }
    }
    sscanf(argv[arg++],"%s",imtype);
    sscanf(argv[arg++],"%f",&exptime);

    // Determine what kind of image to take 
    switch(value_from_imagetype_key(imtype)) {
        case DARK:   ccd_type=DARK;  if (verbose) printf("Taking dark frame.\n");  break;
        case LIGHT:  ccd_type=LIGHT; if (verbose) printf("Taking light frame.\n"); break;
        case BIAS:   ccd_type=BIAS;  if (verbose) printf("Taking bias frame.\n");  break;
        case FLAT:   ccd_type=FLAT;  if (verbose) printf("Taking flat frame.\n");  break;
        case BADKEY: fprintf(stderr,"Unknown image type %s\n",imtype); return(1); break;
    }
    fflush(stdout);

    CountCameras();
    if (ccd_ncam < 1){
	fprintf(stderr,"Found 0 cameras\n");
        return(1);
    }

    InitializeAllCameras();
    store_timestamped_note_in_lockfile("Started");
    store_directory_in_lockfile();
    char myline[128];
    sprintf(myline,"Exptime: %5.1f\n",exptime);
    store_note_in_lockfile(myline);


    // Start integrations going on each of the cameras one by one.
    for (int cam_num = 0; cam_num <ccd_ncam; cam_num++)
    {
        err = SetActiveCamera(cam_num);
        ccd_image_data[cam_num] = 
            (unsigned short *) malloc(ccd_image_width*ccd_image_height*sizeof(unsigned short));
        phase = 0;
        err = CaptureImage(&phase,ccd_image_data[cam_num],ccd_type,exptime,FALSE,0,0,0,0);
    }

    // Wait until the data is ready. I'm intentionally playing this safe by
    // making sure I wait at least 1s before trying to read out the data.
    // This is something I will have to look into if I ever use this for
    // fast focusing.
    int nsec = (int) exptime + 1;
    int count = 0;
    for (int i=0; i<=nsec;i++)
    {
        if(nsec > 3 && nsec < 10){ 
            load_bar(count++,nsec,3,30);
        }
        else if (nsec >  10 && nsec < 100){
            load_bar(count++,nsec,(int)(nsec/2),30);
        }
        else if (nsec >  100){
            load_bar(count++,nsec,(int)(nsec/3),30);
        }
        sleep(1);
    }

    // The cameras are ready to be read out. We once again cycle over each camera and 
    // save the data.
    
    for (int cam_num = 0; cam_num <ccd_ncam; cam_num++)
    {
        char infoline[128];
        phase = 1;
        err = SetActiveCamera(cam_num); 
        fflush(stderr);
        err = CaptureImage(&phase,ccd_image_data[cam_num],ccd_type,exptime,FALSE,0,0,0,0);

        // Print out some pixel values to let the user check data integrity
        if (verbose)
            printf("Some pixel values: %u %u %d\n",
                    *(ccd_image_data[cam_num] + 10000), 
                    *(ccd_image_data[cam_num] + 15000), 
                    *(ccd_image_data[cam_num]+20000)); 

        // Figure out what to call the new file
        char *newname;
        newname = (char *)malloc(MAX_STRING*sizeof(char));
        new_filename(ccd_serial_number,imtype,newname);    

        // Save as a FITS file
        GetCameraTemperature();
        double temperature = ccd_camera_info[ActiveCamera()].temperature;
        int filterNumber = 0;
        if (IsCameraAnST402ME())
            filterNumber = FilterWheelPosition();
        write_fits(newname, ccd_image_width, ccd_image_height, ccd_image_data[cam_num], 
                   exptime,imtype,temperature,filterNumber,ccd_serial_number, name,
                   ra,dec,alt,az);
        fprintf(stderr,"Saved %s \n",newname);
        sprintf(infoline,"Camera %d wrote: %s\n",cam_num,newname);
        store_note_in_lockfile(infoline);
        free(ccd_image_data[cam_num]);
        free(newname);

    }

    DisconnectAllCameras();
    release_lock();

    store_timestamped_note_in_lockfile("Completed");

    // Release the lock file
    release_lock();

    // Ring bell to wake up the astronomer
    if (verbose)
    	printf("Camera(s) opened and closed successfully.\n");
    putchar('\a'); putchar('\a'); putchar('\a');

    return(0);

}
示例#7
0
void AddFlare(const Vec2s & pos, float sm, short typ, Entity * io, bool bookDraw) {
	
	int oldest = 0;
	size_t i;
	for(i = 0; i < MAX_FLARES; i++) {
		if(!magicFlares[i].exist) {
			break;
		}
		if(magicFlares[i].tolive < magicFlares[oldest].tolive) {
			oldest = i;
		}
	}
	if(i >= MAX_FLARES) {
		removeFlare(magicFlares[oldest]);
		i = oldest;
	}

	FLARES * fl = &magicFlares[i];
	fl->exist = 1;
	flarenum++;

	if(!bookDraw)
		fl->bDrawBitmap = 0;
	else
		fl->bDrawBitmap = 1;

	fl->io = io;
	if(io) {
		fl->flags = 1;
		io->flarecount++;
	} else {
		fl->flags = 0;
	}

	fl->pos.x = float(pos.x) - rnd() * 4.f;
	fl->pos.y = float(pos.y) - rnd() * 4.f - 50.f;
	fl->tv.rhw = fl->v.rhw = 1.f;

	if(!bookDraw) {
		EERIE_CAMERA ka = *Kam;
		ka.angle = Anglef(360.f, 360.f, 360.f) - ka.angle;
		EERIE_CAMERA * oldcam = ACTIVECAM;
		SetActiveCamera(&ka);
		PrepareCamera(&ka, g_size);
		fl->v.p += ka.orgTrans.pos;
		EE_RTP(fl->tv.p, &fl->v);
		fl->v.p += ka.orgTrans.pos;

		float vx = -(fl->pos.x - subj.center.x) * 0.2173913f;
		float vy = (fl->pos.y - subj.center.y) * 0.1515151515151515f;
		if(io) {
			fl->v.p = io->pos;
			fl->v.p += angleToVectorXZ(io->angle.getPitch() + vx) * 100.f;
			fl->v.p.y += std::sin(glm::radians(MAKEANGLE(io->angle.getYaw() + vy))) * 100.f - 150.f;
		} else {
			fl->v.p.x = 1.0f  * float(pos.x - (g_size.width()  / 2)) * 156.f / (640.f * g_sizeRatio.y);
			fl->v.p.y = 0.75f * float(pos.y - (g_size.height() / 2)) * 156.f / (480.f * g_sizeRatio.y);
			fl->v.p.z = 75.f;
			ka = *oldcam;
			SetActiveCamera(&ka);
			PrepareCamera(&ka, g_size);
			float temp = (fl->v.p.y * -ka.orgTrans.xsin) + (fl->v.p.z * ka.orgTrans.xcos);
			fl->v.p.y = (fl->v.p.y * ka.orgTrans.xcos) - (-fl->v.p.z * ka.orgTrans.xsin);
			fl->v.p.z = (temp * ka.orgTrans.ycos) - (-fl->v.p.x * ka.orgTrans.ysin);
			fl->v.p.x = (temp * -ka.orgTrans.ysin) + (fl->v.p.x * ka.orgTrans.ycos);
			fl->v.p += oldcam->orgTrans.pos;
		}
		fl->tv.p = fl->v.p;
		SetActiveCamera(oldcam);
		PrepareCamera(oldcam, g_size);
	} else {
		fl->tv.p = Vec3f(fl->pos.x, fl->pos.y, 0.001f);
	}

	switch(PIPOrgb) {
		case 0: {
			fl->rgb = Color3f(.4f, 0.f, .4f) + Color3f(2.f/3, 2.f/3, 2.f/3) * randomColor3f();
			break;
		}
		case 1: {
			fl->rgb = Color3f(.5f, .5f, 0.f) + Color3f(.625f, .625f, .55f) * randomColor3f();
			break;
		}
		case 2: {
			fl->rgb = Color3f(.4f, 0.f, 0.f) + Color3f(2.f/3, .55f, .55f) * randomColor3f();
			break;
		}
	}

	if(typ == -1) {
		float zz = eeMousePressed1() ? 0.29f : ((sm > 0.5f) ? rnd() : 1.f);
		if(zz < 0.2f) {
			fl->type = 2;
			fl->size = rnd() * 42.f + 42.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else if(zz < 0.5f) {
			fl->type = 3;
			fl->size = rnd() * 52.f + 16.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else {
			fl->type = 1;
			fl->size = (rnd() * 24.f + 32.f) * sm;
			fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
		}
	} else {
		fl->type = (rnd() > 0.8f) ? 1 : 4;
		fl->size = (rnd() * 38.f + 64.f) * sm;
		fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
	}

	fl->dynlight = LightHandle::Invalid;

	for(long kk = 0; kk < 3; kk++) {

		if(rnd() < 0.5f) {
			continue;
		}

		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}

		if(!bookDraw) {
			pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
			if(!io) {
				pd->special |= PARTICLE_NOZBUFFER;
			}
		} else {
			pd->special = FADE_IN_AND_OUT;
		}

		pd->ov = fl->v.p + randomVec(-5.f, 5.f);
		pd->move = Vec3f(0.f, 5.f, 0.f);
		pd->scale = Vec3f(-2.f);
		pd->tolive = 1300 + kk * 100 + Random::get(0, 800);
		pd->tc = fire2;
		if(kk == 1) {
			pd->move.y = 4.f;
			pd->siz = 1.5f;
		} else {
			pd->siz = 1.f + rnd();
		}
		pd->rgb = Color3f(fl->rgb.r * (2.f/3), fl->rgb.g * (2.f/3), fl->rgb.b * (2.f/3));
		pd->fparam = 1.2f;

		if(bookDraw)
			pd->is2D = true;
	}
}
示例#8
0
Entity::~Entity() {
	
	cleanReferences();
	
	if(g_cameraEntity == this) {
		g_cameraEntity = NULL;
	}
	
	// Releases ToBeDrawn Transparent Polys linked to this object !
	tweaks.clear();
	
	if(obj && !(ioflags & IO_CAMERA) && !(ioflags & IO_MARKER) && !(ioflags & IO_GOLD)) {
		delete obj, obj = NULL;
	}
	
	spells.removeTarget(this);
	
	delete tweakerinfo;
	delete tweaky, tweaky = NULL;
	
	ReleaseScript(&script);
	ReleaseScript(&over_script);
	
	for(size_t n = 0; n < MAX_ANIMS; n++) {
		if(anims[n]) {
			EERIE_ANIMMANAGER_ReleaseHandle(anims[n]);
			anims[n] = NULL;
		}
	}
	
	lightHandleDestroy(dynlight);
	
	delete usepath;
	
	delete symboldraw;
	symboldraw = NULL;
	
	if(ioflags & IO_NPC) {
		delete _npcdata;
	} else if(ioflags & IO_ITEM) {
		free(_itemdata->equipitem);
		delete _itemdata;
	} else if(ioflags & IO_FIX) {
		delete _fixdata;
	} else if(ioflags & IO_CAMERA && _camdata) {
		if(g_camera == &_camdata->cam) {
			SetActiveCamera(&g_playerCamera);
		}
		delete _camdata;
	}
	
	if(SecondaryInventory && SecondaryInventory->io == this) {
		SecondaryInventory = NULL;
	}
	
	if(TSecondaryInventory && TSecondaryInventory->io == this) {
		TSecondaryInventory = NULL;
	}
	
	delete inventory;
	
	if(m_index != size_t(-1)) {
		entities.remove(m_index);
	}
	
}
示例#9
0
/*---------------------------------------------------------------*/
void Cinematic::Render(float FDIFF) {
	
	CinematicBitmap * tb;

	LargeurRender = DANAESIZX;
	HauteurRender = DANAESIZY;

	if (projectload)
	{
		GRenderer->Clear(Renderer::ColorBuffer);
		GRenderer->BeginScene();

		GereTrack(this, FDIFF);

		//sound
		if (changekey)
		{
			if (idsound >= 0)
			{
				PlaySoundKeyFramer(idsound);
			}
		}

		//draw
		GRenderer->SetBlendFunc(Renderer::BlendSrcAlpha, Renderer::BlendInvSrcAlpha);

		GRenderer->GetTextureStage(0)->SetColorOp(TextureStage::OpModulate, TextureStage::ArgTexture, TextureStage::ArgDiffuse);
		GRenderer->GetTextureStage(0)->SetAlphaOp(TextureStage::OpModulate, TextureStage::ArgTexture, TextureStage::ArgDiffuse);

		GRenderer->GetTextureStage(1)->DisableAlpha();
		
		//image key
		tb = m_bitmaps[numbitmap];

		//fx
		int col = 0x00FFFFFF;

		switch (fx & 0x000000FF)
		{
			case FX_FADEIN:
				col = FX_FadeIN(a, color, colord);
				break;
			case FX_FADEOUT:
				col = FX_FadeOUT(a, color, colord);
				break;
			case FX_BLUR:
				FX_Blur(this, tb);
				break;
			default:
				break;
		}

		//fx precalculation
		switch (fx & 0x0000ff00)
		{
			case FX_DREAM:

				if ((this->fxsuiv & 0x0000ff00) == FX_DREAM)
					FX_DreamPrecalc(tb, 15.f, (FPS > 1.f) ? GetTrackFPS() / FPS : 0.f);
				else
					FX_DreamPrecalc(tb, 15.f * a, (FPS > 1.f) ? GetTrackFPS() / FPS : 0.f);

				break;
			default:
				break;
		}

		Camera.pos = pos;
		SetTargetCamera(&Camera, Camera.pos.x, Camera.pos.y, 0.f);
		Camera.angle.b = 0;
		Camera.angle.g = angz;
		Camera.centerx = LargeurRender >> 1;
		Camera.centery = HauteurRender >> 1;
		Camera.clip.right = LargeurRender;
		Camera.clip.bottom = HauteurRender;
		PrepareCamera(&Camera);
		SetActiveCamera(&Camera);

		int alpha = ((int)(a * 255.f)) << 24;

		int stopline = tb->nbx;

		if (stopline & 1) stopline++;

		if (force ^ 1) alpha = 0xFF000000;

		col |= alpha;

		CinematicLight lightt, *l = NULL;

		if ((this->light.intensity >= 0.f) &&
		        (this->lightd.intensity >= 0.f))
		{
			lightt = this->light;
			lightt.pos.x += (float)(LargeurRender >> 1);
			lightt.pos.y += (float)(HauteurRender >> 1);

			#define SPEEDINTENSITYRND (10.f)
			float flIntensityRNDToReach = lightt.intensiternd * rnd();
			m_flIntensityRND += (flIntensityRNDToReach - m_flIntensityRND) * FDIFF * SPEEDINTENSITYRND;
			m_flIntensityRND = m_flIntensityRND < 0.f ? 0.f : m_flIntensityRND > 1.f ? 1.f : m_flIntensityRND;

			LightRND = lightt.intensity + (lightt.intensiternd * rnd());

			if (LightRND > 1.f) LightRND = 1.f;

			l = &lightt;
		}

		if (tb->grid.nbvertexs) DrawGrille(&tb->grid, col, fx, l, &posgrille, angzgrille);

		//PASS #2
		if (force & 1)
		{
			switch (ti)
			{
				case INTERP_NO:
					Camera.pos = possuiv;
					SetTargetCamera(&Camera, Camera.pos.x, Camera.pos.y, 0.f);
					Camera.angle.b = 0;
					Camera.angle.g = angzsuiv;
					PrepareCamera(&Camera);
					break;
				case INTERP_LINEAR:
					break;
				case INTERP_BEZIER:
					break;
			}

			tb = m_bitmaps[numbitmapsuiv];

			alpha = 0xFF000000 - alpha;
			col &= 0x00FFFFFF;
			col |= alpha;

			l = NULL;

			if ((this->light.intensity >= 0.f) &&
			        (this->lightd.intensity >= 0.f))
			{
				lightt = this->lightd;
				lightt.pos.x += (float)(LargeurRender >> 1);
				lightt.pos.y += (float)(HauteurRender >> 1);
				LightRND = lightt.intensity + (lightt.intensiternd * rnd());

				if (LightRND > 1.f) LightRND = 1.f;

				l = &lightt;
			}

			if (tb->grid.nbvertexs) DrawGrille(&tb->grid, col, fx, l, &posgrillesuiv, angzgrillesuiv);
		}
示例#10
0
/*---------------------------------------------------------------*/
void Cinematic::Render(float FDIFF) {
	
	CinematicBitmap * tb;

	LargeurRender = g_size.width();
	HauteurRender = g_size.height();

	if(projectload) {
		GRenderer->Clear(Renderer::ColorBuffer);

		GereTrack(this, FDIFF);

		//sound
		if(changekey && idsound >= 0)
			PlaySoundKeyFramer(idsound);

		//draw
		GRenderer->SetBlendFunc(Renderer::BlendSrcAlpha, Renderer::BlendInvSrcAlpha);

		GRenderer->GetTextureStage(0)->setColorOp(TextureStage::OpModulate, TextureStage::ArgTexture, TextureStage::ArgDiffuse);
		GRenderer->GetTextureStage(0)->setAlphaOp(TextureStage::OpModulate, TextureStage::ArgTexture, TextureStage::ArgDiffuse);

		GRenderer->GetTextureStage(1)->disableAlpha();
		
		//image key
		tb = m_bitmaps[numbitmap];

		//fx
		int col = 0x00FFFFFF;

		switch(fx & 0x000000FF) {
			case FX_FADEIN:
				col = FX_FadeIN(a, color, colord);
				break;
			case FX_FADEOUT:
				col = FX_FadeOUT(a, color, colord);
				break;
			case FX_BLUR:
				FX_Blur(this, tb, m_camera);
				break;
			default:
				break;
		}

		//fx precalculation
		switch(fx & 0x0000ff00) {
			case FX_DREAM:

				if ((this->fxsuiv & 0x0000ff00) == FX_DREAM)
					FX_DreamPrecalc(tb, 15.f, (FPS > 1.f) ? GetTrackFPS() / FPS : 0.f);
				else
					FX_DreamPrecalc(tb, 15.f * a, (FPS > 1.f) ? GetTrackFPS() / FPS : 0.f);

				break;
			default:
				break;
		}

		m_camera.orgTrans.pos = pos;
		m_camera.setTargetCamera(m_camera.orgTrans.pos.x, m_camera.orgTrans.pos.y, 0.f);
		m_camera.angle.setPitch(0);
		m_camera.angle.setRoll(angz);
		m_camera.clip = Rect(LargeurRender, HauteurRender);
		m_camera.center = m_camera.clip.center();
		PrepareCamera(&m_camera, g_size);
		SetActiveCamera(&m_camera);

		int alpha = ((int)(a * 255.f)) << 24;

		if(force ^ 1)
			alpha = 0xFF000000;

		col |= alpha;

		CinematicLight lightt, *l = NULL;

		if(this->light.intensity >= 0.f && this->lightd.intensity >= 0.f) {
			lightt = this->light;
			lightt.pos.x += (float)(LargeurRender >> 1);
			lightt.pos.y += (float)(HauteurRender >> 1);

			static const float SPEEDINTENSITYRND = 10.f;
			float flIntensityRNDToReach = lightt.intensiternd * rnd();
			m_flIntensityRND += (flIntensityRNDToReach - m_flIntensityRND) * FDIFF * SPEEDINTENSITYRND;
			m_flIntensityRND = m_flIntensityRND < 0.f ? 0.f : m_flIntensityRND > 1.f ? 1.f : m_flIntensityRND;

			LightRND = lightt.intensity + (lightt.intensiternd * rnd());

			if(LightRND > 1.f)
				LightRND = 1.f;

			l = &lightt;
		}

		if(tb->grid.nbvertexs)
			DrawGrille(&tb->grid, col, fx, l, &posgrille, angzgrille);

		//PASS #2
		if(force & 1) {
			switch(ti) {
				case INTERP_NO:
					m_camera.orgTrans.pos = possuiv;
					m_camera.setTargetCamera(m_camera.orgTrans.pos.x, m_camera.orgTrans.pos.y, 0.f);
					m_camera.angle.setPitch(0);
					m_camera.angle.setRoll(angzsuiv);
					PrepareCamera(&m_camera, g_size);
					break;
				case INTERP_LINEAR:
					break;
				case INTERP_BEZIER:
					break;
			}

			tb = m_bitmaps[numbitmapsuiv];

			alpha = 0xFF000000 - alpha;
			col &= 0x00FFFFFF;
			col |= alpha;

			l = NULL;

			if(this->light.intensity >= 0.f && this->lightd.intensity >= 0.f) {
				lightt = this->lightd;
				lightt.pos.x += (float)(LargeurRender >> 1);
				lightt.pos.y += (float)(HauteurRender >> 1);
				LightRND = lightt.intensity + (lightt.intensiternd * rnd());

				if(LightRND > 1.f)
					LightRND = 1.f;

				l = &lightt;
			}

			if(tb->grid.nbvertexs)
				DrawGrille(&tb->grid, col, fx, l, &posgrillesuiv, angzgrillesuiv);
		}
示例#11
0
void AddFlare(const Vec2s & pos, float sm, short typ, Entity * io, bool bookDraw) {

	long i;
	for(i = 0; i < MAX_FLARES; i++) {
		if(!magicFlares[i].exist) {
			break;
		}
	}
	if(i >= MAX_FLARES) {
		return;
	}

	FLARES * fl = &magicFlares[i];
	fl->exist = 1;
	flarenum++;

	if(!bookDraw)
		fl->bDrawBitmap = 0;
	else
		fl->bDrawBitmap = 1;

	fl->io = io;
	if(io) {
		fl->flags = 1;
		io->flarecount++;
	} else {
		fl->flags = 0;
	}

	fl->x = float(pos.x) - rnd() * 4.f;
	fl->y = float(pos.y) - rnd() * 4.f - 50.f;
	fl->tv.rhw = fl->v.rhw = 1.f;
	fl->tv.specular = fl->v.specular = 1;

	if(!bookDraw) {
		EERIE_CAMERA ka = *Kam;
		ka.angle = Anglef(360.f, 360.f, 360.f) - ka.angle;
		EERIE_CAMERA * oldcam = ACTIVECAM;
		SetActiveCamera(&ka);
		PrepareCamera(&ka);
		fl->v.p += ka.orgTrans.pos;
		EE_RTP(&fl->tv, &fl->v);
		fl->v.p += ka.orgTrans.pos;

		float vx = -(fl->x - subj.center.x) * 0.2173913f;
		float vy = (fl->y - subj.center.y) * 0.1515151515151515f;
		if(io) {
			fl->v.p.x = io->pos.x - EEsin(radians(MAKEANGLE(io->angle.getPitch() + vx))) * 100.f;
			fl->v.p.y = io->pos.y + EEsin(radians(MAKEANGLE(io->angle.getYaw() + vy))) * 100.f - 150.f;
			fl->v.p.z = io->pos.z + EEcos(radians(MAKEANGLE(io->angle.getPitch() + vx))) * 100.f;
		} else {
			fl->v.p.x = float(pos.x - (g_size.width() / 2)) * 150.f / float(g_size.width());
			fl->v.p.y = float(pos.y - (g_size.height() / 2)) * 150.f / float(g_size.width());
			fl->v.p.z = 75.f;
			ka = *oldcam;
			SetActiveCamera(&ka);
			PrepareCamera(&ka);
			float temp = (fl->v.p.y * -ka.orgTrans.xsin) + (fl->v.p.z * ka.orgTrans.xcos);
			fl->v.p.y = (fl->v.p.y * ka.orgTrans.xcos) - (-fl->v.p.z * ka.orgTrans.xsin);
			fl->v.p.z = (temp * ka.orgTrans.ycos) - (-fl->v.p.x * ka.orgTrans.ysin);
			fl->v.p.x = (temp * -ka.orgTrans.ysin) + (fl->v.p.x * ka.orgTrans.ycos);
			fl->v.p += oldcam->orgTrans.pos;
		}
		fl->tv.p = fl->v.p;
		SetActiveCamera(oldcam);
		PrepareCamera(oldcam);
	} else {
		fl->tv.p = Vec3f(fl->x, fl->y, 0.001f);
	}

	switch(PIPOrgb) {
		case 0: {
			fl->rgb = Color3f(rnd() * (2.f/3) + .4f, rnd() * (2.f/3), rnd() * (2.f/3) + .4f);
			break;
		}
		case 1: {
			fl->rgb = Color3f(rnd() * .625f + .5f, rnd() * .625f + .5f, rnd() * .55f);
			break;
		}
		case 2: {
			fl->rgb = Color3f(rnd() * (2.f/3) + .4f, rnd() * .55f, rnd() * .55f);
			break;
		}
	}

	if(typ == -1) {
		float zz = (EERIEMouseButton & 1) ? 0.29f : ((sm > 0.5f) ? rnd() : 1.f);
		if(zz < 0.2f) {
			fl->type = 2;
			fl->size = rnd() * 42.f + 42.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else if(zz < 0.5f) {
			fl->type = 3;
			fl->size = rnd() * 52.f + 16.f;
			fl->tolive = (800.f + rnd() * 800.f) * FLARE_MUL;
		} else {
			fl->type = 1;
			fl->size = (rnd() * 24.f + 32.f) * sm;
			fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
		}
	} else {
		fl->type = (rnd() > 0.8f) ? 1 : 4;
		fl->size = (rnd() * 38.f + 64.f) * sm;
		fl->tolive = (1700.f + rnd() * 500.f) * FLARE_MUL;
	}

	fl->dynlight = -1;
	fl->move = OPIPOrgb;

	for(long kk = 0; kk < 3; kk++) {

		if(rnd() < 0.5f) {
			continue;
		}

		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}

		if(!bookDraw) {
			pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
			if(!io) {
				pd->special |= PARTICLE_NOZBUFFER;
			}
		} else {
			pd->special = FADE_IN_AND_OUT;
		}

		pd->ov = fl->v.p + randomVec(-5.f, 5.f);
		pd->move = Vec3f(0.f, 5.f, 0.f);
		pd->scale = Vec3f(-2.f);
		pd->tolive = 1300 + kk * 100 + Random::get(0, 800);
		pd->tc = fire2;
		if(kk == 1) {
			pd->move.y = 4.f;
			pd->siz = 1.5f;
		} else {
			pd->siz = 1.f + rnd();
		}
		pd->rgb = Color3f(fl->rgb.r * (2.f/3), fl->rgb.g * (2.f/3), fl->rgb.b * (2.f/3));
		pd->fparam = 1.2f;

		if(bookDraw)
			pd->type = PARTICLE_2D;
	}
}
示例#12
0
void AddFlare(const Vec2f & pos, float sm, short typ, Entity * io, bool bookDraw) {
	
	size_t oldest = 0;
	size_t i;
	for(i = 0; i < g_magicFlaresMax; i++) {
		if(!g_magicFlares[i].exist) {
			break;
		}
		if(g_magicFlares[i].tolive < g_magicFlares[oldest].tolive) {
			oldest = i;
		}
	}
	if(i >= g_magicFlaresMax) {
		removeFlare(g_magicFlares[oldest]);
		i = oldest;
	}

	MagicFlare & flare = g_magicFlares[i];
	flare.exist = 1;
	g_magicFlaresCount++;

	if(!bookDraw)
		flare.bDrawBitmap = 0;
	else
		flare.bDrawBitmap = 1;

	flare.io = io;
	if(io) {
		flare.flags = 1;
		io->flarecount++;
	} else {
		flare.flags = 0;
	}

	flare.pos.x = pos.x - Random::getf(0.f, 4.f);
	flare.pos.y = pos.y - Random::getf(0.f, 4.f) - 50.f;
	flare.tv.rhw = flare.v.rhw = 1.f;

	if(!bookDraw) {
		EERIE_CAMERA ka = *g_magicFlareCamera;
		ka.angle = Anglef(360.f, 360.f, 360.f) - ka.angle;
		EERIE_CAMERA * oldcam = ACTIVECAM;
		SetActiveCamera(&ka);
		PrepareCamera(&ka, g_size);
		flare.v.p += ka.orgTrans.pos;
		EE_RTP(flare.tv.p, flare.v);
		flare.v.p += ka.orgTrans.pos;

		float vx = -(flare.pos.x - subj.center.x) * 0.2173913f;
		float vy = (flare.pos.y - subj.center.y) * 0.1515151515151515f;
		if(io) {
			flare.v.p = io->pos;
			flare.v.p += angleToVectorXZ(io->angle.getYaw() + vx) * 100.f;
			flare.v.p.y += std::sin(glm::radians(MAKEANGLE(io->angle.getPitch() + vy))) * 100.f - 150.f;
		} else {
			flare.v.p.x = 1.0f  * float(pos.x - (g_size.width()  / 2)) * 156.f / (640.f * g_sizeRatio.y);
			flare.v.p.y = 0.75f * float(pos.y - (g_size.height() / 2)) * 156.f / (480.f * g_sizeRatio.y);
			flare.v.p.z = 75.f;
			ka = *oldcam;
			SetActiveCamera(&ka);
			PrepareCamera(&ka, g_size);
			float temp = (flare.v.p.y * -ka.orgTrans.xsin) + (flare.v.p.z * ka.orgTrans.xcos);
			flare.v.p.y = (flare.v.p.y * ka.orgTrans.xcos) - (-flare.v.p.z * ka.orgTrans.xsin);
			flare.v.p.z = (temp * ka.orgTrans.ycos) - (-flare.v.p.x * ka.orgTrans.ysin);
			flare.v.p.x = (temp * -ka.orgTrans.ysin) + (flare.v.p.x * ka.orgTrans.ycos);
			flare.v.p += oldcam->orgTrans.pos;
		}
		flare.tv.p = flare.v.p;
		SetActiveCamera(oldcam);
		PrepareCamera(oldcam, g_size);
	} else {
		flare.tv.p = Vec3f(flare.pos.x, flare.pos.y, 0.001f);
	}

	switch(g_magicFlareCurrentColor) {
		case 0: {
			flare.rgb = Color3f(.4f, 0.f, .4f) + Color3f(2.f/3, 2.f/3, 2.f/3) * randomColor3f();
			break;
		}
		case 1: {
			flare.rgb = Color3f(.5f, .5f, 0.f) + Color3f(.625f, .625f, .55f) * randomColor3f();
			break;
		}
		case 2: {
			flare.rgb = Color3f(.4f, 0.f, 0.f) + Color3f(2.f/3, .55f, .55f) * randomColor3f();
			break;
		}
	}
	
	static const float FLARE_MUL = 2.f;
	
	if(typ == -1) {
		float zz = eeMousePressed1() ? 0.29f : ((sm > 0.5f) ? Random::getf() : 1.f);
		if(zz < 0.2f) {
			flare.type = 2;
			flare.size = Random::getf(42.f, 84.f);
			flare.tolive = Random::getf(800.f, 1600.f) * FLARE_MUL;
		} else if(zz < 0.5f) {
			flare.type = 3;
			flare.size = Random::getf(16.f, 68.f);
			flare.tolive = Random::getf(800.f, 1600.f) * FLARE_MUL;
		} else {
			flare.type = 1;
			flare.size = Random::getf(32.f, 56.f) * sm;
			flare.tolive = Random::getf(1700.f, 2200.f) * FLARE_MUL;
		}
	} else {
		flare.type = (Random::getf() > 0.8f) ? 1 : 4;
		flare.size = Random::getf(64.f, 102.f) * sm;
		flare.tolive = Random::getf(1700.f, 2200.f) * FLARE_MUL;
	}

	flare.dynlight = LightHandle();

	for(unsigned int kk = 0; kk < 3; kk++) {

		if(Random::getf() < 0.5f) {
			continue;
		}

		PARTICLE_DEF * pd = createParticle();
		if(!pd) {
			break;
		}

		if(!bookDraw) {
			pd->m_flags = FADE_IN_AND_OUT | ROTATING | DISSIPATING;
			if(!io) {
				pd->m_flags |= PARTICLE_NOZBUFFER;
			}
		} else {
			pd->m_flags = FADE_IN_AND_OUT;
		}

		pd->ov = flare.v.p + randomVec(-5.f, 5.f);
		pd->move = Vec3f(0.f, 5.f, 0.f);
		pd->scale = Vec3f(-2.f);
		pd->tolive = 1300 + kk * 100 + Random::getu(0, 800);
		pd->tc = fire2;
		if(kk == 1) {
			pd->move.y = 4.f;
			pd->siz = 1.5f;
		} else {
			pd->siz = Random::getf(1.f, 2.f);
		}
		pd->rgb = Color3f(flare.rgb.r * (2.f/3), flare.rgb.g * (2.f/3), flare.rgb.b * (2.f/3));
		pd->m_rotation = 1.2f;

		if(bookDraw)
			pd->is2D = true;
	}
}