Ejemplo n.º 1
0
WORD	MTime::DateFormatAlt(LPTSTR ptszTimeFormat, WORD cchTimeFormat)
{
	if (!ptszTimeFormat || !cchTimeFormat)
		return 0;

	WORD wRes = DateFormat(ptszTimeFormat, cchTimeFormat);
	if (wRes != 0)
		return wRes;

	SYSTEMTIME AltSysTime = _SysTime;
	MTime mtNow;
	mtNow.GetLocalTime();
	AltSysTime.wYear=mtNow.Year();

	if ((cchTimeFormat = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &AltSysTime, NULL, ptszTimeFormat, cchTimeFormat)) == 0) {
		*ptszTimeFormat = 0;
		return 0;
	}
	
	TCHAR tszText[10];
	_itot(mtNow.Year(), tszText, 10);
	TCHAR * tszYear = _tcsstr(ptszTimeFormat, tszText);

	if (tszYear && mir_tstrlen(tszYear) == 4)
		mir_tstrcpy(tszYear, _T("????"));
	else {
		*ptszTimeFormat = 0;
		return 0;
	}
	
	return cchTimeFormat;
}
Ejemplo n.º 2
0
MStatus sweptEmitter::emitCountPerPoint
	(
		const MPlug &plug,
		MDataBlock &block,
		int length,					// length of emitCountPP
		MIntArray &emitCountPP		// output: emitCount for each point
	)
//
//	Descriptions:
//		Compute emitCount for each point where new particles come from.
//
{
	MStatus status;

	int plugIndex = plug.logicalIndex( &status );
	McheckErr(status, "ERROR in emitCountPerPoint: when plug.logicalIndex.\n");

	// Get rate and delta time.
	//
	double rate = rateValue( block );
	MTime dt = deltaTimeValue( plugIndex, block );

	// Compute emitCount for each point.
	//
	double dblCount = rate * dt.as( MTime::kSeconds );

	int intCount = (int)dblCount;
	for( int i = 0; i < length; i++ )
	{
		emitCountPP.append( intCount );
	}

	return( MS::kSuccess );
}
Ejemplo n.º 3
0
/**
 * This is a notification handler for changed contact settings.
 * If any anniversary setting has changed for a meta sub contact,
 * the parental meta contact is rescanned.
 *
 * @param	hContact		- handle of the contect the notification was fired for
 * @param	pdbcws			- pointer to a DBCONTACTWRITESETTING structure
 *
 * @return	This function must return 0 in order to continue in the notification chain.
 **/
static INT OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcws)
{
    if (hContact &&										// valid contact not owner!
            ghCListIA &&								// extraicons active
            pdbcws && pdbcws->szSetting &&				// setting structure valid
            (pdbcws->value.type < DBVT_DWORD) &&		// anniversary datatype
            (gRemindOpts.RemindState != REMIND_OFF) &&	// reminder active
            (!strncmp(pdbcws->szSetting, "Birth", 5) ||
             !strncmp(pdbcws->szSetting, "Anniv", 5) ||
             !strncmp(pdbcws->szSetting, "DOB", 3)))
    {
        HANDLE hMeta = DB::MetaContact::GetMeta(hContact);
        WORD LastAnswer = IDNONE;
        CEvent evt;
        MTime now;

        // check metacontact instead of subcontact
        if (hMeta)
        {
            hContact = hMeta;
        }
        now.GetLocalTime();
        if (!strcmp(pdbcws->szModule, SvcReminderGetMyBirthdayModule()))
        {
            CheckContact(hContact, now, evt, FALSE, &LastAnswer);
        }
        else
        {
            CheckContact(hContact, now, evt, FALSE, 0);
        }
    }
    return 0;
}
Ejemplo n.º 4
0
bool MSystemTime::Parse(const TCHAR *s, const TCHAR **endptr/* = NULL*/)
{
    MDate d;
    MTime t;

    if (endptr)
        *endptr = NULL;

    if (d.Parse(s, &s))
    {
        while (*s && !MzcIsCharDigit(*s))
            s++;

        if (t.Parse(s, &s))
        {
            SetDate(d);
            SetTimeOfDay(t);
            if (endptr)
                *endptr = s;
        }
        else
        {
            SetDate(d);
            ClearTimeOfDay();
            if (endptr)
                *endptr = s;
        }
        return true;
    }
    return false;
}
Ejemplo n.º 5
0
ConstObjectPtr SceneShape::readSceneShapeAttribute( const MDagPath &p, SceneInterface::Name attributeName )
{
	MDagPath dagPath;
	SceneShape *sceneShape = findScene( p, false, &dagPath );
	if ( !sceneShape )
	{
		return 0;
	}
	
	MFnDagNode fnChildDag( dagPath );
	if( attributeName == LinkedScene::linkAttribute )
	{
		if( !fnChildDag.isIntermediateObject() )
		{
			return readSceneShapeLink(p);
		}
	}
	
	ConstSceneInterfacePtr scene = sceneShape->getSceneInterface();
	if ( !scene )
	{
		return 0;
	}
	
	MPlug timePlug = fnChildDag.findPlug( aTime );
	MTime time;
	timePlug.getValue( time );
	return scene->readAttribute( attributeName, time.as( MTime::kSeconds ) );
}
Ejemplo n.º 6
0
	// This method clears the list and adds contacts again, according to the current filter settings.
	void RebuildList()
	{
		LPSTR pszProto;
		MTime mtNow;
		MAnnivDate ad;
		int i = 0;
		DWORD age = 0;
		WORD wDaysBefore = db_get_w(NULL, MODNAME, SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET);
		WORD numMale = 0;
		WORD numFemale = 0;
		WORD numContacts = 0;
		WORD numBirthContacts = 0;

		ShowWindow(_hList, SW_HIDE);
		DeleteAllItems();
		mtNow.GetLocalTime();

		// insert the items into the list
		for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
			// ignore meta subcontacts here, as they are not interesting.
			if (!db_mc_isSub(hContact)) {
				// filter protocol
				pszProto = Proto_GetBaseAccountName(hContact);
				if (pszProto) {
					numContacts++;
					switch (GenderOf(hContact, pszProto)) {
					case 'M':
						numMale++;
						break;
					case 'F':
						numFemale++;
					}

					if (!ad.DBGetBirthDate(hContact, pszProto)) {
						age += ad.Age(&mtNow);
						numBirthContacts++;

						// add birthday
						if ((_filter.bFilterIndex != FILTER_ANNIV) && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto)))
							AddRow(hContact, pszProto, ad, mtNow, wDaysBefore);
					}

					// add anniversaries
					if (_filter.bFilterIndex != FILTER_BIRTHDAY && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) 
						for (i = 0; !ad.DBGetAnniversaryDate(hContact, i); i++)
							if (!_filter.pszAnniv || !mir_tstrcmpi(_filter.pszAnniv, ad.Description()))
								AddRow(hContact, pszProto, ad, mtNow, wDaysBefore);
				}
			}
		}
		ListView_SortItemsEx(_hList, (CMPPROC)cmpProc, this);
		ShowWindow(_hList, SW_SHOW);

		// display statistics
		SetDlgItemInt(_hDlg, TXT_NUMBIRTH, numBirthContacts, FALSE);
		SetDlgItemInt(_hDlg, TXT_NUMCONTACT, numContacts, FALSE);
		SetDlgItemInt(_hDlg, TXT_FEMALE, numFemale, FALSE);
		SetDlgItemInt(_hDlg, TXT_MALE, numMale, FALSE);
		SetDlgItemInt(_hDlg, TXT_AGE, numBirthContacts > 0 ? (age - (age % numBirthContacts)) / numBirthContacts : 0, FALSE);
	}
void Exporter::RecursiveJointExtraction(MFnTransform& joint, int parentIndex){

	Bone output;
	output.parent = parentIndex;

	output.invBindPose = joint.transformation().asMatrixInverse().matrix;

	MItDependencyNodes matIt(MFn::kAnimCurve);
	while (!matIt.isDone())
	{
		MFnAnimCurve animCurve(matIt.item());

		if (!strcmp(animCurve.name().substring(0, joint.name().length() - 1).asChar(), joint.name().asChar())){

			cout << animCurve.name().asChar() << endl;
			std::string type = animCurve.name().substring(joint.name().length(), animCurve.name().length()).asChar();
			output.frames.resize(animCurve.time(animCurve.numKeys() - 1).value());
			for (int i = 0; i < output.frames.size(); i++)
			{
				MTime time;
				time.setValue(i);
				output.frames[i].time = time.value();
				if (!strcmp(type.c_str(), "_translateX")){
					cout << animCurve.evaluate(time) << endl;
					output.frames[i].trans.x = animCurve.evaluate(time);
				}
				if (!strcmp(type.c_str(), "_translateY")){
					cout << animCurve.evaluate(time) << endl;
					output.frames[i].trans.y = animCurve.evaluate(time);
				}
				if (!strcmp(type.c_str(), "_translateZ")){
					cout << animCurve.evaluate(time) << endl;
					output.frames[i].trans.z = animCurve.evaluate(time);
				}
				if (!strcmp(type.c_str(), "_rotateX")){
					cout << animCurve.evaluate(time) << endl;
					output.frames[i].rot.x = animCurve.evaluate(time);
				}
				if (!strcmp(type.c_str(), "_rotateY")){
					cout << animCurve.evaluate(time) << endl;
					output.frames[i].rot.y = animCurve.evaluate(time);
				}
				if (!strcmp(type.c_str(), "_rotateZ")){
					cout << animCurve.evaluate(time) << endl;
					output.frames[i].rot.z = animCurve.evaluate(time);
				}
			}
		}
		matIt.next();
	}


	scene_.skeleton.push_back(output);
	int children = joint.childCount();
	int parent = scene_.skeleton.size() - 1;
	for (int i = 0; i < children; i++)
		RecursiveJointExtraction(MFnTransform(joint.child(i)), parent);

};
 // -------------------------------------------
 MTime AnimationHelper::animationEndTime()
 {
     MTime time ( MAnimControl::currentTime() );
     double result;
     MGlobal::executeCommand ( "playbackOptions -q -" TEND, result );
     time.setValue ( result );
     return time;
 }
Ejemplo n.º 9
0
INT_PTR GetContactLocalTime_old(WPARAM wParam, LPARAM lParam)
{
    MTime	now;
    now.GetLocalTime(wParam);

    LPSYSTEMTIME pSystemTime = (LPSYSTEMTIME)lParam;
    *pSystemTime = now.SystemTime();
    return 0;
}
    // -------------------------------------------
    void AnimationHelper::generateSamplingFunction()
    {
        mSamplingTimes.clear();

        // Avoid any potential precision accumulation problems by using the MTime class as an iterator
        MTime startT = animationStartTime();
        MTime endT = animationEndTime();
        for ( MTime currentT = startT; currentT <= endT; ++currentT )
        {
            mSamplingTimes.push_back ( ( float ) currentT.as ( MTime::kSeconds ) );
        }
    }
Ejemplo n.º 11
0
/**
 * This function is the notification handler for clist extra icons to be applied for a contact.
 *
 * @param	hContact		- handle to the contact whose extra icon is to apply
 * @param	lParam			- not used
 *
 * @return	This function must return 0 in order to continue in the notification chain.
 **/
INT OnCListApplyIcon(HANDLE hContact, LPARAM)
{
    if (gRemindOpts.RemindState != REMIND_OFF)
    {
        CEvent evt;
        MTime now;

        now.GetLocalTime();
        CheckContact(hContact, now, evt, FALSE);
    }
    return 0;
}
Ejemplo n.º 12
0
MStatus testNucleusNode::compute(const MPlug &plug, MDataBlock &data)
{
	MStatus stat;

	if ( plug == nextState )
	{
        
        //get the value of the currentTime 
        MTime currTime = data.inputValue(currentTime).asTime();        
        MObject inputData;
        //pull on start state or current state depending on the current time.
        if(currTime.value() <= 0.0) {
            MArrayDataHandle multiDataHandle = data.inputArrayValue(startState);
            multiDataHandle.jumpToElement(0);
            inputData =multiDataHandle.inputValue().data();
        }
        else {
            MArrayDataHandle multiDataHandle = data.inputArrayValue(currentState);
            multiDataHandle.jumpToElement(0);
            inputData =multiDataHandle.inputValue().data();
        }                
                
        MFnNObjectData inputNData(inputData);                
        MnCloth * nObj = NULL;
        inputNData.getObjectPtr(nObj);        
        
        MFloatPointArray points;
        nObj->getPositions(points);
        unsigned int ii;
        for(ii=0;ii<points.length();ii++) {            
            points[ii].y = (float) sin(points[ii].x + currTime.value()*4.0f*(3.1415f/180.0f));
        }
        nObj->setPositions(points);

        delete nObj;        
        data.setClean(plug);
	}
	else if ( plug == currentState )
	{        
	    data.setClean(plug);

	}
    else if (plug == startState) {        
	    data.setClean(plug);
    }
    else {
		stat = MS::kUnknownParameter;
	}
	return stat;
}
const MUID MMatchRuleAssassinate::ChooseCommander(int nTeam)
{
    MMatchStage* pStage = GetStage();
    if (pStage == NULL) return MUID(0,0);

    int nRedAliveCount, nBlueAliveCount, nChooseTeamCount;
    if (GetAliveCount(&nRedAliveCount, &nBlueAliveCount) == false) return MUID(0,0);
    if (nTeam == MMT_RED) {
        if (nRedAliveCount <= 0) return MUID(0,0);
        nChooseTeamCount = nRedAliveCount;
    }
    if (nTeam == MMT_BLUE) {
        if (nBlueAliveCount <= 0) return MUID(0,0);
        nChooseTeamCount = nBlueAliveCount;
    }


    if( m_bIsAdminCommander == true )
    {
        for(MUIDRefCache::iterator itor=pStage->GetObjBegin(); itor!=pStage->GetObjEnd(); itor++) {

            MMatchObject* pObj = (MMatchObject*)(*itor).second;

            if (pObj->GetEnterBattle() == false)
                continue;	// 배틀참가하고 있는 플레이어만 체크

            if (pObj->GetTeam() == nTeam && pObj->GetAccountInfo()->m_nUGrade == MMUG_ADMIN)
            {
                return pObj->GetUID();
            }
        }
    }


    MTime time;
    int nChoose = time.MakeNumber(1, nChooseTeamCount);

    int nCount = 0;
    for(MUIDRefCache::iterator itor=pStage->GetObjBegin(); itor!=pStage->GetObjEnd(); itor++) {
        MMatchObject* pObj = (MMatchObject*)(*itor).second;
        if (pObj->GetEnterBattle() == false) continue;	// 배틀참가하고 있는 플레이어만 체크
        if (pObj->GetTeam() == nTeam) {
            nCount++;
            if (nCount == nChoose) {
                return pObj->GetUID();
            }
        }
    }
    return MUID(0,0);
}
Ejemplo n.º 14
0
ConstObjectPtr SceneShape::readSceneShapeObject( const MDagPath &p )
{
	SceneShape *sceneShape = findScene( p, true );
	if ( !sceneShape )
	{
		return 0;
	}

	MPlug pTime( sceneShape->thisMObject(), aTime );
	MTime time;
	pTime.getValue( time );
	double t = time.as( MTime::kSeconds );
	return sceneShape->getSceneInterface()->readObject( t );
}
Ejemplo n.º 15
0
/**
 * Timer procedure, called if date changed. This updates clist icons.
 *
 * @param	hwnd			- not used
 * @param	uMsg			- not used
 * @param	idEvent			- not used
 * @param	dwTime			- not used
 * @return	nothing
 **/
static VOID CALLBACK TimerProc_DateChanged(HWND, UINT, UINT_PTR, DWORD)
{
    static MTime last;
    MTime now;

    now.GetLocalTime();
    if (now.Day() > last.Day() || now.Month() > last.Month() || now.Year() > last.Year()) {
        SvcReminderCheckAll(NOTIFY_CLIST);
        last = now;
    }
}
Ejemplo n.º 16
0
//
// Evaluate the curve at the given time.
//
double interpHalf::evaluate(const MTime &val)
{
	// Interpolate the before and after values.
	double sec = val.as(MTime::kSeconds);
	double alpha = (sec-sTime) / range;
	return (1.0 - alpha) * beforeVal + alpha * afterVal;
}
Ejemplo n.º 17
0
MObject animCube::createMesh(const MTime& time,
							  MObject& outData,
							  MStatus& stat)

{
	int				numVertices, frame;
	float			cubeSize;
	MFloatPointArray		points;
	MFnMesh			meshFS;

	// Scale the cube on the frame number, wrap every 10 frames.
	frame = (int)time.as( MTime::kFilm );
	if (frame == 0)
	  frame = 1;
	cubeSize		    		= 0.5f * (float)( frame % 10);

	const int numFaces			= 6;
	numVertices					= 8;
	const int numFaceConnects	= 24;

	MFloatPoint vtx_1( -cubeSize, -cubeSize, -cubeSize );
	MFloatPoint vtx_2(  cubeSize, -cubeSize, -cubeSize );
	MFloatPoint vtx_3(  cubeSize, -cubeSize,  cubeSize );
	MFloatPoint vtx_4( -cubeSize, -cubeSize,  cubeSize );
	MFloatPoint vtx_5( -cubeSize,  cubeSize, -cubeSize );
	MFloatPoint vtx_6( -cubeSize,  cubeSize,  cubeSize );
	MFloatPoint vtx_7(  cubeSize,  cubeSize,  cubeSize );
	MFloatPoint vtx_8(  cubeSize,  cubeSize, -cubeSize );
	points.append( vtx_1 );
	points.append( vtx_2 );
	points.append( vtx_3 );
	points.append( vtx_4 );
	points.append( vtx_5 );
	points.append( vtx_6 );
	points.append( vtx_7 );
	points.append( vtx_8 );

	// Set up an array containing the number of vertices
	// for each of the 6 cube faces (4 verticies per face)
	//
	int face_counts[numFaces] = { 4, 4, 4, 4, 4, 4 };
	MIntArray faceCounts( face_counts, numFaces );

	// Set up and array to assign vertices from points to each face 
	//
	int face_connects[ numFaceConnects ] = {	0, 1, 2, 3,
												4, 5, 6, 7,
												3, 2, 6, 5,
												0, 3, 5, 4,
												0, 4, 7, 1,
												1, 7, 6, 2	};
	MIntArray faceConnects( face_connects, numFaceConnects );

	MObject newMesh = meshFS.create(numVertices, numFaces,
									points, faceCounts, faceConnects,
									outData, &stat);

	return newMesh;
}
Ejemplo n.º 18
0
MStatus bruiseMapNode::compute( const MPlug& plug, MDataBlock& data )
{ 
	MStatus status;
	if(plug == aoutput)
	{
		MObject ogrow = data.inputValue(agrowth).asMesh();
		if(!ogrow.isNull()) m_base->setBase(ogrow);
		
		MObject oguide = data.inputValue(aguide).asMesh();
		if(!oguide.isNull()) m_base->setGuide(oguide);
		
		//MMatrix mat = data.inputValue(aworldSpace).asMatrix();
		MTime currentTime = data.inputValue(acurrenttime, &status).asTime();
		int frame = (int)currentTime.value();
		
		int startFrame = data.inputValue(astartframe, &status).asInt();
		
		float bias = data.inputValue(aBias, &status).asFloat();

		if(frame == startFrame)
		{
			int mapsize = data.inputValue(amapsize, &status).asInt();
			m_base->init(mapsize);
		}
		
		int npt = m_base->dice(bias);
		MGlobal::displayInfo(MString(" bruise map n sample ")+npt);

		int isave = data.inputValue(asavemap, &status).asInt();
		if(isave==1) 
		{
			MString cache_path;
			MGlobal::executeCommand( MString ("string $p = `workspace -q -fn`"), cache_path);

			cache_path = cache_path + "/data/" + MFnDependencyNode(thisMObject()).name() + "."+frame+".exr";
			MGlobal::displayInfo(MString("Saving ")+cache_path);
			
			MString uvname = data.inputValue(auvset).asString();
			if(uvname == "") uvname = "map1";
			m_base->save(bias, cache_path.asChar(), uvname);
		}
	    
		data.setClean(plug);
	}
	return MS::kUnknownParameter;
}
Ejemplo n.º 19
0
	/**
	 * This method adds a row to the listview.
	 *
	 * @param	hContact		- contact to add the line for
	 * @param	pszProto		- contact's protocol
	 * @param	ad				- anniversary to add
	 * @param	mtNow			- current time
	 * @param	wDaysBefore		- number of days in advance to remind the user of the anniversary
	 *
	 * @retval	TRUE if successful
	 * @retval	FALSE if failed
	 **/
	BYTE AddRow(MCONTACT hContact, LPCSTR pszProto, MAnnivDate &ad, MTime &mtNow, WORD wDaysBefore) 
	{
		TCHAR szText[MAX_PATH];
		int diff, iItem = -1;
		CItemData *pdata;
	
		// first column: ETA
		diff = ad.CompareDays(mtNow);
		if (diff < 0)
			diff += IsLeap(mtNow.Year() + 1) ? 366 : 365;
		// is filtered
		if (diff <= _filter.wDaysBefore) {
			// read reminder options for the contact
			ad.DBGetReminderOpts(hContact);
			if ((_filter.bFilterIndex != FILTER_DISABLED_REMINDER) || (ad.RemindOption() == BST_UNCHECKED)) {
				// set default offset if required
				if (ad.RemindOffset() == (WORD)-1) {
					ad.RemindOffset(wDaysBefore);
					
					// create data object
					pdata = new CItemData(hContact, ad);
					if (!pdata)
						return FALSE;
					// add item
					iItem = AddItem(_itot(diff, szText, 10), (LPARAM)pdata);
					if (iItem == -1) {
						delete pdata;
						return FALSE;
					}

					// second column: contact name
					AddSubItem(iItem, COLUMN_CONTACT, DB::Contact::DisplayName(hContact));

					// third column: protocol
					TCHAR *ptszProto = mir_a2t(pszProto);
					AddSubItem(iItem, COLUMN_PROTO, ptszProto);
					mir_free(ptszProto);

					// forth line: age
					if (ad.Age(&mtNow))
						AddSubItem(iItem, COLUMN_AGE, _itot(ad.Age(&mtNow), szText, 10));
					else
						AddSubItem(iItem, COLUMN_AGE, _T("???"));

					// fifth line: anniversary
					AddSubItem(iItem, COLUMN_DESC, (LPTSTR)ad.Description());

					// sixth line: date
					ad.DateFormatAlt(szText, _countof(szText));
					AddSubItem(iItem, COLUMN_DATE, szText);
					
					_numRows++;
				}
			}
		}
		return TRUE;
	}
Ejemplo n.º 20
0
MStatus
XmlCacheFormat::readTime( MTime& time )
{
	MStringArray timeValue;
	readXmlTagValue(timeTag, timeValue);
	time.setValue( strtod( timeValue[0].asChar(), NULL ) );

	return MS::kSuccess;
}
Ejemplo n.º 21
0
ConstObjectPtr SceneShape::readSceneShapeLink( const MDagPath &p )
{
	MDagPath dagPath;
	SceneShape *sceneShape = findScene( p, true, &dagPath );
	if ( !sceneShape )
	{
		throw Exception("readSceneShapeLink: Could not find SceneShape!");
	}

	ConstSceneInterfacePtr scene = sceneShape->getSceneInterface();
	if ( !scene )
	{
		throw Exception( "Empty scene!");
	}

	MFnDagNode fnChildDag( dagPath );
	MStatus st;
	MPlug timePlug = fnChildDag.findPlug( aTime, &st );
	if( !st )
	{
		throw Exception( "Could not find 'time' plug in SceneShape!");
	}

	// if time plug is connected to maya global time, then we assume there's no time remapping between the Maya scene and the loaded scene.
	MPlugArray array;
	timePlug.connectedTo( array, true, false, &st );
	if( !st )
	{
		throw Exception( "Could not find 'time' plug connections in SceneShape!");
	}

	for ( unsigned int i = 0; i < array.length(); i++ )
	{
		if ( array[i].name() == "time1.outTime" )
		{
			/// connected to time, so no time remapping between maya scene and loaded scene.
			return LinkedScene::linkAttributeData( scene.get() );
		}
	}
	/// couldn't find connection to maya time, so this node is mapping the time some other way.
	MTime time;
	timePlug.getValue( time );
	return LinkedScene::linkAttributeData( scene.get(), time.as( MTime::kSeconds ) );
}
Ejemplo n.º 22
0
/**
 *	Build the animation from a Maya generic animated Transform
 */
osg::ref_ptr<osg::AnimationPath> Transform::animatedTransform2AnimationPath(MObject &obj)
{
	osg::ref_ptr<osg::AnimationPath> anim = new osg::AnimationPath();

	MTime start = MAnimControl::animationStartTime();
	MTime end = MAnimControl::animationEndTime();
	for( MTime t = start ; t <= end ; t += Config::instance()->getAnimSampleBy() ) {
		// Set the right time in Maya timeline so all properties are updated
		MAnimControl::setCurrentTime(t);

		anim->insert(t.as(MTime::kSeconds), osg::AnimationPath::ControlPoint(
			getCPPosition(obj),
			getCPRotation(obj),
			getCPScale(obj)
			));
	}

	return anim;
}
Ejemplo n.º 23
0
/**
 * This method fills @szTime with the current time
 * according to the combobox's selected timezone.
 *
 * @param		szTime		- string to fill with the current time
 * @param		cchTime		- number of characters the string can take
 *
 * @return	nothing
 **/
void CTzCombo::GetTime(LPTSTR szTime, WORD cchTime)
{
	//use new core tz interface
	if (tmi.printDateTime) {
		tmi.printDateTime((HANDLE)ComboBox_GetItemData(_hwnd, _curSel), _T("t"), szTime, cchTime, 0);
	}
	//fallback use old UIEX method
	else {
		const CTimeZone *pTimeZone = (CTimeZone*)ComboBox_GetItemData(_hwnd, _curSel);
		if (PtrIsValid(pTimeZone)) {
			MTime now;
			TIME_ZONE_INFORMATION tzi = *pTimeZone;

			now.GetTimeUTC();
			now.UTCToTzSpecificLocal(&tzi);
			now.TimeFormat(szTime, cchTime);
		}
		else mir_tcscpy(szTime, _T("--:--"));
	}
}
Ejemplo n.º 24
0
static void restoreOldTime(MTime &start, MTime &end, MTime &curr, MTime &minT,
                           MTime &maxT)
{
  const double st = start.as(start.unit()), en = end.as(end.unit()),
               cu = curr.as(curr.unit()), mi = minT.as(minT.unit()),
               ma = maxT.as(maxT.unit());

  MString inst = "playbackOptions -ast ";
  inst += st;
  inst += " -aet ";
  inst += en;
  inst += " -min ";
  inst += mi;
  inst += " -max ";
  inst += ma;
  inst += ";\ncurrentTime ";
  inst += cu;
  inst += ";";

  MGlobal::executeCommand(inst);
}
Ejemplo n.º 25
0
MStatus simpleEvaluationNode::compute( const MPlug& plug, MDataBlock& data )
{
	
	MStatus returnStatus;
 
	if( plug == output )
	{
		MDataHandle inputData = data.inputValue( input, &returnStatus );

		if( returnStatus != MS::kSuccess )
        {
			cerr << "ERROR getting data" << endl;
        }
		else
		{
            MDataHandle inputTimeData = data.inputValue( aTimeInput, &returnStatus );
		    if( returnStatus != MS::kSuccess )
            {
			    cerr << "ERROR getting data" << endl;
            }
            else
            {
                if ( ! cachedValueIsValid )
                {
                    MTime time = inputTimeData.asTime();
			        cachedValue = doExpensiveCalculation( inputData.asFloat() , (float) time.value() );
                    cachedValueIsValid = true;
                }
			    MDataHandle outputHandle = data.outputValue( simpleEvaluationNode::output );
			    outputHandle.set( cachedValue );
			    data.setClean(plug);
            }
		}
	} else {
		return MS::kUnknownParameter;
	}

	return MS::kSuccess;
}
Ejemplo n.º 26
0
/**
 * This function checks all contacts.
 *
 * @param	notify			- notification type
 *
 * @return	nothing
 **/
VOID SvcReminderCheckAll(const ENotify notify)
{
    if (gRemindOpts.RemindState != REMIND_OFF)
    {
        HANDLE hContact;
        CEvent evt;
        MTime now;
        WORD a1 = 0;

        now.GetLocalTime();

        //walk through all the contacts stored in the DB
        for (hContact = DB::Contact::FindFirst();
                hContact != NULL;
                hContact = DB::Contact::FindNext(hContact))
        {
            CheckContact(hContact, now, evt, notify != NOTIFY_CLIST, &a1);
        }

        if (notify != NOTIFY_CLIST)
        {
            // play sound for the next anniversary
            NotifyWithSound(evt);

            // popup anniversary list
            if (DB::Setting::GetByte(SET_ANNIVLIST_POPUP, FALSE))
            {
                DlgAnniversaryListShow(0, 0);
            }

            if (evt._wDaysLeft > gRemindOpts.wDaysEarlier && notify == NOTIFY_NOANNIV)
            {
                NotifyWithPopup(NULL, CEvent::NONE, 0, NULL, TranslateT("No anniversaries to remind of"));
            }
        }
        UpdateTimer(FALSE);
    }
}
Ejemplo n.º 27
0
int MTime::Compare(const MTime& t) const
{
    assert(IsValid());
    assert(t.IsValid());
    if (m_wHour < t.m_wHour) return -1;
    if (m_wHour > t.m_wHour) return 1;
    if (m_wMinute < t.m_wMinute) return -1;
    if (m_wMinute > t.m_wMinute) return 1;
    if (m_wSecond < t.m_wSecond) return -1;
    if (m_wSecond > t.m_wSecond) return 1;
    if (m_wMilliseconds < t.m_wMilliseconds) return -1;
    if (m_wMilliseconds > t.m_wMilliseconds) return 1;
    return 0;
}
Ejemplo n.º 28
0
MObject AniMesh::readFrame(const MTime& time,MObject& outData,MStatus& stat)

{
	MFloatPointArray points;
	MFnMesh         meshFS;
	int frame = (int)time.as( MTime::kFilm );
	if (frame == 0)
		frame = 1; 
	vector<size_t> face_v;
	vector<double> points_v;
	char cfilename[256];
	sprintf(cfilename, "%s%d.vrml",import_prefix.c_str(),frame);
	//sprintf(cfilename, "%s%d.vrml",import_prefix.c_str(),0);
	string filename = string(cfilename);
	fstream fp;
	fp.open(filename,ios::in);
	if (fp)
	{
		ImportVrml2 (filename, face_v, points_v);
	}else{
		sprintf(cfilename, "%s%d.vrml",import_prefix.c_str(),0);
		string filename = string(cfilename); 
		ImportVrml2(filename,face_v,points_v);
	}
	
	size_t numVertices = points_v.size()/3;
	size_t numFaces = face_v.size()/3;
	for(vector<double>::const_iterator it = points_v.begin();it != points_v.end();it+=3) {
		MFloatPoint vtx(*it,*(it+1),*(it+2));
		points.append(vtx);
	}

	vector<int> face_count;
	for(int i=0;i<numFaces;i++) {
		face_count.push_back(3);
	}
	MIntArray faceCounts(&face_count[0],numFaces);

	vector<int> face_connects;
	face_connects.resize(face_v.size());
	for(int i=0;i<face_v.size();++i)
	{
		face_connects[i] = face_v[i];
	}

	MIntArray faceConnects( &face_connects[0], face_connects.size() );
	MObject newMesh=meshFS.create(numVertices, numFaces,points, faceCounts, faceConnects,outData,&stat);
	return newMesh;

}
Ejemplo n.º 29
0
MStatus timeControl::compute( const MPlug& plug, MDataBlock& data )
{
	MStatus status;

	MDataHandle hInTime = data.inputValue( aInTime );
	MDataHandle hOffset = data.inputValue( aOffset );
	MDataHandle hMult = data.inputValue( aMult );
	MDataHandle hMinTime = data.inputValue( aMinTime );
	MDataHandle hMaxTime = data.inputValue( aMaxTime );
	MDataHandle hLimitAble = data.inputValue( aLimitAble );

	MTime inTime = hInTime.asTime();
	
	double offset = hOffset.asDouble();
	double mult = hMult.asDouble();

	double timeValue = inTime.value();
	
	if( hLimitAble.asBool() )
	{
		MTime minTime = hMinTime.asTime();
		MTime maxTime = hMaxTime.asTime();
		double minTimeValue = minTime.value();
		double maxTimeValue = maxTime.value();
		if( timeValue < minTimeValue )
			timeValue = minTimeValue;
		if( timeValue > maxTimeValue )
			timeValue = maxTimeValue;
	}

	timeValue += offset;
	timeValue *= mult;

	MTime outTime( timeValue );

	MDataHandle hOutTime = data.outputValue( aOutTime );
	hOutTime.set( outTime );

	MDataHandle hWeight = data.inputValue( aWeight );
	MDataHandle hOutWeight = data.outputValue( aOutWeight );
	hOutWeight.set( hWeight.asDouble() );

	data.setClean( plug );

	return status;
}
Ejemplo n.º 30
0
float convert( const MTime &from )
{
	return from.as( MTime::kSeconds );
}