INode* plDistribComponent_old::IMakeOne(plDistribInstTab& nodes)
{
    if( !nodes.Count() )
        return nil;

    int iStartNode = 0;

    NameMaker *nn = GetCOREInterface()->NewNameMaker();

    while( iStartNode < nodes.Count() )
    {
        TriObject* triObj = CreateNewTriObject();
        Mesh* outMesh = &triObj->mesh;

        *outMesh = *nodes[iStartNode].fMesh;

        INode *outNode = GetCOREInterface()->CreateObjectNode(triObj);

        Matrix3 l2w = nodes[0].fObjectTM;
        Matrix3 w2l = Inverse(l2w);

        MeshDelta meshDelta(*outMesh);

        int i;
        for( i = iStartNode; i < nodes.Count(); i++ )
        {
            Mesh* nextMesh = nodes[i].fMesh;

            Matrix3 relativeTransform = nodes[i].fObjectTM * w2l;

            meshDelta.AttachMesh(*outMesh, *nextMesh, relativeTransform, 0);

            meshDelta.Apply(*outMesh);

            const int kFaceCutoff = 1000;
            if( outMesh->getNumFaces() > kFaceCutoff )
                break;
        }
        iStartNode = i;

        outNode->SetNodeTM(TimeValue(0), l2w);
        outNode->CopyProperties(nodes[0].fNode);
        outNode->SetMtl(nodes[0].fNode->GetMtl());
        outNode->SetObjOffsetPos(Point3(0,0,0));
        Quat identQuat;
        identQuat.Identity();
        outNode->SetObjOffsetRot(identQuat);
        outNode->SetObjOffsetScale(ScaleValue(Point3(1.f, 1.f, 1.f)));

        TSTR outName(TSTR("Preview"));
        nn->MakeUniqueName(outName);
        outNode->SetName(outName);

        fCompPB->Append(kReplicants, 1, &outNode);
    }

    return nil;
}
Esempio n. 2
0
void ScaleMC::GetValueLive(TimeValue t,void *val, GetSetMethod method)
	{
	Point3 pt = base;
	for (int i=0; i<3; i++) {
		if (bind[i]) pt[i] += bind[i]->Eval(t)/100.0f;		
		}
	if (method==CTRL_ABSOLUTE) {
		*((ScaleValue*)val) = ScaleValue(pt);
	} else {
		Matrix3 *tm = (Matrix3*)val;
		tm->PreScale(pt);
		}
	}
Esempio n. 3
0
void DraggedTabView::MoveTo(const gfx::Point& screen_point)
{
    int x;
    if(base::i18n::IsRTL())
    {
        // On RTL locales, a dragged tab (when it is not attached to a tab strip)
        // is rendered using a right-to-left orientation so we should calculate the
        // window position differently.
        gfx::Size ps = GetPreferredSize();
        x = screen_point.x() + ScaleValue(mouse_tab_offset_.x() - ps.width());
    }
    else
    {
        x = screen_point.x() - ScaleValue(mouse_tab_offset_.x());
    }
    int y = screen_point.y() - ScaleValue(mouse_tab_offset_.y());

    // TODO(beng): make this cross-platform
    int show_flags = container_->IsVisible() ? SWP_NOZORDER : SWP_SHOWWINDOW;
    SetWindowPos(container_->GetNativeView(), HWND_TOP, x, y, 0, 0,
                 SWP_NOSIZE | SWP_NOACTIVATE | show_flags);
}
Esempio n. 4
0
   void PackedNavBits::addUnsignedDouble( const double value, const int numBits,
                                          const int power2 ) 
      throw(InvalidParameter)
   {
      uint64_t out = (uint64_t) ScaleValue(value, power2);
      uint64_t test = pow(static_cast<double>(2),numBits) - 1;
      if ( out > test )
      {
         InvalidParameter exc("Scaled value too large for specifed bit length");
         GPSTK_THROW(exc);
      }

      addUint64_t( out, numBits ); 
   } 
Esempio n. 5
0
void RemovePivotScale(INode* node)
{
	const TimeValue  t  = ccMaxWorld::MaxTime();
	Matrix3 nodeTM = node->GetNodeTM(t);

	Point3 pos = nodeTM.GetRow(3);
	Matrix3 objectTM = node->GetObjectTM(t);
	nodeTM = objectTM;
	nodeTM.SetRow(3, pos);
	Matrix3 pv = objectTM * Inverse(nodeTM);
	node->SetNodeTM(t, nodeTM);

	node->SetObjOffsetPos(pv.GetTrans()); 
	node->SetObjOffsetRot(IdentQuat()); 
	node->SetObjOffsetScale(ScaleValue(Point3(1,1,1))); 
}
Esempio n. 6
0
 void PackedNavBits::addSignedDouble( const double value, const int numBits,
                                      const int power2 ) 
    throw(InvalidParameter)
 {
    union
    {
       uint64_t u_out;
       int64_t out;
    };
    out = (int64_t) ScaleValue(value, power2);
    int64_t test = pow(static_cast<double>(2),numBits-1) - 1; 
    if ( ( out > test ) || ( out < -( test + 1 ) ) )
    {
       InvalidParameter exc("Scaled value too large for specifed bit length");
       GPSTK_THROW(exc);
    }
    addUint64_t( u_out, numBits ); 
 }
Esempio n. 7
0
MRESULT SetRightVolume(USHORT DevID, MPARAM mp1, MPARAM mp2)
{
    USHORT NewVolume, VolumeScaled;
    BOOL bResult;

    if ( ( SHORT2FROMMP(mp1) == SLN_CHANGE ||
           SHORT2FROMMP(mp1) == SLN_SLIDERTRACK ) && ! SliderSet ) {
        NewVolume = SHORT1FROMMR(WinSendMsg(hwndVolumeRight, SLM_QUERYSLIDERINFO,
            MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE), NULL));

        if ( NewVolume != OldVolRight ) {
            VolumeScaled = ScaleValue(NewVolume, VolSliderPixels-1, 100);

            if ( ! VolChannelIndependent ) {
                CurrVolLeft = VolumeScaled;
                CurrVolRight = VolumeScaled;

                OldVolLeft = OldVolRight = NewVolume;
                SliderSet = TRUE;
                WinSendMsg(hwndVolumeLeft, SLM_SETSLIDERINFO,
                    MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                    MPFROMSHORT(NewVolume));
                SliderSet = FALSE;
                bResult = CDSetVolume(DevID, VolumeScaled, VolumeScaled);
                // CDOptError(bResult, hwnd, ERR_DEVICE_SETVOLUME);
                }
            else {
                CurrVolRight = VolumeScaled;

                OldVolRight = NewVolume;
                bResult = CDSetVolume(DevID, -1, VolumeScaled);
                // CDOptError(bResult, hwnd, ERR_DEVICE_SETVOLUME);
                }

            if ( SaveVolume ) {
                bResult = CDPrfSaveVolume(CurrVolLeft, CurrVolRight);
                }
            }
        }

    return NULL;
}
Esempio n. 8
0
static void do_expire(char *datadir) {
bookkeeper_t 	*books;
dirstat_t 		*dirstat, oldstat;
int				ret, bookkeeper_stat, do_rescan;

	syslog(LOG_INFO, "Run expire on '%s'", datadir);

	do_rescan = 0;
	ret = ReadStatInfo(datadir, &dirstat, CREATE_AND_LOCK);
	switch (ret) {
		case STATFILE_OK:
			break;
		case ERR_NOSTATFILE:
			dirstat->low_water = 95;
		case FORCE_REBUILD:
			syslog(LOG_INFO, "Force rebuild stat record");
			do_rescan = 1;
			break;
		case ERR_FAIL:
			syslog(LOG_ERR, "expire failed: can't read stat record");
			return;
			/* not reached */
			break;
		default:
			syslog(LOG_ERR, "expire failed: unexpected return code %i reading stat record", ret);
			return;
			/* not reached */
	}

	bookkeeper_stat = AccessBookkeeper(&books, datadir);
	if ( do_rescan ) {
		RescanDir(datadir, dirstat);
		if ( bookkeeper_stat == BOOKKEEPER_OK ) {
			ClearBooks(books, NULL);
			// release the books below
		}
	}

	if ( bookkeeper_stat == BOOKKEEPER_OK ) {
		bookkeeper_t	tmp_books;
		ClearBooks(books, &tmp_books);
		UpdateBookStat(dirstat, &tmp_books);
		ReleaseBookkeeper(books, DETACH_ONLY);
	} else {
		syslog(LOG_ERR, "Error %i: can't access book keeping records", ret);
	}

	syslog(LOG_INFO, "Limits: Filesize %s, Lifetime %s, Watermark: %llu%%\n", 
		dirstat->max_size     ? ScaleValue(dirstat->max_size)    : "<none>", 
		dirstat->max_lifetime ? ScaleTime(dirstat->max_lifetime) : "<none>",
		(unsigned long long)dirstat->low_water);
		
	syslog(LOG_INFO, "Current size: %s, Current lifetime: %s, Number of files: %llu",
		ScaleValue(dirstat->filesize),
		ScaleTime(dirstat->last - dirstat->first),
		(unsigned long long)dirstat->numfiles);

	oldstat = *dirstat;
	if ( dirstat->max_size || dirstat->max_lifetime ) 
		ExpireDir(datadir, dirstat, dirstat->max_size, dirstat->max_lifetime, 0);
	WriteStatInfo(dirstat);

	if ( (oldstat.numfiles - dirstat->numfiles) > 0 ) {
		syslog(LOG_INFO, "expire completed");
		syslog(LOG_INFO, "   expired files: %llu", (unsigned long long)(oldstat.numfiles - dirstat->numfiles));
		syslog(LOG_INFO, "   expired time slot: %s", ScaleTime(dirstat->first - oldstat.first));
		syslog(LOG_INFO, "   expired file size: %s", ScaleValue(oldstat.filesize - dirstat->filesize));
		syslog(LOG_INFO, "New size: %s, New lifetime: %s, Number of files: %llu",
			ScaleValue(dirstat->filesize),
		ScaleTime(dirstat->last - dirstat->first),
			(unsigned long long)dirstat->numfiles);
	} else {
		syslog(LOG_INFO, "expire completed - nothing to expire.");
	}
	ReleaseStatInfo(dirstat);

} // End of do_expire
Esempio n. 9
0
gfx::Size DraggedTabView::PreferredContainerSize()
{
    gfx::Size ps = GetPreferredSize();
    return gfx::Size(ScaleValue(ps.width()), ScaleValue(ps.height()));
}
Esempio n. 10
0
BOOL EnableVolume(BOOL Enable, USHORT DevID, CDAUDIO_DRIVERINFO *DriverInfo)
{
    ULONG VolLeft, VolRight;
    BOOL bResult;

    if ( Enable && DriverInfo->CanSetVolume ) {
        WinEnableWindow(hwndChannelSwap, DriverInfo->CanSwapChannels);        

        if ( CDPrfLoadVolume(&VolLeft, &VolRight) ) {
            bResult = CDSetVolume(DevID, VolLeft, VolRight);
            // CDOptError(bResult, hwnd, ERR_DEVICE_SETVOLUME);
            }
        else {
            VolLeft = VolRight = 100;
            bResult = CDQueryVolume(DevID, &VolLeft, &VolRight);
            // CDOptError(bResult, hwnd, ERR_DEVICE_QUERYVOLUME);
            }

        CurrVolLeft = VolLeft;
        CurrVolRight = VolRight;

        if ( VolLeft == VolRight ) {
            VolChannelIndependent = FALSE;
            WinSendMsg(hwndChannelIndependent, BM_SETCHECK, MPFROMSHORT(0), NULL);
            }
        else {
            VolChannelIndependent = TRUE;
            WinSendMsg(hwndChannelIndependent, BM_SETCHECK, MPFROMSHORT(1), NULL);
            }

        OldVolLeft = ScaleValue(VolLeft, 100, VolSliderPixels-1);
        OldVolRight = ScaleValue(VolRight, 100, VolSliderPixels-1);
        SliderSet = TRUE;
        WinSendMsg(hwndVolumeLeft, SLM_SETSLIDERINFO,
            MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
            MPFROMSHORT(OldVolLeft));
        WinSendMsg(hwndVolumeRight, SLM_SETSLIDERINFO,
            MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
            MPFROMSHORT(OldVolRight));
        SliderSet = FALSE;
        }
    else {
        SliderSet = TRUE;
        WinSendMsg(hwndVolumeLeft, SLM_SETSLIDERINFO,
            MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
            MPFROMSHORT(VolSliderPixels-1));
        WinSendMsg(hwndVolumeRight, SLM_SETSLIDERINFO,
            MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
            MPFROMSHORT(VolSliderPixels-1));
        SliderSet = FALSE;
 
        WinSendMsg(hwndChannelIndependent, BM_SETCHECK, MPFROMLONG(0), NULL);
        WinSendMsg(hwndChannelSwap, BM_SETCHECK, MPFROMLONG(0), NULL);
        WinEnableWindow(WinWindowFromID(hwndDlg, ID_GROUP_OUTPUT), FALSE);
        WinEnableWindow(hwndVolumeLeft, FALSE);
        WinEnableWindow(hwndVolumeRight, FALSE);
        WinEnableWindow(hwndChannelIndependent, FALSE);
        WinEnableWindow(hwndChannelSwap, FALSE);
        WinEnableWindow(hwndMute, FALSE);
        }

    return TRUE;
}
Esempio n. 11
0
int main( int argc, char **argv ) {
    struct stat fstat;
    int 		c, err, maxsize_set, maxlife_set;
    int			do_rescan, do_expire, do_list, print_stat, do_update_param, print_books, is_profile, nfsen_format;
    char		*maxsize_string, *lifetime_string, *datadir;
    uint64_t	maxsize, lifetime, low_water;
    uint32_t	runtime;
    channel_t	*channel, *current_channel;

    maxsize_string = lifetime_string = NULL;
    datadir = NULL;
    maxsize = lifetime = 0;
    do_rescan  		= 0;
    do_expire  		= 0;
    do_list	   		= 0;
    do_update_param = 0;
    is_profile		= 0;
    print_stat		= 0;
    print_books		= 0;
    maxsize_set 	= 0;
    maxlife_set 	= 0;
    low_water		= 0;
    nfsen_format	= 0;
    runtime			= 0;

    while ((c = getopt(argc, argv, "e:hl:L:T:Ypr:s:t:u:w:")) != EOF) {
        switch (c) {
        case 'h':
            usage(argv[0]);
            exit(0);
            break;
        case 'l':
            CheckDataDir(datadir);
            datadir = optarg;
            do_list = 1;
            print_stat = 1;
            break;
        case 'L':
            CheckDataDir(datadir);
            datadir = optarg;
            print_stat  = 1;
            print_books = 1;
            break;
        case 'p':
            is_profile = 1;
            break;
        case 'r':
            CheckDataDir(datadir);
            do_rescan = 1;
            print_stat = 1;
            datadir = optarg;
            break;
        case 'e':
            CheckDataDir(datadir);
            datadir = optarg;
            do_expire = 1;
            print_stat = 1;
            break;
        case 's':
            if ( ParseSizeDef(optarg, &maxsize ) == 0 )
                exit(250);
            maxsize_set = 1;
            break;
        case 't':
            if ( ParseTimeDef(optarg, &lifetime ) == 0 )
                exit(250);
            maxlife_set = 1;
            break;
        case 'u':
            CheckDataDir(datadir);
            datadir = optarg;
            do_update_param = 1;
            break;
        case 'w':
            low_water = strtoll(optarg, NULL, 10);
            if ( low_water > 100 ) {
                fprintf(stderr, "Water mark > 100%%\n");
                exit(250);
            }
            if ( low_water == 0 )
                low_water = 100;
            break;
        case 'T':
            runtime = strtoll(optarg, NULL, 10);
            if ( runtime > 3600 ) {
                fprintf(stderr, "Runtime > 3600 (1h)\n");
                exit(250);
            }
            break;
        case 'Y':
            nfsen_format = 1;
            break;
        default:
            usage(argv[0]);
            exit(250);
        }

    }

    datadir = AbsolutePath(datadir);

    if ( !datadir ) {
        fprintf(stderr, "Missing data directory\n");
        usage(argv[0]);
        exit(250);
    }

    err  = stat(datadir, &fstat);
    if ( !(fstat.st_mode & S_IFDIR) ) {
        fprintf(stderr, "No such directory: %s\n", datadir);
        exit(250);
    }

    channel = GetChannelList(datadir, is_profile, do_rescan);
    // GetChannelList(datadir, is_profile, do_rescan);
    if ( !channel ) {
        exit(250);
    }

// printf("Size: %llu, time: %llu\n", maxsize, lifetime);

    // update water mark only, when not listing
    if ( !is_profile && !do_list && low_water )
        channel->dirstat->low_water = low_water;

    /* process do_list first: if the UpdateBookStat results in a FORCE_REBUILD,
     * this will immediately done afterwards
     * do_expire will need accurate books as well, so update the books here as well
     */
    if ( do_list || do_expire ) {
        current_channel = channel;
        while ( current_channel ) {
            if ( current_channel->books_stat == BOOKKEEPER_OK ) {
                bookkeeper_t	tmp_books;
                printf("Include nfcapd bookeeping record in %s\n", current_channel->datadir);
                ClearBooks(current_channel->books, &tmp_books);
                UpdateBookStat(current_channel->dirstat, &tmp_books);
                if ( current_channel->dirstat->status == FORCE_REBUILD )
                    current_channel->do_rescan = 1;
            }
            current_channel = current_channel->next;
        }
    }

    // process do_rescan: make sure stats are up to date, if required
    current_channel = channel;
    while ( current_channel ) {
        if ( current_channel->do_rescan ) {
            int	 i;
            uint64_t last_sequence;

            /* detect new files: If nfcapd adds a new file while we are rescanning the directory
            * this results in inconsistent data for the rescan. Therefore check at the begin and end
            * of the rescan for the sequence number, which reflects the accesss/change to the bookkeeping record
            * It's assumed, that such an event does not occure more than once. However, loop 3 times max
            */
            for ( i=0; i<3; i++ ) {
                last_sequence = BookSequence(current_channel->books);
                printf("Scanning files in %s .. ", current_channel->datadir);
                RescanDir(current_channel->datadir, current_channel->dirstat);
                if ( current_channel->dirstat->numfiles == 0 ) { //nothing found
                    current_channel->status = NOFILES;
                }
                if ( BookSequence(current_channel->books) == last_sequence )
                    break;
                printf("Rescan again, due to file changes in directory!\n");
            }
            if ( BookSequence(current_channel->books) != last_sequence ) {
                fprintf(stderr, "Could not savely rescan the directory. Data is not consistent.\n");
                ReleaseBookkeeper(current_channel->books, DETACH_ONLY);
                if ( current_channel->status == OK )
                    WriteStatInfo(current_channel->dirstat);
                exit(250);
            }
            printf("done.\n");
            if ( current_channel->books_stat == BOOKKEEPER_OK ) {
                printf("Updating nfcapd bookeeping records\n");
                ClearBooks(channel->books, NULL);
            }
        }
        current_channel = current_channel->next;
    }

    // now process do_expire if required
    if ( do_expire ) {
        dirstat_t	old_stat, current_stat;

        if ( is_profile ) {
            current_stat.status = 0;
            current_stat.max_lifetime 	= lifetime;
            current_stat.max_size  		= maxsize;
            current_stat.low_water 		= low_water ? low_water : 98;

            // sum up all channels in the profile
            current_channel = channel;
            current_stat.numfiles = current_channel->dirstat->numfiles;
            current_stat.filesize = current_channel->dirstat->filesize;
            current_stat.first 	  = current_channel->dirstat->first;
            current_stat.last 	  = current_channel->dirstat->last;
            current_channel = current_channel->next;
            while ( current_channel ) {
                current_stat.numfiles += current_channel->dirstat->numfiles;
                current_stat.filesize += current_channel->dirstat->filesize;
                if ( current_channel->dirstat->first && (current_channel->dirstat->first < current_stat.first) )
                    current_stat.first = current_channel->dirstat->first;
                if ( current_channel->dirstat->last > current_stat.last )
                    current_stat.last = current_channel->dirstat->last;

                current_channel = current_channel->next;
            }
            old_stat = current_stat;
            ExpireProfile(channel, &current_stat, maxsize, lifetime, runtime);

        } else {
            // cmd args override dirstat values
            if ( maxsize_set )
                channel->dirstat->max_size     = maxsize;
            else
                maxsize = channel->dirstat->max_size;
            if ( maxlife_set )
                channel->dirstat->max_lifetime = lifetime;
            else
                lifetime = channel->dirstat->max_lifetime;


            old_stat = *(channel->dirstat);
            ExpireDir(channel->datadir, channel->dirstat, maxsize, lifetime, runtime);
            current_stat = *(channel->dirstat);

        }
        // Report, what we have done
        printf("Expired files:      %llu\n", (unsigned long long)(old_stat.numfiles - current_stat.numfiles));
        printf("Expired file size:  %s\n", ScaleValue(old_stat.filesize - current_stat.filesize));
        printf("Expired time range: %s\n\n", ScaleTime(current_stat.first - old_stat.first));
    }

    if ( !is_profile && do_update_param ) {
        switch (channel->books_stat) {
        case BOOKKEEPER_OK:
            if ( maxsize_set )
                channel->dirstat->max_size = maxsize;
            else
                maxsize = channel->dirstat->max_size;
            if ( maxlife_set )
                channel->dirstat->max_lifetime = lifetime;
            else
                lifetime = channel->dirstat->max_lifetime;
            printf("Update collector process running for directory: '%s'\n", datadir);
            UpdateBooksParam(channel->books, (time_t)lifetime, maxsize);
            print_stat = 1;
            break;
        case ERR_NOTEXISTS:
            if ( maxsize_set )
                channel->dirstat->max_size = maxsize;
            if ( maxlife_set )
                channel->dirstat->max_lifetime = lifetime;
            print_stat = 1;
            break;
        default:
            // should never be reached as already cought earlier
            printf("Error %i while connecting to collector\n", channel->books_stat);
        }
        if ( channel->status == OK || channel->status == NOFILES  )
            WriteStatInfo(channel->dirstat);
    }

    if ( !is_profile && print_books ) {
        switch (channel->books_stat) {
        case BOOKKEEPER_OK:
            PrintBooks(channel->books);
            break;
        case ERR_NOTEXISTS:
            printf("No collector process running for directory: '%s'\n", channel->datadir);
            break;
        default:
            // should never be reached as already cought earlier
            printf("Error %i while connecting to collector\n", channel->books_stat);
        }

    }

    if ( print_stat ) {
        if ( is_profile ) {
            dirstat_t	current_stat;

            current_stat.status = 0;
            current_stat.max_lifetime 	= lifetime;
            current_stat.max_size  		= maxsize;
            current_stat.low_water 		= low_water ? low_water : 98;

            // sum up all channels in the profile
            current_channel = channel;
            current_stat.numfiles = current_channel->dirstat->numfiles;
            current_stat.filesize = current_channel->dirstat->filesize;
            current_stat.first 	  = current_channel->dirstat->first;
            current_stat.last 	  = current_channel->dirstat->last;
            current_channel = current_channel->next;
            while ( current_channel ) {
                current_stat.numfiles += current_channel->dirstat->numfiles;
                current_stat.filesize += current_channel->dirstat->filesize;
                if ( current_channel->dirstat->first && (current_channel->dirstat->first < current_stat.first) )
                    current_stat.first = current_channel->dirstat->first;
                if ( current_channel->dirstat->last > current_stat.last )
                    current_stat.last = current_channel->dirstat->last;

                current_channel = current_channel->next;
            }
            if ( nfsen_format ) {
                printf("Stat|%llu|%llu|%llu\n",
                       (unsigned long long)current_stat.filesize,
                       (unsigned long long)current_stat.first, (unsigned long long)current_stat.last);
            } else
                PrintDirStat(&current_stat);
        } else if ( nfsen_format )
            printf("Stat|%llu|%llu|%llu\n",
                   (unsigned long long)channel->dirstat->filesize,
                   (unsigned long long)channel->dirstat->first, (unsigned long long)channel->dirstat->last );
        else
            PrintDirStat(channel->dirstat);

    }

    current_channel = channel;
    while ( current_channel ) {
        ReleaseBookkeeper(current_channel->books, DETACH_ONLY);
        if ( current_channel->status == OK )
            WriteStatInfo(current_channel->dirstat);

        current_channel = current_channel->next;
    }

    return 0;
}
Esempio n. 12
0
void ResetXForm::ResetNodes(const INodeTab& nodesToReset)
{
	Interface *ip = GetCOREInterface();
	for (int i = 0; i < nodesToReset.Count(); i++) {
		INode *node = nodesToReset[i];
		if (!node || node->IsGroupMember() || node->IsGroupHead()) 
			continue;
		if (SelectedAncestor(node)) 
			continue;

		Matrix3 ntm, ptm, rtm(1), piv(1), tm;
		
		// Get Parent and Node TMs
		ntm = node->GetNodeTM(ip->GetTime());
		ptm = node->GetParentTM(ip->GetTime());
		
		// Compute the relative TM
		ntm = ntm * Inverse(ptm);
		
		// The reset TM only inherits position
		rtm.SetTrans(ntm.GetTrans());
		
		// Set the node TM to the reset TM		
		tm = rtm*ptm;
		node->SetNodeTM(ip->GetTime(), tm);

		// Compute the pivot TM
		piv.SetTrans(node->GetObjOffsetPos());
		PreRotateMatrix(piv,node->GetObjOffsetRot());
		ApplyScaling(piv,node->GetObjOffsetScale());
		
		// Reset the offset to 0
		node->SetObjOffsetPos(Point3(0,0,0));
		node->SetObjOffsetRot(IdentQuat());
		node->SetObjOffsetScale(ScaleValue(Point3(1,1,1)));

		// Take the position out of the matrix since we don't reset position
		ntm.NoTrans();

		// Apply the offset to the TM
		ntm = piv * ntm;

		// Apply a derived object to the node's object
		Object *obj = node->GetObjectRef();
		IDerivedObject *dobj = CreateDerivedObject(obj);
		
		// Create an XForm mod
		SimpleMod *mod = (SimpleMod*)ip->CreateInstance(
			OSM_CLASS_ID,
			Class_ID(CLUSTOSM_CLASS_ID,0));

		// Apply the transformation to the mod.
		SetXFormPacket pckt(ntm);
		mod->tmControl->SetValue(ip->GetTime(),&pckt);

		// Add the modifier to the derived object.
		dobj->SetAFlag(A_LOCK_TARGET); // RB 3/11/99: When the macro recorder is on the derived object will get deleted unless it is locked.
		dobj->AddModifier(mod);
		dobj->ClearAFlag(A_LOCK_TARGET);

		// Replace the node's object
		node->SetObjectRef(dobj);
	}
	
//	Why on earth were we clearing the undo stack?
//	GetSystemSetting(SYSSET_CLEAR_UNDO);
	ip->RedrawViews(ip->GetTime());
	SetSaveRequiredFlag(TRUE);
}
Esempio n. 13
0
ScaleValue Scale::read() {
	float raw = adc.readFloat();
	//FIXME: MAGIC!
	int grams = (raw - 0.51) * 2000.0 / (0.562 - 0.51);
	return ScaleValue(grams);
}