Ejemplo n.º 1
0
// write the frame ranges and statistic string on the root
// Also call the post callbacks
void AbcWriteJob::postCallback(double iFrame)
{
	std::string statsStr = "";

	addToString(statsStr, "TransStaticNum", mStats.mTransStaticNum);
	addToString(statsStr, "TransAnimNum", mStats.mTransAnimNum);
	addToString(statsStr, "TransColNum", mStats.mTransColNum);

	if (statsStr.length() > 0)
	{
		Alembic::Abc::OStringProperty stats(mRoot.getTop().getProperties(),
			"statistics");
		stats.set(statsStr);
	}

	if (mTransTimeIndex != 0)
	{
		MString propName;
		propName += static_cast<int>(mTransTimeIndex);
		propName += ".samples";
		Alembic::Abc::OUInt32Property samp(mRoot.getTop().getProperties(),
			propName.asChar());
		samp.set(mTransSamples);
	}

	MBoundingBox bbox;

	processCallback(mArgs.melPostCallback, true, iFrame, bbox);
	processCallback(mArgs.pythonPostCallback, false, iFrame, bbox);
}
Ejemplo n.º 2
0
int FontMatchInfoObject::
addToString(const char *&str, int &strLen, int &strMaxLen, struct fmi_attr_store *ele)
{
	const char *value;
	char *newValue = NULL;
	char strValue[64];	// XXX There must be a better way to do this.
	int ret = 0;

	addToString(str, strLen, strMaxLen, FMI_FONTPART_SEPERATOR);
	if (count() > MAX_STANDARD_ATTRIBUTES)
	{
		// Add the attribute also
		addToString(str, strLen, strMaxLen, ele->attr);
		addToString(str, strLen, strMaxLen, ":");
	}
	
	if (ele->valueType == FMI_TYPE_JINT)
	{
		strValue[0] = '\0';
		if (ele->u.intValue > 0)
		{
			sprintf(strValue, "%d", ele->u.intValue);
		}
		value = strValue;
	}
	else
	{
		// Escape {:-*} in value. These have special meaning to us.
		value = ele->u.stringValue;
		if (value && *value)
		{
			newValue = EscapeString(value, needsEscape);
			if (!newValue)
			{
				// ERROR: No memory
				return (-1);
			}
			value = newValue;
		}
	}
	ret = addToString(str, strLen, strMaxLen, value);
	if (newValue)
	{
		delete[] newValue;
	}
	return (ret);
}
Ejemplo n.º 3
0
const char * FontMatchInfoObject::
describe(void)
{
	if (stringRepresentation != NULL)
	{
		return (stringRepresentation);
	}
	
	wfListElement *tmp = head;
	stringLen = 0;
	stringMaxLen = 0;
	
	for (; tmp; tmp = tmp->next)
	{
		struct fmi_attr_store *ele = (struct fmi_attr_store *)tmp->item;
		addToString(stringRepresentation, stringLen, stringMaxLen, ele);
	}
	return (stringRepresentation);
}   
Ejemplo n.º 4
0
int FontMatchInfoObject::
addAttribute(const char *attr, jint value)
{
	struct fmi_attr_store *ele = new fmi_attr_store;
	if (!ele)
	  {
		// no memory
		return (-1);
	  }

	ele->attr = attr;
	ele->valueType = FMI_TYPE_JINT;
	ele->u.intValue = value;
	add(ele);

	// Sync stringRepresentation
	addToString(stringRepresentation, stringLen, stringMaxLen, ele);
	
	return (0);
}
Ejemplo n.º 5
0
// write the frame ranges and statistic string on the root
// Also call the post callbacks
void AbcWriteJob::postCallback(double iFrame)
{
    std::string statsStr = "";

    addToString(statsStr, "SubDStaticNum", mStats.mSubDStaticNum);
    addToString(statsStr, "SubDAnimNum", mStats.mSubDAnimNum);
    addToString(statsStr, "SubDStaticCVs", mStats.mSubDStaticCVs);
    addToString(statsStr, "SubDAnimCVs", mStats.mSubDAnimCVs);
    addToString(statsStr, "SubDStaticFaces", mStats.mSubDStaticFaces);
    addToString(statsStr, "SubDAnimFaces", mStats.mSubDAnimFaces);

    addToString(statsStr, "PolyStaticNum", mStats.mPolyStaticNum);
    addToString(statsStr, "PolyAnimNum", mStats.mPolyAnimNum);
    addToString(statsStr, "PolyStaticCVs", mStats.mPolyStaticCVs);
    addToString(statsStr, "PolyAnimCVs", mStats.mPolyAnimCVs);
    addToString(statsStr, "PolyStaticFaces", mStats.mPolyStaticFaces);
    addToString(statsStr, "PolyAnimFaces", mStats.mPolyAnimFaces);

    addToString(statsStr, "CurveStaticNum", mStats.mCurveStaticNum);
    addToString(statsStr, "CurveStaticCurves", mStats.mCurveStaticCurves);
    addToString(statsStr, "CurveAnimNum", mStats.mCurveAnimNum);
    addToString(statsStr, "CurveAnimCurves", mStats.mCurveAnimCurves);
    addToString(statsStr, "CurveStaticCVs", mStats.mCurveStaticCVs);
    addToString(statsStr, "CurveAnimCVs", mStats.mCurveAnimCVs);

    addToString(statsStr, "PointStaticNum", mStats.mPointStaticNum);
    addToString(statsStr, "PointAnimNum", mStats.mPointAnimNum);
    addToString(statsStr, "PointStaticCVs", mStats.mPointStaticCVs);
    addToString(statsStr, "PointAnimCVs", mStats.mPointAnimCVs);

    addToString(statsStr, "NurbsStaticNum", mStats.mNurbsStaticNum);
    addToString(statsStr, "NurbsAnimNum", mStats.mNurbsAnimNum);
    addToString(statsStr, "NurbsStaticCVs", mStats.mNurbsStaticCVs);
    addToString(statsStr, "NurbsAnimCVs", mStats.mNurbsAnimCVs);

    addToString(statsStr, "TransStaticNum", mStats.mTransStaticNum);
    addToString(statsStr, "TransAnimNum", mStats.mTransAnimNum);

    addToString(statsStr, "LocatorStaticNum", mStats.mLocatorStaticNum);
    addToString(statsStr, "LocatorAnimNum", mStats.mLocatorAnimNum);

    addToString(statsStr, "CameraStaticNum", mStats.mCameraStaticNum);
    addToString(statsStr, "CameraAnimNum", mStats.mCameraAnimNum);

    if (statsStr.length() > 0)
    {
        Alembic::Abc::OStringProperty stats(mRoot.getTop().getProperties(),
            "statistics");
        stats.set(statsStr);
    }

    if (mTransTimeIndex != 0)
    {
        MString propName;
        propName += static_cast<int>(mTransTimeIndex);
        propName += ".samples";
        Alembic::Abc::OUInt32Property samp(mRoot.getTop().getProperties(),
            propName.asChar());
        samp.set(mTransSamples);
    }

    if (mShapeTimeIndex != 0 && mShapeTimeIndex != mTransTimeIndex)
    {
        MString propName;
        propName += static_cast<int>(mShapeTimeIndex);
        propName += ".samples";
        Alembic::Abc::OUInt32Property samp(mRoot.getTop().getProperties(),
            propName.asChar());
        samp.set(mShapeSamples);
    }

    MBoundingBox bbox;

    if (mArgs.melPostCallback.find("#BOUNDS#") != std::string::npos ||
        mArgs.pythonPostCallback.find("#BOUNDS#") != std::string::npos ||
        mArgs.melPostCallback.find("#BOUNDSARRAY#") != std::string::npos ||
        mArgs.pythonPostCallback.find("#BOUNDSARRAY#") != std::string::npos)
    {
        util::ShapeSet::const_iterator it = mArgs.dagPaths.begin();
        const util::ShapeSet::const_iterator end = mArgs.dagPaths.end();
        for (; it != end; it ++)
        {
            mCurDag = *it;

            MMatrix eMInvMat;
            if (mArgs.worldSpace)
            {
                eMInvMat.setToIdentity();
            }
            else
            {
                eMInvMat = mCurDag.exclusiveMatrixInverse();
            }

            bbox.expand(getBoundingBox(iFrame, eMInvMat));
        }
    }

    processCallback(mArgs.melPostCallback, true, iFrame, bbox);
    processCallback(mArgs.pythonPostCallback, false, iFrame, bbox);
}
Ejemplo n.º 6
0
void DataRecord_t::printRecord() const
{
  String str;
  addToString(str);
  DIAGPRINTLN(str.c_str());
}
Ejemplo n.º 7
0
void flashback(char* path) {

	//////////////////////////////////////initialize music, video and text/////////////////////////////////////

	SDL_Surface *screen; 
	SDL_Window *window;
	SDL_Surface *text;
	SDL_Rect paper = { 560, 140, 800, 800 };

	char *fullString = ReadFile(path);
	char *string; 
	int cnt = 0;
	int quit = 1;

	Mix_Music *typing = NULL;

	//init sdl mixer
	if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { 
		printf("SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError());  
	}

	//load music
	typing = Mix_LoadMUS("sounds/typing.mp3");
	if (NULL == typing) {
		printf("Failed to load low sound effect! SDL_mixer Error: %s\n", Mix_GetError());
	}
	Mix_PlayMusic(typing, -1);

	// init video
	SDL_Init(SDL_INIT_VIDEO); 

	// create the window
	
	window = SDL_CreateWindow("popup", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1920, 1080, SDL_WINDOW_BORDERLESS);

	// Initialize SDL_ttf library
	if (TTF_Init() != 0)
	{
		fprintf(stderr, "Init TTF failed! SDL_Error: %s", SDL_GetError());
	}

	// Load a font
	TTF_Font *font;
	font = TTF_OpenFont("FreeMonoBold.ttf", 24);
	if (font == NULL)
	{
		fprintf(stderr, "loading font failed! SDL_Error: %s", SDL_GetError());
	}

	// draw directly to the screen
	screen = SDL_GetWindowSurface(window);

	SDL_Event end;

	//////////////////////////////////////render Text on Screen/////////////////////////////////////
	while (1) {
		
		while(SDL_PollEvent(&end));

		string = addToString(cnt, fullString);
		cnt++;

		//write text to surface
		SDL_Color text_color = { 255, 255, 255 };
		text = TTF_RenderText_Blended_Wrapped(font,
			string,
			text_color,
			1000);


		SDL_FillRect(screen, NULL, 0x000000); 		//overwrite screen in black
		SDL_BlitSurface(text, NULL, screen, &paper);	// blit it to the screen
		

		SDL_UpdateWindowSurface(window);

		// show image for 60 ms
		SDL_Delay(60);


		//////////////////////////////////////Skip text on tap any key//////////////////////////////////
		
		if (SDL_KEYDOWN == end.type || '\0' == fullString[cnt]) {

			Mix_HaltMusic();
			end.type = 0;
			SDL_FillRect(screen, NULL, 0x000000);

			text = TTF_RenderText_Blended_Wrapped(font,
				fullString,
				text_color,
				1000);
			SDL_BlitSurface(text, NULL, screen, &paper); 
			SDL_UpdateWindowSurface(window);
			Mix_HaltMusic();

 			while (1) {
				while(SDL_PollEvent(&end));
 				if (SDL_KEYDOWN == end.type) {
					quit = 0;
					break;
				}
			}
			break;	
		}
	}

	Mix_HaltMusic();
	Mix_FreeMusic(typing);
	typing = NULL;
	SDL_FreeSurface(text);
	SDL_FreeSurface(screen);
	SDL_DestroyWindow(window);
}