- newVerts.push_back( MeshData::Vertex( Vector3( tlx, baseLine, ZERO ),
- Vector2::ZERO,
- Vector3::ZERO ) );
-
- newVerts.push_back( MeshData::Vertex( Vector3( brx, baseLine, ZERO ),
- Vector2( u, ZERO ),
- Vector3::ZERO ) );
-
- newVerts.push_back( MeshData::Vertex( Vector3( tlx, baseLine + thickness, ZERO ),
- Vector2( ZERO, v ),
- Vector3::ZERO ) );
-
- newVerts.push_back( MeshData::Vertex( Vector3( brx, baseLine + thickness, ZERO ),
- Vector2( u, v ),
- Vector3::ZERO ) );
-
- newMeshData.SetVertices( newVerts );
- newMeshData.SetFaceIndices( mFace );
-
- if ( underlineColor == textColor )
- {
- mGlyphManager.StitchMesh( meshRecords[ index ].mMeshData, newMeshData );
- }
- else
- {
- MeshRecord record;
- newMeshData.SetMaterial( meshRecords[ index ].mMeshData.GetMaterial() );
- newMeshData.SetHasNormals( true );
- newMeshData.SetHasColor( false );
- newMeshData.SetHasTextureCoords( true );
- record.mMeshData = newMeshData;
- record.mAtlasId = meshRecords[ index ].mAtlasId;
- record.mColor = underlineColor;
- record.mIsUnderline = true;
- meshRecords.push_back( record );
- }
- }
- }
-
- MeshActor GenerateShadow( MeshRecord& meshRecord,
- const Vector2& shadowOffset,
- const Vector4& shadowColor )
- {
- // Scan vertex buffer to determine width and height of effect buffer needed
- MeshData::VertexContainer verts = meshRecord.mMeshData.GetVertices();
- float tlx = verts[ 0 ].x;
- float tly = verts[ 0 ].y;
- float brx = ZERO;
- float bry = ZERO;
-
- for ( uint32_t i = 0; i < verts.size(); ++i )
- {
- if ( verts[ i ].x < tlx )
- {
- tlx = verts[ i ].x;
- }
- if ( verts[ i ].y < tly )
- {
- tly = verts[ i ].y;
- }
- if ( verts[ i ].x > brx )
- {
- brx = verts[ i ].x;
- }
- if ( verts[ i ].y > bry )
- {
- bry = verts[ i ].y;
- }
- }
-
- float width = brx - tlx;
- float height = bry - tly;
- float divWidth = TWO / width;
- float divHeight = TWO / height;
-
- // Create a buffer to render to
- meshRecord.mBuffer = FrameBufferImage::New( width, height );
-
- // Create a mesh actor to contain the post-effect render
- MeshData::VertexContainer vertices;
- MeshData::FaceIndices face;
-
- vertices.push_back( MeshData::Vertex( Vector3( tlx + shadowOffset.x, tly + shadowOffset.y, ZERO ),
- Vector2::ZERO,
- Vector3::ZERO ) );
-
- vertices.push_back( MeshData::Vertex( Vector3( brx + shadowOffset.x, tly + shadowOffset.y, ZERO ),
- Vector2( ONE, ZERO ),
- Vector3::ZERO ) );
-
- vertices.push_back( MeshData::Vertex( Vector3( tlx + shadowOffset.x, bry + shadowOffset.y, ZERO ),
- Vector2( ZERO, ONE ),
- Vector3::ZERO ) );
-
- vertices.push_back( MeshData::Vertex( Vector3( brx + shadowOffset.x, bry + shadowOffset.y, ZERO ),
- Vector2::ONE,
- Vector3::ZERO ) );
-
- MeshData meshData;
- Material newMaterial = Material::New("effect buffer");
- newMaterial.SetDiffuseTexture( meshRecord.mBuffer );
- meshData.SetMaterial( newMaterial );
- meshData.SetVertices( vertices );
- meshData.SetFaceIndices( mFace );
- meshData.SetHasNormals( true );
- meshData.SetHasColor( false );
- meshData.SetHasTextureCoords( true );
- MeshActor actor = MeshActor::New( Mesh::New( meshData ) );
- actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
- actor.SetShaderEffect( mBgraShader );
- actor.SetFilterMode( FilterMode::LINEAR, FilterMode::LINEAR );
- actor.SetSortModifier( 0.1f ); // force behind main text
-
- // Create a sub actor to render once with normalized vertex positions
- MeshData newMeshData;
- MeshData::VertexContainer newVerts;
- MeshData::FaceIndices newFaces;
- MeshData::FaceIndices faces = meshRecord.mMeshData.GetFaces();
- for ( uint32_t i = 0; i < verts.size(); ++i )
- {
- MeshData::Vertex vertex = verts[ i ];
- vertex.x = ( ( vertex.x - tlx ) * divWidth ) - ONE;
- vertex.y = ( ( vertex.y - tly ) * divHeight ) - ONE;
- newVerts.push_back( vertex );
- }
-
- // Reverse triangle winding order
- uint32_t faceCount = faces.size() / 3;
- for ( uint32_t i = 0; i < faceCount; ++i )
- {
- uint32_t index = i * 3;
- newFaces.push_back( faces[ index + 2 ] );
- newFaces.push_back( faces[ index + 1 ] );
- newFaces.push_back( faces[ index ] );
+ vert.mPosition.x = tlx;
+ vert.mPosition.y = baseLine;
+ vert.mTexCoords.x = ZERO;
+ vert.mTexCoords.y = ZERO;
+ vert.mColor = underlineColor;
+ newMesh.mVertices.PushBack( vert );
+
+ vert.mPosition.x = brx;
+ vert.mPosition.y = baseLine;
+ vert.mTexCoords.x = u;
+ vert.mColor = underlineColor;
+ newMesh.mVertices.PushBack( vert );
+
+ vert.mPosition.x = tlx;
+ vert.mPosition.y = baseLine + thickness;
+ vert.mTexCoords.x = ZERO;
+ vert.mTexCoords.y = v;
+ vert.mColor = underlineColor;
+ newMesh.mVertices.PushBack( vert );
+
+ vert.mPosition.x = brx;
+ vert.mPosition.y = baseLine + thickness;
+ vert.mTexCoords.x = u;
+ vert.mColor = underlineColor;
+ newMesh.mVertices.PushBack( vert );
+
+ // Six indices in counter clockwise winding
+ newMesh.mIndices.PushBack( faceIndex + 1u );
+ newMesh.mIndices.PushBack( faceIndex );
+ newMesh.mIndices.PushBack( faceIndex + 2u );
+ newMesh.mIndices.PushBack( faceIndex + 2u );
+ newMesh.mIndices.PushBack( faceIndex + 3u );
+ newMesh.mIndices.PushBack( faceIndex + 1u );
+ faceIndex += 4;
+
+ Toolkit::Internal::AtlasMeshFactory::AppendMesh( meshRecords[ index ].mMesh, newMesh );