当前位置: 首页>>代码示例>>C++>>正文


C++ SkeletonAnimation::addBoneTrack方法代码示例

本文整理汇总了C++中SkeletonAnimation::addBoneTrack方法的典型用法代码示例。如果您正苦于以下问题:C++ SkeletonAnimation::addBoneTrack方法的具体用法?C++ SkeletonAnimation::addBoneTrack怎么用?C++ SkeletonAnimation::addBoneTrack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkeletonAnimation的用法示例。


在下文中一共展示了SkeletonAnimation::addBoneTrack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addAnimation

void Skeleton::addAnimation(const String& name, const String& fileName) {

    OSFILE *inFile = OSBasics::open(fileName.c_str(), "rb");
    
    if(!inFile) {
		return;
	}
	
    unsigned int activeBones,numPoints,numCurves, curveType;
    float length;
    OSBasics::read(&length, 1, sizeof(float), inFile);

    SkeletonAnimation *newAnimation = new SkeletonAnimation(name, length);
    OSBasics::read(&activeBones, sizeof(unsigned int), 1, inFile);
    
    unsigned short boneNameLen;
    char boneNameBuffer[1024];

    for(int j=0; j < activeBones; j++) {
        
        OSBasics::read(&boneNameLen, sizeof(unsigned short), 1, inFile);
        OSBasics::read(boneNameBuffer, 1, boneNameLen, inFile);
        boneNameBuffer[boneNameLen] = '\0';
        
        Bone *trackBone = getBoneByName(boneNameBuffer);
        if(!trackBone) {
            printf("WARNING, INVALID BONE NAME: %s\n", boneNameBuffer);
            continue;
        }
        
        BoneTrack *newTrack = new BoneTrack(trackBone, length);
        
        BezierCurve *curve;
        float vec1[2];
        
        OSBasics::read(&numCurves, sizeof(unsigned int), 1, inFile);
        for(int l=0; l < numCurves; l++) {
            curve = new BezierCurve();
            OSBasics::read(&curveType, sizeof(unsigned int), 1, inFile);
            OSBasics::read(&numPoints, sizeof(unsigned int), 1, inFile);
            
            for(int k=0; k < numPoints; k++) {
                OSBasics::read(vec1, sizeof(float), 2, inFile);					
                curve->addControlPoint2d(vec1[1], vec1[0]);
            }
            switch(curveType) {
                case 0:
                    newTrack->scaleX = curve;
                    break;
                case 1:
                    newTrack->scaleY = curve;
                    break;
                case 2:
                    newTrack->scaleZ = curve;					
                    break;
                case 3:
                    newTrack->QuatW = curve;					
                    break;
                case 4:
                    newTrack->QuatX = curve;					
                    break;
                case 5:
                    newTrack->QuatY = curve;					
                    break;
                case 6:
                    newTrack->QuatZ = curve;					
                    break;
                case 7:;
                    newTrack->LocX = curve;					
                    break;
                case 8:
                    newTrack->LocY = curve;					
                    break;
                case 9:
                    newTrack->LocZ = curve;					
                    break;
            }
        }
        newAnimation->addBoneTrack(newTrack);
    }
    
    animations.push_back(newAnimation);
	OSBasics::close(inFile);	
}
开发者ID:Anwesh43,项目名称:Polycode,代码行数:84,代码来源:PolySkeleton.cpp

示例2: addAnimation

void Skeleton::addAnimation(const String& name, const String& fileName) {
	OSFILE *inFile = OSBasics::open(fileName.c_str(), "rb");
	if(!inFile) {
		return;
	}
	
		unsigned int activeBones,boneIndex,numPoints,numCurves, curveType;	
		float length;
		OSBasics::read(&length, 1, sizeof(float), inFile);
		SkeletonAnimation *newAnimation = new SkeletonAnimation(name, length);
		
		OSBasics::read(&activeBones, sizeof(unsigned int), 1, inFile);
		
		//	Logger::log("activeBones: %d\n", activeBones);		
		for(int j=0; j < activeBones; j++) {
			OSBasics::read(&boneIndex, sizeof(unsigned int), 1, inFile);
			BoneTrack *newTrack = new BoneTrack(bones[boneIndex], length);
			
			BezierCurve *curve;
			float vec1[2]; //,vec2[2],vec3[2];
			
			OSBasics::read(&numCurves, sizeof(unsigned int), 1, inFile);
			//			Logger::log("numCurves: %d\n", numCurves);					
			for(int l=0; l < numCurves; l++) {
				curve = new BezierCurve();
				OSBasics::read(&curveType, sizeof(unsigned int), 1, inFile);
				OSBasics::read(&numPoints, sizeof(unsigned int), 1, inFile);
				for(int k=0; k < numPoints; k++) {					
					OSBasics::read(vec1, sizeof(float), 2, inFile);					
					curve->addControlPoint2d(vec1[1], vec1[0]);
					//					curve->addControlPoint(vec1[1]-10, vec1[0], 0, vec1[1], vec1[0], 0, vec1[1]+10, vec1[0], 0);
				}
				switch(curveType) {
					case 0:
						newTrack->scaleX = curve;
						break;
					case 1:
						newTrack->scaleY = curve;
						break;
					case 2:
						newTrack->scaleZ = curve;					
						break;
					case 3:
						newTrack->QuatW = curve;					
						break;
					case 4:
						newTrack->QuatX = curve;					
						break;
					case 5:
						newTrack->QuatY = curve;					
						break;
					case 6:
						newTrack->QuatZ = curve;					
						break;
					case 7:;
						newTrack->LocX = curve;					
						break;
					case 8:
						newTrack->LocY = curve;					
						break;
					case 9:
						newTrack->LocZ = curve;					
						break;
				}
			}
			
			newAnimation->addBoneTrack(newTrack);
		}
		animations.push_back(newAnimation);
	
	
	OSBasics::close(inFile);	
}
开发者ID:dev-life,项目名称:Polycode,代码行数:73,代码来源:PolySkeleton.cpp


注:本文中的SkeletonAnimation::addBoneTrack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。