mmortall
Messages : 6 Date d'inscription : 2011-04-11
| Subject: OpenGL all particles are black Fri Aug 19, 2011 1:41 pm | |
| I use Spark with pure OpenGL + glu + glut (no SDL) I copy code from Fountain Demo. I load textures using Irrlicht and then got its OpenGL id-s. Id-s is valid. All particles rendered as black quads. If I turn on blending its become invisible. All another 3D models are drowed perfect using OpenGL. My init: - Code:
-
unsigned int randomSeed = static_cast<unsigned int>(time(NULL));
// Inits Particle Engine SPK::randomSeed = Game::GetInstance()->getIrrDevice()->getTimer()->getRealTime(); // Sets the update step SPK::System::setClampStep(true,0.1f); // clamp the step to 100 ms SPK::System::useAdaptiveStep(0.001f,0.01f); // use an adaptive step from 1ms to 10ms (1000fps to 100fps)
//Vector3D gravity(0.0f,-0.8f,0.0f);
loadData(); //load images
Vector3D gravity(0.0f,-2.2f,0.0f);
GLPointRenderer* basicRenderer = GLPointRenderer::create();
GLQuadRenderer* particleRenderer = GLQuadRenderer::create(); particleRenderer->setScale(0.06f,0.06f); particleRenderer->setTexturingMode(TEXTURE_2D); GLuint tx = m_textureFlash->getTextureID(); particleRenderer->setTexture(tx); particleRenderer->setBlending(BLENDING_NONE); particleRenderer->enableRenderingHint(DEPTH_WRITE,false);
// Model Model* particleModel = Model::create(FLAG_ALPHA | FLAG_SIZE | FLAG_ANGLE, FLAG_ALPHA | FLAG_SIZE | FLAG_ANGLE, FLAG_SIZE | FLAG_ANGLE);
particleModel->setLifeTime(1.6f,2.2f); //particleModel->setParam(PARAM_ALPHA,0.2f,0.0f); //particleModel->setParam(PARAM_SIZE,1.0f,1.0f,2.0f,8.0f); //particleModel->setParam(PARAM_ANGLE,0.0f,4.0f * 3.141592,0.0f,4.0f * 3.141592);
// Emitters const int NB_EMITTERS = 13;
Point* emitterZone[NB_EMITTERS]; emitterZone[0] = Point::create(Vector3D(0.0f,0.1f,0.0f));
emitterZone[1] = Point::create(Vector3D(0.0f,0.1f,0.0f)); emitterZone[2] = Point::create(Vector3D(0.0f,0.1f,0.0f)); emitterZone[3] = Point::create(Vector3D(0.0f,0.1f,0.0f)); emitterZone[4] = Point::create(Vector3D(0.0f,0.1f,0.0f));
emitterZone[5] = Point::create(Vector3D(-1.6f,0.1f,-1.6f)); emitterZone[6] = Point::create(Vector3D(1.6f,0.1f,1.6f)); emitterZone[7] = Point::create(Vector3D(1.6f,0.1f,-1.6f)); emitterZone[8] = Point::create(Vector3D(-1.6f,0.1f,1.6f)); emitterZone[9] = Point::create(Vector3D(-2.26f,0.1f,0.0f)); emitterZone[10] = Point::create(Vector3D(2.26f,0.1f,0.0f)); emitterZone[11] = Point::create(Vector3D(0.0f,0.1f,-2.26f)); emitterZone[12] = Point::create(Vector3D(0.0f,0.1f,2.26f));
StraightEmitter* particleEmitter[NB_EMITTERS]; particleEmitter[0] = StraightEmitter::create(Vector3D(0.0f,1.0f,0.0f));
particleEmitter[1] = StraightEmitter::create(Vector3D(1.0f,3.0f,1.0f)); particleEmitter[2] = StraightEmitter::create(Vector3D(-1.0f,3.0f,-1.0f)); particleEmitter[3] = StraightEmitter::create(Vector3D(-1.0f,3.0f,1.0f)); particleEmitter[4] = StraightEmitter::create(Vector3D(1.0f,3.0f,-1.0f));
particleEmitter[5] = StraightEmitter::create(Vector3D(1.0f,2.0f,1.0f)); particleEmitter[6] = StraightEmitter::create(Vector3D(-1.0f,2.0f,-1.0f)); particleEmitter[7] = StraightEmitter::create(Vector3D(-1.0f,2.0f,1.0f)); particleEmitter[8] = StraightEmitter::create(Vector3D(1.0f,2.0f,-1.0f)); particleEmitter[9] = StraightEmitter::create(Vector3D(1.41f,2.0f,0.0f)); particleEmitter[10] = StraightEmitter::create(Vector3D(-1.41f,2.0f,0.0f)); particleEmitter[11] = StraightEmitter::create(Vector3D(0.0f,2.0f,1.41f)); particleEmitter[12] = StraightEmitter::create(Vector3D(0.0f,2.0f,-1.41f));
float flow[NB_EMITTERS] = { 500.0f,
600.0f, 600.0f, 600.0f, 600.0f,
900.0f, 900.0f, 900.0f, 900.0f, 900.0f, 900.0f, 900.0f, 900.0f, };
float flowLow[NB_EMITTERS] = { 150.0f,
200.0f, 200.0f, 200.0f, 200.0f,
250.0f, 250.0f, 250.0f, 250.0f, 250.0f, 250.0f, 250.0f, 250.0f, }; for (int i = 0; i < NB_EMITTERS; ++i) { particleEmitter[i]->setZone(emitterZone[i]); particleEmitter[i]->setFlow(flow[i]); particleEmitter[i]->setForce(2.5f,4.0f); } particleEmitter[0]->setForce(3.0f,3.5f);
// Group particleGroup = Group::create(particleModel,20000); particleGroup->setRenderer(particleRenderer); for (int i = 0; i < NB_EMITTERS; ++i) particleGroup->addEmitter(particleEmitter[i]); particleGroup->setCustomUpdate(&splash); particleGroup->setGravity(gravity); particleGroup->setFriction(0.7f); particleGroup->enableAABBComputing(true);
// System particleSystem = System::create(); particleSystem->addGroup(particleGroup); particleSystem->enableAABBComputing(true); particleSystem->computeAABB();
My render: - Code:
-
glDepthFunc(GL_LEQUAL); glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST);
glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glEnable(GL_TEXTURE_2D);
glClearColor(0.0f,0.68f,0.85f,1.0f); glViewport(0,0,1024, 768);
//glDepthMask(GL_TRUE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45,(float)1024/(float)768,0.01f,80.0f);
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
glTranslatef(0.0f,0.0f,-10); //glRotatef(0,1.0f,0.0f,0.0f); //glRotatef(0,0.0f,1.0f,0.0f);
particleSystem->render(); //particleGroup->render();
particleSystem->update(0.001f); //particleGroup->update(0.001f);
Vector3D AABBMin = particleGroup->getAABBMin(); Vector3D AABBMax = particleGroup->getAABBMax();
glDisable(GL_TEXTURE_2D); glBegin(GL_LINES); glColor3f(1.0f,0.0f,0.0f);
glVertex3f(AABBMin.x,AABBMin.y,AABBMin.z); glVertex3f(AABBMax.x,AABBMin.y,AABBMin.z); glVertex3f(AABBMin.x,AABBMin.y,AABBMin.z); glVertex3f(AABBMin.x,AABBMax.y,AABBMin.z);
glVertex3f(AABBMin.x,AABBMin.y,AABBMin.z); glVertex3f(AABBMin.x,AABBMin.y,AABBMax.z);
glVertex3f(AABBMax.x,AABBMax.y,AABBMax.z); glVertex3f(AABBMin.x,AABBMax.y,AABBMax.z);
glVertex3f(AABBMax.x,AABBMax.y,AABBMax.z); glVertex3f(AABBMax.x,AABBMin.y,AABBMax.z);
glVertex3f(AABBMax.x,AABBMax.y,AABBMax.z); glVertex3f(AABBMax.x,AABBMax.y,AABBMin.z);
glVertex3f(AABBMin.x,AABBMin.y,AABBMax.z); glVertex3f(AABBMax.x,AABBMin.y,AABBMax.z);
glVertex3f(AABBMin.x,AABBMin.y,AABBMax.z); glVertex3f(AABBMin.x,AABBMax.y,AABBMax.z);
glVertex3f(AABBMin.x,AABBMax.y,AABBMin.z); glVertex3f(AABBMax.x,AABBMax.y,AABBMin.z);
glVertex3f(AABBMin.x,AABBMax.y,AABBMin.z); glVertex3f(AABBMin.x,AABBMax.y,AABBMax.z);
glVertex3f(AABBMax.x,AABBMin.y,AABBMin.z); glVertex3f(AABBMax.x,AABBMax.y,AABBMin.z);
glVertex3f(AABBMax.x,AABBMin.y,AABBMin.z); glVertex3f(AABBMax.x,AABBMin.y,AABBMax.z); glEnd();
| |
|