void ofxLetterTextObject::rebuildLetters()
{	
	int     currentWordID;

	cleanupLetters();

	if (words.size() > 0) {

		for(int a=0; a < lines.size(); a++)
		{
			for(int w=0; w < lines[a].wordsID.size(); w++)
			{
				currentWordID = lines[a].wordsID[w];
				//Make letters.
				for(int p=0; p < words[currentWordID].charPositions.size(); p++){
					//Add word position to char position.
					ofVec3f pos((words[currentWordID].pos.x + words[currentWordID].charPositions[p].x) * scaleFactor, 
								 (words[currentWordID].pos.y + words[currentWordID].charPositions[p].y) * scaleFactor,
								 0);
					
					//Create letter text letter and pass position and char to it.
					ofxLetterTextObjectLetter *letter = new ofxLetterTextObjectLetter(font, words[currentWordID].rawWord.c_str()[p], pos.x, pos.y, scaleFactor); 					
					letter->setTrans(pos.x, pos.y, pos.z);
					letter->setColor(words[currentWordID].color.r, words[currentWordID].color.g, words[currentWordID].color.b, words[currentWordID].color.a);	//Gotta grab word color or else it gets reset to white.					
					letters.push_back(letter);
					addChild(letter);								
				}
			}
		}
	}
}
예제 #2
0
void ofxLetterTextObject::rebuildLetters()
{	
	int     currentWordID;

	cleanupLetters();

	if (words.size() > 0) {

		for(int a=0; a < lines.size(); a++)
		{
			for(int w=0; w < lines[a].wordsID.size(); w++)
			{
				currentWordID = lines[a].wordsID[w];
				//Make letters.
				for(int p=0; p < words[currentWordID].charPositions.size(); p++){
					//Add word position to char position.
                    
                    
                    float xLocation = (words[currentWordID].pos.x + words[currentWordID].charPositions[p].x) * scaleFactor;
                    float yLocation = (words[currentWordID].pos.y + words[currentWordID].charPositions[p].y) * scaleFactor;
                    
                    
					ofVec3f pos( xLocation,	yLocation, 0);
					
                    //Check for special unicode sequences, as defined in buildMappedChars() //eg 0701412
                    char *cSeq = NULL; //getFont()->getMappedCharSequence(words[currentWordID].rawWord, p);
                    if(cSeq==NULL){    //If, not a mapped char sequence, just grab character straight from word.
                        cSeq = new char[2];
                        cSeq[0] = words[currentWordID].rawWord.c_str()[p];
                        cSeq[1] = 0;
                    }
                    
					//Create letter text letter and pass position and char to it.
					//ofxLetterTextObjectLetter *letter = new ofxLetterTextObjectLetter(font, words[currentWordID].rawWord.c_str()[p], pos.x, pos.y, scaleFactor); 					
                    ofxLetterTextObjectLetter *letter = new ofxLetterTextObjectLetter(font, cSeq, pos.x, pos.y, scaleFactor);       //eg 070412
					letter->setTrans(pos.x, pos.y, pos.z);
					letter->setColor(words[currentWordID].color.r, words[currentWordID].color.g, words[currentWordID].color.b, words[currentWordID].color.a);	//Gotta grab word color or else it gets reset to white.					
					letters.push_back(letter);
                    letter->letterWidth =
					addChild(letter);								
				}
			}
		}
	}
}