void ParticleScene::DoTick( U32 deltaTime ) { for( int i=0; i<buttonArr.Size(); ++i ) { ToggleButton* toggle = buttonArr[i]->ToToggleButton(); if ( toggle && toggle->Down() ) { Vector3F pos = { SIZE/2, 0.01f, SIZE/2 }; Vector3F normal = { 0, 1, 0 }; //Vector3F dir = { 1, 0, 0 }; ParticleDef* def = &particleDefArr[i]; if ( def->spread == ParticleDef::SPREAD_POINT ) { engine->particleSystem->EmitPD( *def, pos, normal, deltaTime ); } else { Rectangle3F r; r.Set( pos.x-0.5f, pos.y, pos.z-0.5f, pos.x+0.5f, pos.y, pos.z+0.5f ); engine->particleSystem->EmitPD( *def, r, normal, deltaTime ); } } } }
void DecalMesh::SetPosV( const Vector3F& newPos, const Matrix4& _newRot ) { float zRot = _newRot.CalcRotationAroundAxis(2); zRot = NormalizeAngleDegrees( zRot ); Matrix4 newRot; newRot.SetZRotation( zRot ); // We don't need to ask the container (the TerrainMesh) where we // will be, since the decal is patched to the terrain. if ( newPos.x != pos.x || newPos.y != pos.y || newRot != rotation || !InList() ) { pos = newPos; rotation = newRot; Rectangle3F base; base.Set( -size / 2.0f, -size / 2.0f, (TERRAIN_MIN+0.01f), size / 2.0f, size / 2.0f, (TERRAIN_MAX-0.01f) ); if ( InList() ) ListRemove(); ComputeTransform(); CalcAABB( base ); Lilith3D::Instance()->GetQuadTree()->AddMesh( this ); // Compute the texture matrix for this decal. Matrix4 center, inverse, scale; Transform().Invert( &inverse ); // position the texture with the mesh center.SetTranslation( 0.5f, 0.5f, 0.5f ); // center the decal scale.SetScale( 1.0f / size ); texMat = center * scale * inverse; } }
Lilith3D::Lilith3D( U32 msecPerDay, U32 msecStart ) : timeClock( msecPerDay, msecStart ), pointLightSentinel( InnerCircle<PointLight>::SENTINEL ) { int viewPort[4]; glGetIntegerv(GL_VIEWPORT, viewPort); surfaceWidth = viewPort[2]-viewPort[0]; surfaceHeight = viewPort[3]-viewPort[1]; InitShadows(); instance = this; displayPerfData = false; infoDisplay = INFO_DEFAULT; renderMode = RENDER_FLAT; mapSize = 0.0f; targetMapSize = 0.0f; // Lilith doesn't have a performance meauring system (yet), so // use the shader flag as a performance measure for now. bool powerful = ShaderManager::Instance()->PowerFragments(); renderFoliage = powerful; renderShadows = true; // I like the shadows too much to default them off Rectangle3F bounds; bounds.Set( 0.0f, 0.0f, TERRAIN_MIN, (float) MAPSIZE, (float) MAPSIZE, WORLD_CEILING ); terrainMesh = new TerrainMesh(); quadTree = new QuadTree(); // quadtree depends on the terrain, construct 2nd camera.SetCamera( 20.0f, 0.0f, 32.0f, 55.0f, 23.0f ); //camera.SetCamera( 20.0f, 0.0f, 32.0f, 0.0f, 0.0f, 0.0f ); sequenceStart = 0; sequenceLength = 0; // ------- Set up the perspective ----------- GLfloat ratio; ratio = ( float )surfaceWidth / ( float )surfaceHeight; glViewport( 0, 0, surfaceWidth, surfaceHeight ); glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); // The further the near plane can be pushed out, the better the resolution // that can be obtained. gluPerspective( VIEW_ANGLE, ratio, 1.0f, FAR_PLANE_DISTANCE ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); terrainDecor = new TerrainDecor(); gravityParticles = new GravParticles(); rainDropParticles = new RainDropParticles(); rainSplashParticles = new RainSplashParticles(); RegisterParticleSystem( gravityParticles ); RegisterParticleSystem( rainDropParticles ); RegisterParticleSystem( rainSplashParticles ); GLLOG(( "Sizeof Vertex=%d\n", sizeof( Vertex ) )); }