Vec3f QuadParticleSystemDrawer::getQuadNormal(DrawEnv *pEnv, ParticleSystemUnrecPtr System, UInt32 Index)
{
	Vec3f Direction;
	
	switch(getNormalSource())
	{
	case NORMAL_POSITION_CHANGE:
		Direction = System->getPositionChange(Index);
			Direction.normalize();
		break;
	case NORMAL_VELOCITY_CHANGE:
		Direction = System->getVelocityChange(Index);
			Direction.normalize();
		break;
	case NORMAL_VELOCITY:
		Direction = System->getVelocity(Index);
			Direction.normalize();
		break;
	case NORMAL_ACCELERATION:
		Direction = System->getAcceleration(Index);
			Direction.normalize();
		break;
	case NORMAL_PARTICLE_NORMAL:
		Direction = System->getNormal(Index);
		break;
	case NORMAL_VIEW_POSITION:
		{
			//TODO: make this more efficient
            Matrix ModelView(pEnv->getCameraViewing()); 
			Pnt3f Position(ModelView[0][3],ModelView[1][3],ModelView[2][3]);
			Direction = Position - System->getPosition(Index);
			Direction.normalize();
		
		break;
		}
	case NORMAL_STATIC:
		Direction = getNormal();
			break;
	case NORMAL_VIEW_DIRECTION:
	default:
		{
            Matrix ModelView(pEnv->getCameraViewing()); 
            ModelView.mult(pEnv->getObjectToWorld());
			Direction.setValues(ModelView[0][2],ModelView[1][2],ModelView[2][2]);
		break;
		}
	}
	return Direction;
}
示例#2
0
void DrawTexture::DrawBarrelDistortion(bool leftEye) const {
	glBindVertexArray(fVao);
	auto shader = Shaders::BarrelDistortion::Make();
	shader->EnableProgram();
	shader->ConfigureEye(leftEye);
	glm::mat4 scale = glm::scale(glm::mat4(1), glm::vec3(2,2,1));
	glm::mat4 transl = glm::translate(glm::mat4(1), glm::vec3(-1, -1, 0));
	shader->ModelView(transl * scale);

	this->DrawBasic();

	shader->DisableProgram();
	glBindVertexArray(0);
}
Vec3f QuadParticleSystemDrawer::getQuadUpDir(DrawEnv *pEnv, ParticleSystemUnrecPtr System, UInt32 Index)
{
	Vec3f Direction;
	
	switch(getUpSource())
	{
	case UP_POSITION_CHANGE:
		Direction = System->getPositionChange(Index);
		break;
	case UP_VELOCITY_CHANGE:
		Direction = System->getVelocityChange(Index);
		break;
	case UP_VELOCITY:
		Direction = System->getVelocity(Index);
		break;
	case UP_ACCELERATION:
		Direction = System->getAcceleration(Index);
		break;
	case UP_PARTICLE_NORMAL:
		Direction = System->getNormal(Index);
		break;
	case UP_STATIC:
		Direction = getUp();
		break;
	case UP_VIEW_DIRECTION:
	default:
		{
            Matrix ModelView(pEnv->getCameraViewing()); 
            ModelView.mult(pEnv->getObjectToWorld());
			Direction.setValues(ModelView[0][1],ModelView[1][1],ModelView[2][1]);
		break;
		}
	}

	return Direction;
}