本文整理汇总了C++中Control::NumKeys方法的典型用法代码示例。如果您正苦于以下问题:C++ Control::NumKeys方法的具体用法?C++ Control::NumKeys怎么用?C++ Control::NumKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Control
的用法示例。
在下文中一共展示了Control::NumKeys方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dump_material_tracks
void SkeletonExporter::dump_material_tracks(Mtl* mtl)
{
Control *c;
int size_key;
Animatable *track;
if (!mtl) return;
export_animatable(mtl, 1);
if (mtl->ClassID() == Class_ID(DMTL_CLASS_ID, 0))
{
// opacity track
track=mtl->SubAnim(2)->SubAnim(0);
c=GetControlInterface(track);
if ((c) && (c->NumKeys()>0))
{
if (IsTCBControl(c)) size_key=28;
else
if (IsBezierControl(c)) size_key=16;
else size_key=8;
fprintf(fTXT, "Material %s: opacity track present.\n", mtl->GetName());
write_chunk_header(fA3D, MATERIAL_OPACITY_TRACK_ID,
mtl->GetName(), 1+2+4+c->NumKeys()*size_key);
export_float_track(c, 1.0f, fA3D);
}
}
fprintf(fTXT, "\n\n");
}
示例2: material_has_transparency_track
BOOL SkeletonExporter::material_has_transparency_track(Mtl* mtl)
{
Control *c;
Animatable *track;
if (mtl->ClassID() == Class_ID(DMTL_CLASS_ID, 0))
{
track=mtl->SubAnim(2)->SubAnim(0);
c=GetControlInterface(track);
if ((c) && (c->NumKeys()>0)) return(TRUE);
}
return(FALSE);
}
示例3: createAnimationPath
/**
* This method will create and return an animation path.
*/
osg::AnimationPath* OSGExp::createAnimationPath(INode *node, TimeValue t){
// Get the controllers from the node.
Control* pC = node->GetTMController()->GetPositionController();
Control* rC = node->GetTMController()->GetRotationController();
Control* sC = node->GetTMController()->GetScaleController();
// Are we using TCB, Linear, and Bezier keyframe controllers.
if (isExportable(pC) && isExportable(rC) && isExportable(sC)) {
if (pC->NumKeys() || rC->NumKeys() || sC->NumKeys()) {
// Create the animation path.
osg::AnimationPath* animationPath = new osg::AnimationPath();
animationPath->setLoopMode(osg::AnimationPath::LOOP);
exportPosKeys(animationPath, pC);
return animationPath;
}
}
// Or are we using other kinds of animations which can be sampled lineary.
if(hasAnimation(node)){
return sampleNode(node);
}
return NULL;
}
示例4: export_light
void SkeletonExporter::export_light(INode *node)
{
Control *c;
int size_key, sf;
ObjectState os;
GenLight* light;
struct LightState ls;
float near_radius, far_radius;
Point3 row;
Matrix3 mat;
os=node->EvalWorldState(0);
if (!os.obj) return; // per sicurezza
light=(GenLight*)os.obj;
// controlliamo se esiste un padre
INode *padre=node->GetParentNode();
if ((padre) && (strcmp(padre->GetName(), "Scene Root")!=0))
sf=strlen(padre->GetName())+1;
else sf=0;
light->EvalLightState(0, FOREVER, &ls);
fprintf(fTXT, "Name : %s\n", node->GetName());
switch (ls.type)
{
case OMNI_LGT: fprintf(fTXT, "Omni light found\n");
// flag padre + nome padre + pivot + NodeTM(0) +
// + colore
write_chunk_header(fA3D, OMNI_LIGHT_ID,
node->GetName(), 4+sf+12+48+12);
if (makeRAY) write_chunk_header(fRAY, OMNI_LIGHT_ID,
node->GetName(), 4+sf+12+48+12);
break;
case SPOT_LGT: fprintf(fTXT, "Spot light found\n");
// flag padre + nome padre + pivot + NodeTM(0) +
// + colore + falloff + hotspot
write_chunk_header(fA3D, SPOT_LIGHT_ID,
node->GetName(), 4+sf+12+48+12+8);
if (makeRAY) write_chunk_header(fRAY, SPOT_LIGHT_ID,
node->GetName(), 4+sf+12+48+12+8);
break;
}
// ----------- scrivo il padre (flag, nome) ------------------
fwrite(&sf, sizeof(int), 1, fA3D);
if (sf>0) write_string0(fA3D, padre->GetName());
if (makeRAY) fwrite(&sf, sizeof(int), 1, fRAY);
if (makeRAY)
if (sf>0) write_string0(fRAY, padre->GetName());
// --------------- scrittura del punto di pivot ----------------
GetPivotOffset(node, &row);
fprintf(fTXT, "Pivot point : %f, %f, %f\n", row.x, row.y, row.z);
write_point3(&row, fA3D);
if (makeRAY) write_point3(&row, fRAY);
// ------------------- salviamo la NodeTM(0) ---------------------
mat=node->GetNodeTM(0);
row=mat.GetRow(3);
fprintf(fTXT, "World position : x=%f, y=%f, z=%f\n", row.x, row.y, row.z);
write_matrix(&mat, fA3D);
if (makeRAY) write_matrix(&mat, fRAY);
// -------------------- salviamo il colore -----------------------
fprintf(fTXT, "Color : R=%f, G=%f, B=%f\n", ls.color.r, ls.color.g, ls.color.b);
fwrite(&ls.color.r, sizeof(float), 1, fA3D);
fwrite(&ls.color.g, sizeof(float), 1, fA3D);
fwrite(&ls.color.b, sizeof(float), 1, fA3D);
if (makeRAY) fwrite(&ls.color.r, sizeof(float), 1, fRAY);
if (makeRAY) fwrite(&ls.color.g, sizeof(float), 1, fRAY);
if (makeRAY) fwrite(&ls.color.b, sizeof(float), 1, fRAY);
// ---------------------- falloff e hotpsot ----------------------
if (ls.type == SPOT_LGT)
{
float hotspot = (float)(ls.hotsize*3.14159265358979323846/180.0);
float falloff = (float)(ls.fallsize*3.14159265358979323846/180.0);
fwrite(&hotspot, sizeof(float), 1, fA3D);
if (makeRAY) fwrite(&hotspot, sizeof(float), 1, fRAY);
fwrite(&falloff, sizeof(float), 1, fA3D);
if (makeRAY) fwrite(&falloff, sizeof(float), 1, fRAY);
}
fprintf(fTXT, "Intensity : %f\n", ls.intens);
// -------------- esportazione tracce di posizione ---------------
c=node->GetTMController()->GetPositionController();
if ((c) && (c->NumKeys()>0))
{
if (IsTCBControl(c)) size_key=36;
else
if (IsBezierControl(c)) size_key=40;
else size_key=16;
fprintf(fTXT, "Light position track present.");
write_chunk_header(fA3D, POSITION_TRACK_ID,
node->GetName(), 1+2+4+c->NumKeys()*size_key);
export_point3_track(c, 1, fA3D);
if (makeRAY) write_chunk_header(fRAY, POSITION_TRACK_ID,
node->GetName(), 1+2+4+c->NumKeys()*size_key);
//.........这里部分代码省略.........
示例5: export_camera
void SkeletonExporter::export_camera(INode *node)
{
Control *c;
int size_key;
float camera_znear, camera_zfar;
CameraState cs;
// Interval valid = FOREVER;
ObjectState os;
CameraObject *cam;
GenCamera *gencam;
float roll0;
Matrix3 mat;
Point3 row;
os = node->EvalWorldState(0);
cam = (CameraObject *)os.obj;
gencam = (GenCamera *)os.obj;
if (gencam->Type() != TARGETED_CAMERA)
{
fprintf(fTXT, "Only targeted camera are supported!\n\n");
return;
}
fprintf(fTXT, "Targeted camera found\n");
write_chunk_header(fA3D, TARGETED_CAMERA_ID, node->GetName(), 40);
if (makeRAY) write_chunk_header(fRAY, TARGETED_CAMERA_ID, node->GetName(), 40);
INode* target = node->GetTarget();
fprintf(fTXT, "Name : %s\n", node->GetName());
cam->EvalCameraState(0, FOREVER, &cs);
// ------------------ salviamo znear e zfar ----------------------
camera_znear=2;
camera_zfar=2000;
if (cs.manualClip)
{
camera_znear=cs.hither;
camera_zfar=cs.yon;
}
fprintf(fTXT, "Znear = %f \n", camera_znear);
fwrite(&camera_znear, sizeof(float), 1, fA3D);
if (makeRAY) fwrite(&camera_znear, sizeof(float), 1, fRAY);
fprintf(fTXT, "Zfar = %f \n", camera_zfar);
fwrite(&camera_zfar, sizeof(float), 1, fA3D);
if (makeRAY) fwrite(&camera_zfar, sizeof(float), 1, fRAY);
// ----------------- salviamo l'angolo di FOV --------------------
fprintf(fTXT, "FOV (rad) = %f \n", cs.fov);
fwrite(&cs.fov, sizeof(float), 1, fA3D);
if (makeRAY) fwrite(&cs.fov, sizeof(float), 1, fRAY);
// ------------------ salviamo l'angolo di roll ------------------
c=node->GetTMController()->GetRollController();
c->GetValue(0, &roll0, FOREVER);
fprintf(fTXT, "Roll (rad) = %f \n", roll0);
fwrite(&roll0, sizeof(float), 1, fA3D);
if (makeRAY) fwrite(&roll0, sizeof(float), 1, fRAY);
// salviamo la posizione nel mondo
mat = node->GetNodeTM(0);
row = mat.GetRow(3);
fprintf(fTXT, "Camera world position : x=%f, y=%f, z=%f\n", row.x, row.y, row.z);
write_point3(&row, fA3D);
if (makeRAY) write_point3(&row, fRAY);
// --------- salviamo la posizione del target nel mondo ----------
if (target)
{
mat = target->GetNodeTM(0);
row = mat.GetRow(3);
fprintf(fTXT, "Target world position : x=%f, y=%f, z=%f\n", row.x, row.y, row.z);
write_point3(&row, fA3D);
if (makeRAY) write_point3(&row, fRAY);
}
// esportiamo l'animazione della posizione della camera
// se ci sono un numero di key > 0
c=node->GetTMController()->GetPositionController();
if ((c) && (c->NumKeys()>0))
{
if (IsTCBControl(c)) size_key=36;
else
if (IsBezierControl(c)) size_key=40;
else size_key=16;
fprintf(fTXT, "Camera position track present.");
write_chunk_header(fA3D, POSITION_TRACK_ID,
node->GetName(), 1+2+4+c->NumKeys()*size_key);
export_point3_track(c, 1, fA3D);
if (makeRAY) write_chunk_header(fRAY, POSITION_TRACK_ID,
node->GetName(), 1+2+4+c->NumKeys()*size_key);
if (makeRAY) export_point3_track(c, 1, fRAY);
}
// ----- esportiamo l'animazione della posizione del target ------
if (target)
{
c=target->GetTMController()->GetPositionController();
if ((c) && (c->NumKeys()>0))
{
//.........这里部分代码省略.........
示例6: export_particle_spray
//.........这里部分代码省略.........
// informazioni in formato binario (.A3D)
fwrite(&width, sizeof(float), 1, fA3D);
fwrite(&height, sizeof(float), 1, fA3D);
fwrite(&initVel, sizeof(float), 1, fA3D);
fwrite(&var, sizeof(float), 1, fA3D);
fwrite(&life, sizeof(int), 1, fA3D);
fwrite(&start_time, sizeof(int), 1, fA3D);
fwrite(&stop_time, sizeof(int), 1, fA3D);
fwrite(&count, sizeof(int), 1, fA3D);
fwrite(&mod_count, sizeof(int), 1, fA3D);
fprintf(fTXT, "Modificatori (wind, gravity, bomb) collegati: %d\n", mod_count);
for (k=0; k<mod_count; k++)
{
fprintf(fTXT, "Modificatore %d: %s\n", k, modNames[k]);
write_string0(fA3D, modNames[k]);
//if (makeADP)
//fprintf(fADP, " modifier=%c%s, ON%c;\n", '"', modNames[k], '"');
}
//------------------------
// ESPORTAZIONE KEYFRAMER
//------------------------
Control *c;
int size_key;
// NB: per gli oggetti mesh e quant'altre tipologie di
// oggetti che possono essere linkati (ovvero dove e'
// possibile implmenetare gerarchie), esporto SEMPRE una key
// di posizione, una di rotazione ed una di scaling
// POSITION CONTROLLER
c=node->GetTMController()->GetPositionController();
if ((c) && (c->NumKeys()>0))
{
if (IsTCBControl(c)) size_key=36;
else
if (IsBezierControl(c)) size_key=40;
else size_key=16;
fprintf(fTXT, "Particle position track present.\n");
write_chunk_header(fA3D, POSITION_TRACK_ID,
node->GetName(), 1+2+4+c->NumKeys()*size_key);
export_point3_track(c, 1, fA3D);
}
else
{
fprintf(fTXT, "Particle position track present. (1 key case)\n");
if (!c) fprintf(fTXT, "c nullo !\n");
fflush(fTXT);
size_key=36;
write_chunk_header(fA3D, POSITION_TRACK_ID,
node->GetName(), 1+2+4+1*size_key);
export_1key_point3_track(c, 1, fA3D);
}
// ROTATION CONTROLLER
c=node->GetTMController()->GetRotationController();
if ((c) && (c->NumKeys()>0))
{
if (IsTCBControl(c)) size_key=40;
else size_key=20;
fprintf(fTXT, "Particle rotation track present.\n");
write_chunk_header(fA3D, ROTATION_TRACK_ID,
node->GetName(), 1+2+4+c->NumKeys()*size_key);
export_rot_track(c, fA3D);
示例7: export_WSM_wind
// ***********************************************************
// ****************** VENTO ***********************
// ***********************************************************
void SkeletonExporter::export_WSM_wind(INode *node)
{
Point3 row;
Matrix3 mat;
Control *c;
int size_key;
char sval[50];
ObjectState os = node->EvalWorldState(0);
if (!os.obj) return;
INode *padre=node->GetParentNode();
int sf;
if ((padre) && (strcmp(padre->GetName(), "Scene Root")!=0))
sf=strlen(padre->GetName())+1;
else sf=0;
fprintf(fTXT, "Wind space modifier found\n");
fprintf(fTXT, "Name : %s\n", node->GetName());
// flag padre + nome padre + pivot + matrice(t=0) +
// strenght + decay + mapping + turbolence + frequency + scale
write_chunk_header(fA3D, WIND_MODIFIER_ID, node->GetName(),
4+sf+12+48+4*6);
fwrite(&sf, sizeof(int), 1, fA3D);
if (sf>0) write_string0(fA3D, padre->GetName());
// --------------- scrittura del punto di pivot ----------------
GetPivotOffset(node, &row);
fprintf(fTXT, "Pivot point : %f, %f, %f\n", row.x, row.y, row.z);
write_point3(&row, fA3D);
// ------------------- scrittura matrice -----------------------
mat = node->GetNodeTM(0);
write_matrix(&mat, fA3D);
float turb, decay, stren, freq, scale;
int type=0;
SimpleWSMObject2 *obj=(SimpleWSMObject2 *)os.obj;
fflush(fTXT);
export_animatable(obj->pblock2, 5);
// ----------------------- strenght -----------------------
c=obj->pblock2->GetController(WPB_STRENGTH);
if (c) c->GetValue(0, &stren, FOREVER);
else obj->pblock2->GetValue(WPB_STRENGTH, 0, stren, FOREVER);
fprintf(fTXT, "Strenght: %f\n", stren); fflush(fTXT);
// ----------------------- decay -----------------------
c=obj->pblock2->GetController(WPB_DECAY);
if (c) c->GetValue(0, &decay, FOREVER);
else obj->pblock2->GetValue(WPB_DECAY, 0, decay, FOREVER);
fprintf(fTXT, "Decay: %f\n", decay); fflush(fTXT);
// ----------------------- type -----------------------
//obj->pblock2->GetValue(WPB_TYPE, 0, type, FOREVER);
//obj->pblock2->GetController(WPB_TYPE)->GetValue(0, &type, FOREVER);
type=0;
fprintf(fTXT, "Type: %d\n", type); fflush(fTXT);
// ----------------------- turbulence -----------------------
c=obj->pblock2->GetController(WPB_TURBULENCE);
if (c) c->GetValue(0, &turb, FOREVER);
else obj->pblock2->GetValue(WPB_TURBULENCE, 0, turb, FOREVER);
fprintf(fTXT, "Turbulence: %f\n", turb); fflush(fTXT);
// ----------------------- frequency -----------------------
c=obj->pblock2->GetController(WPB_FREQUENCY);
if (c) c->GetValue(0, &freq, FOREVER);
else obj->pblock2->GetValue(WPB_FREQUENCY, 0, freq, FOREVER);
fprintf(fTXT, "Frequency: %f\n", freq); fflush(fTXT);
// ----------------------- scale -----------------------
c=obj->pblock2->GetController(WPB_SCALE);
if (c) c->GetValue(0, &scale, FOREVER);
else obj->pblock2->GetValue(WPB_SCALE, 0, scale, FOREVER);
fprintf(fTXT, "Scale: %f\n", scale); fflush(fTXT);
fwrite(&stren, sizeof(float), 1, fA3D);
fwrite(&decay, sizeof(float), 1, fA3D);
fwrite(&type, sizeof(int), 1, fA3D);
fwrite(&turb, sizeof(float), 1, fA3D);
fwrite(&freq, sizeof(float), 1, fA3D);
fwrite(&scale, sizeof(float), 1, fA3D);
//------------------------
// ESPORTAZIONE KEYFRAMER
//------------------------
// POSITION CONTROLLER
c=node->GetTMController()->GetPositionController();
if ((c) && (c->NumKeys()>0))
{
if (IsTCBControl(c)) size_key=36;
//.........这里部分代码省略.........
示例8: export_WSM_gravity
// ***********************************************************
// ****************** GRAVITA' ***********************
// ***********************************************************
void SkeletonExporter::export_WSM_gravity(INode *node)
{
Matrix3 mat;
Point3 row;
float decay, stren;
int type;
char sval[50];
ObjectState os = node->EvalWorldState(0);
if (!os.obj) return;
mat = node->GetNodeTM(0);
INode *padre=node->GetParentNode();
int sf;
if ((padre) && (strcmp(padre->GetName(), "Scene Root")!=0))
sf=strlen(padre->GetName())+1;
else sf=0;
fprintf(fTXT, "Gravity space modifier found\n");
fprintf(fTXT, "Name : %s\n", node->GetName());
// flag padre + nome padre + strenght + decay + mapping +
// world position
write_chunk_header(fA3D, GRAVITY_MODIFIER_ID, node->GetName(),
4+sf+12+48+3*4);
fwrite(&sf, sizeof(int), 1, fA3D);
if (sf>0) write_string0(fA3D, padre->GetName());
// --------------- scrittura del punto di pivot ----------------
GetPivotOffset(node, &row);
fprintf(fTXT, "Pivot point : %f, %f, %f\n", row.x, row.y, row.z);
write_point3(&row, fA3D);
// ------------------- scrittura matrice -----------------------
mat = node->GetNodeTM(0);
write_matrix(&mat, fA3D);
SimpleWSMObject2 *obj=(SimpleWSMObject2 *)os.obj;
obj->pblock2->GetValue(GPB_STRENGTH, 0, stren, FOREVER);
obj->pblock2->GetValue(GPB_DECAY, 0, decay, FOREVER);
//obj->pblock2->GetValue(GPB_TYPE, 0, type, FOREVER);
type=0;
fprintf(fTXT, "Strength: %f\n", stren);
fprintf(fTXT, "Decay: %f\n", decay);
fprintf(fTXT, "Type: %d\n", type);
fwrite(&stren, sizeof(float), 1, fA3D);
fwrite(&decay, sizeof(float), 1, fA3D);
fwrite(&type, sizeof(int), 1, fA3D);
//------------------------
// ESPORTAZIONE KEYFRAMER
//------------------------
Control *c;
int size_key;
// POSITION CONTROLLER
c=node->GetTMController()->GetPositionController();
if ((c) && (c->NumKeys()>0))
{
if (IsTCBControl(c)) size_key=36;
else
if (IsBezierControl(c)) size_key=40;
else size_key=16;
fprintf(fTXT, "Object position track present.\n");
write_chunk_header(fA3D, POSITION_TRACK_ID,
node->GetName(), 1+2+4+c->NumKeys()*size_key);
export_point3_track(c, 1, fA3D);
}
else
{
fprintf(fTXT, "Object position track present. (1 key case)\n");
size_key=36;
write_chunk_header(fA3D, POSITION_TRACK_ID,
node->GetName(), 1+2+4+1*size_key);
export_1key_point3_track(c, 1, fA3D);
}
// ROTATION CONTROLLER
c=node->GetTMController()->GetRotationController();
if ((c) && (c->NumKeys()>0))
{
if (IsTCBControl(c)) size_key=40;
else size_key=20;
fprintf(fTXT, "Object rotation track present.\n");
write_chunk_header(fA3D, ROTATION_TRACK_ID,
node->GetName(), 1+2+4+c->NumKeys()*size_key);
export_rot_track(c, fA3D);
}
else
{
fprintf(fTXT, "Object rotation track present. (1 key case)\n");
size_key=40;
write_chunk_header(fA3D, ROTATION_TRACK_ID,
//.........这里部分代码省略.........