コード例 #1
0
ファイル: Picking.cpp プロジェクト: Borzen/SrProject
void Picking::project(const physx::PxVec3& v, int& xi, int& yi, float& depth) const
{
	SampleRenderer::Renderer* renderer = mFrame.getRenderer();
	SampleRenderer::RendererProjection	projection = mFrame.getCamera().getProjMatrix();
	const PxTransform view = mFrame.getCamera().getViewMatrix().getInverse();

	PxVec3 pos = SampleRenderer::project(projection, view, v);
	///* Map x, y and z to range 0-1 */
	pos.x = (pos.x + 1 ) * 0.5f;
	pos.y = (pos.y + 1 ) * 0.5f;
	pos.z = (pos.z + 1 ) * 0.5f;
	
	PxU32 windowWidth  = 0;
	PxU32 windowHeight = 0;
	renderer->getWindowSize(windowWidth, windowHeight);

	/* Map x,y to viewport */
	pos.x *= windowWidth;
	pos.y *= windowHeight; 
	
	depth = (float)pos.z;

	xi = (int)(pos.x + 0.5); 
	yi = (int)(pos.y + 0.5); 
}
コード例 #2
0
void RenderMaterial::update(SampleRenderer::Renderer& renderer)
{
	const RendererMaterial::Variable* var = mRenderMaterialInstance->findVariable("windowWidth", RendererMaterial::VARIABLE_FLOAT);
	if(var)
	{
		PxU32 tmpWindowWidth, tmpWindowHeight;
		renderer.getWindowSize(tmpWindowWidth, tmpWindowHeight);

		const PxReal windowWidth = PxReal(tmpWindowWidth);
		mRenderMaterialInstance->writeData(*var, &windowWidth);
	}

}
コード例 #3
0
ファイル: Picking.cpp プロジェクト: Borzen/SrProject
PxVec3 Picking::unProject(int x, int y, float depth) const
{
	SampleRenderer::Renderer* renderer = mFrame.getRenderer();
	const SampleRenderer::RendererProjection& projection = mFrame.getCamera().getProjMatrix();
	const PxTransform view = mFrame.getCamera().getViewMatrix().getInverse();

	PxU32 windowWidth  = 0;
	PxU32 windowHeight = 0;
	renderer->getWindowSize(windowWidth, windowHeight);
	
	const PxF32 outX = (float)x / (float)windowWidth;
	const PxF32 outY = (float)y / (float)windowHeight;

	return SampleRenderer::unproject(projection, view, outX * 2 -1, outY * 2 -1, depth * 2 - 1);
}
コード例 #4
0
ファイル: SampleSubmarine.cpp プロジェクト: thomhughes/Awe
void SampleSubmarine::customizeRender()
{
	SampleRenderer::Renderer* renderer = getRenderer();
	const PxU32 yInc = 18;
	const RendererColor textColor(255, 255, 255, 255);

	PxU32 width, height;
	renderer->getWindowSize(width, height);
	char healthBar[20];
	PxU32 h = gSubmarineHealth;
	sprintf(healthBar, "Health:%c%c%c%c%c%c%c%c%c%c", (h>90?'I':' '), (h>80?'I':' '), (h>70?'I':' '),(h>60?'I':' '),(h>50?'I':' '), 
	(h>40?'I':' '), (h>30?'I':' '), (h>20?'I':' '),(h>10?'I':' '),(h>0?'I':' '));
	renderer->print(width-130, height-yInc, healthBar);	
	if(gTreasureFound)
		renderer->print(width-160, height-2*yInc, "Treasure Found!");	
}
コード例 #5
0
ファイル: SampleParticles.cpp プロジェクト: akurt5/AIEShit
void SampleParticles::customizeRender()
{
	SampleRenderer::Renderer* renderer = getRenderer();

	// render the sight
	SampleRenderer::RendererColor sightColor(200, 40, 40, 127);
	PxReal sight[] = {  0.47f, 0.50f, 0.49f, 0.50f,	// line 1
						0.51f, 0.50f, 0.53f, 0.50f,	// line 2
						0.50f, 0.47f, 0.50f, 0.49f,	// line 3
						0.50f, 0.51f, 0.50f, 0.53f	// line 4
					 };

	renderer->drawLines2D(2, sight, sightColor);
	renderer->drawLines2D(2, sight + 4, sightColor);
	renderer->drawLines2D(2, sight + 8, sightColor);
	renderer->drawLines2D(2, sight + 12, sightColor);

	//settings for right lower corner info text (same hight as fps display)
	const PxU32 yInc = 18;
	const PxReal scale = 0.5f;
	const PxReal shadowOffset = 6.0f;
	PxU32 width, height;
	renderer->getWindowSize(width, height);

	PxU32 y = height-2*yInc;
	PxU32 x = width - 240;

	if (mLoadTextAlpha > 0)
	{
		const RendererColor textColor(255, 0, 0, PxU8(mLoadTextAlpha*255.0f));
		const char* message[3] = { "Particle count: Moderate", "Particle count: Medium", "Particle count: High" };
		renderer->print(x, y, message[mParticleLoadIndex], scale, shadowOffset, textColor);
		y -= yInc;
	}

#if PX_SUPPORT_GPU_PHYSX
	{
		const RendererColor textColor(255, 0, 0, 255);
		renderer->print(x, y, mRunOnGpu ? "Running on GPU" : "Running on CPU", scale, shadowOffset, textColor);
	}
#endif
}
コード例 #6
0
void SampleCharacterCloth::customizeRender()
{
#if PX_SUPPORT_GPU_PHYSX
	SampleRenderer::Renderer* renderer = getRenderer();

	const PxU32 yInc = 18;
	const PxReal scale = 0.5f;
	const PxReal shadowOffset = 6.0f;
	PxU32 width, height;
	renderer->getWindowSize(width, height);

	PxU32 y = height-2*yInc;
	PxU32 x = width - 240;

	{
		const RendererColor textColor(255, 0, 0, 255);
		renderer->print(x, y, mUseGPU ? "Running on GPU" : "Running on CPU", scale, shadowOffset, textColor);
	}
#endif

}