void UniformSingleColorNoiseTextureGenerator::FillTexture( LockedTexture& texture ) { float density = m_fDensity; float min_val = m_fMin; float max_val = m_fMax; float range = m_fMax - m_fMin; float r = m_Color.red; float g = m_Color.green; float b = m_Color.blue; const int w = texture.GetWidth();//dest_bitmap_buffer.size_x(); const int h = w;// Assumes that the textute is square. dest_bitmap_buffer.size_y(); for( int y=0; y<h; y++ ) { for( int x=0; x<w; x++ ) { if( density < RangedRand( 0.0f, 0.1f ) ) continue; float val = RangedRand( min_val, max_val ); clamp( val, 0.0f, 1.0f ); // texture.SetPixel( x, y, SFloatRGBAColor( val, val, val, 1.0f ) ); texture.SetPixelARGB32( x, y, SFloatRGBAColor( r, g, b, val ).GetARGB32() ); } } }
inline LensFlareComponent::LensFlareComponent() : m_TexIndex(0), m_fScaleFactor(1.0f), m_fDistFactor(1.0f), m_Color(SFloatRGBAColor(1,1,1,1)), m_fRadius(1.0f) {}
void CBSPMapData_LW::CreateTriangleMesh() { m_vecMesh.resize(1); C3DMeshModelArchive &archive = m_vecMesh[0]; CMMA_VertexSet& vert_set = archive.GetVertexSet(); vector<unsigned int>& index_buffer = archive.GetVertexIndex(); vector<CMapFace> *apFaceBuffer[2] = { &m_aMainFace, &m_aInteriorFace }; for( int i=0; i<2; i++ ) { vector<CMapFace>& vecFace = *apFaceBuffer[i]; size_t j, num_faces = vecFace.size(); for( j=0; j<num_faces; j++ ) { CMapFace& face = vecFace[j]; if( face.ReadTypeFlag(CMapFace::TYPE_INVISIBLE) ) continue; int index_offset = vert_set.vecPosition.size(); int k, num_verts = face.GetNumVertices(); for( k=0; k<num_verts; k++ ) { vert_set.vecPosition.push_back( face.GetVertex(k) ); vert_set.vecNormal.push_back( face.GetMAPVERTEX(k).vNormal ); } int num_triangles = num_verts - 2; for( k=0; k<num_triangles; k++ ) { index_buffer.push_back( index_offset ); index_buffer.push_back( index_offset + k + 1 ); index_buffer.push_back( index_offset + k + 2 ); } } } vert_set.m_VertexFormatFlag = CMMA_VertexSet::VF_POSITION | CMMA_VertexSet::VF_COLORVERTEX | CMMA_VertexSet::VF_NORMAL; vert_set.vecDiffuseColor.resize( vert_set.vecPosition.size(), SFloatRGBAColor( 1.0f, 1.0f, 1.0f, 1.0f ) ); // triangle set CMMA_TriangleSet tri_set; tri_set.m_iMinIndex = 0; tri_set.m_iNumTriangles = index_buffer.size() / 3; tri_set.m_iStartIndex = 0; tri_set.m_iNumVertexBlocksToCover = vert_set.vecPosition.size(); archive.GetTriangleSet().push_back( tri_set ); // material archive.GetMaterial().push_back( CMMA_Material() ); archive.UpdateAABBs(); }