Ejemplo n.º 1
0
int EScene::BoxQuery(SPickQuery& PQ, const Fbox& bb, u32 flags, CDB::MODEL* model)
{
    PQ.prepare_bq	(bb,flags);
	ETOOLS::box_options	(flags);
    Fvector c,d;
    bb.getcenter	(c);
    bb.getradius	(d);
    ETOOLS::box_query	(model,c,d);
    for (int r=0; r<ETOOLS::r_count(); r++)
        PQ.append	(ETOOLS::r_begin()+r,0,0);
	return PQ.r_count();
}
Ejemplo n.º 2
0
void CGlow::Render(int priority, bool strictB2F)
{
    if ((1==priority)&&(true==strictB2F)){
    	if (!m_bDefLoad) OnDeviceCreate();
        ESceneGlowTools* gt = dynamic_cast<ESceneGlowTools*>(ParentTools); VERIFY(gt);
        RCache.set_xform_world(Fidentity);
        if (gt->m_Flags.is(ESceneGlowTools::flTestVisibility)){ 
            Fvector D;	D.sub(Device.vCameraPosition,PPosition);
            float dist 	= D.normalize_magn();
            if (!Scene->RayPickObject(dist,PPosition,D,OBJCLASS_SCENEOBJECT,0,0)){
                if (m_GShader){	Device.SetShader(m_GShader);
                }else{			Device.SetShader(Device.m_WireShader);}
                m_RenderSprite.Render(PPosition,m_fRadius,m_Flags.is(gfFixedSize));
                DU.DrawRomboid(PPosition, VIS_RADIUS, 0x00FF8507);
            }else{
                // рендерим bounding sphere
                Device.SetShader(Device.m_WireShader);
                DU.DrawRomboid(PPosition, VIS_RADIUS, 0x00FF8507);
            }
        }else{
            if (m_GShader){	Device.SetShader(m_GShader);
            }else{			Device.SetShader(Device.m_WireShader);}
            m_RenderSprite.Render(PPosition,m_fRadius,m_Flags.is(gfFixedSize));
        }
        if( Selected() ){
            Fbox bb; GetBox(bb);
            u32 clr = Locked()?0xFFFF0000:0xFFFFFFFF;
            Device.SetShader(Device.m_WireShader);
            DU.DrawSelectionBox(bb,&clr);  
            if (gt->m_Flags.is(ESceneGlowTools::flDrawCross)){
            	Fvector sz; bb.getradius(sz);
        		DU.DrawCross(PPosition,sz.x,sz.y,sz.z, sz.x,sz.y,sz.z,0xFFFFFFFF,false);
            }
        }
    }
}
Ejemplo n.º 3
0
void dx103DFluidRenderer::CalculateLighting(const dx103DFluidData &FluidData, FogLighting  &LightData)
{
	m_lstRenderables.clear_not_free();

	LightData.Reset();

	const dx103DFluidData::Settings &VolumeSettings = FluidData.GetSettings();

	Fvector4 hemi_color = g_pGamePersistent->Environment().CurrentEnv->hemi_color;
	//hemi_color.mul(0.2f);
	hemi_color.mul(VolumeSettings.m_fHemi);
	LightData.m_vLightIntencity.set(hemi_color.x, hemi_color.y, hemi_color.z);
	LightData.m_vLightIntencity.add(g_pGamePersistent->Environment().CurrentEnv->ambient);

	const Fmatrix &Transform = FluidData.GetTransform();

	Fbox	box;
	box.min = Fvector3().set(-0.5f, -0.5f, -0.5f);
	box.max = Fvector3().set( 0.5f,  0.5f,  0.5f);
	box.xform(Transform);
	Fvector3	center;
	Fvector3	size;
	box.getcenter(center);
	box.getradius(size);


	// Traverse object database
	g_SpatialSpace->q_box
		(
		m_lstRenderables,
		0, //ISpatial_DB::O_ORDERED,
		STYPE_LIGHTSOURCE,
		center,
		size
		);

	u32 iNumRenderables = m_lstRenderables.size();
	// Determine visibility for dynamic part of scene
	for (u32 i=0; i<iNumRenderables; ++i)
	{
		ISpatial*	spatial		= m_lstRenderables[i];

		// Light
		light*	pLight = (light*) spatial->dcast_Light();
		VERIFY(pLight);

		if (pLight->flags.bStatic) continue;

		float	d	=	pLight->position.distance_to(Transform.c);

		float	R				= pLight->range + _max( size.x, _max( size.y, size.z ) );
		if ( d >= R )
			continue;

		Fvector3	LightIntencity;

		LightIntencity.set(pLight->color.r, pLight->color.g, pLight->color.b);

		//LightIntencity.mul(0.5f);

		//if (!pLight->flags.bStatic)
		//	LightIntencity.mul(0.5f);

		float	r	=	pLight->range;
		float	a	=	clampr(1.f - d/(r+EPS),0.f,1.f)*(pLight->flags.bStatic?1.f:2.f);

		LightIntencity.mul(a);

		LightData.m_vLightIntencity.add(LightIntencity);
	}

	//LightData.m_vLightIntencity.set( 1.0f, 0.5f, 0.0f);
	//LightData.m_vLightIntencity.set( 1.0f, 1.0f, 1.0f);
}