THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/01/2011 at 08:17, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;
---------
Okay so I have a function that worked 100% in R11.5 but does not do anything in R12. The function rotates the active object at the speed specified based on the current framerate.
I assume that somehting has changed in the timeline/ CTrack ... Here's is the code that worked in R11.5. Does anyone see any reason why it wouldn't work in R12? I'm not asking you to debug the whole thing. I am asking you to look to see if there is something in this code that has changed in the r12 sdk.. That will at least help me pin point what I should be looking at.
Thanks so much,.
//ROTATE PLANET
//====================================================//
Bool PlanetXObject::RotatePlanet(BaseObject *op, GeListNode* node){
if (!op) return FALSE;
BaseContainer *bc = ((BaseList2D* )node)->GetDataInstance();
if (!bc) return FALSE;
BaseDocument *doc = op->GetDocument();
if(!doc) return FALSE;
BaseObject* prnt = doc->GetActiveObject();
if(!prnt) return FALSE;
BaseTime time = doc->GetTime();
Real fps = doc->GetFps();
//Planet COUNTER CLOCKWISE Rotation
//==========================================//
if (bc->GetBool(PLANETX_GENERAL_ENABLE_ROTATION) &&
bc->GetBool(PLANETX_GENERAL_ROTATION_DIRECTION) == PLANETX_GENERAL_ROTATION_COUNTER_CLOCKWISE){
//Remove Existing Track
//==========================================//
if (prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)))){
prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)))->Remove();
}
//Insert the New Track
//==========================================//
CTrack *track = prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)));
if (!track){
track = CTrack::Alloc(prnt,DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)));
if (!track) return FALSE;
prnt->InsertTrackSorted(track);
}
//Get the Base Time
//==========================================//
BaseTime bstime = time;
//Set the Frame Rate (FPS)
//==========================================//
bstime.SetDenominator(fps);
Real deNomin;
deNomin = (60 *fps) / bc->GetReal(PLANETX_GENERAL_ROTATION_SPEED);
//First Key will be set at 0
//==========================================//
bstime.SetNumerator(0);
CKey *keyH = track->GetCurve()->AddKey(bstime,0);
if (!keyH) return false;
keyH->SetValue(track->GetCurve(),0); //Set Position to 0
//Second Key will be placed at deNomin
//==========================================//
bstime.SetNumerator(deNomin);
CKey *keyH2 = track->GetCurve()->AddKey(bstime,0);
if (!keyH2) return false;
keyH2->SetValue(track->GetCurve(),6.283185307); //Set Position to 360
track->SetAfter(CLOOP_REPEAT);
}
//Planet CLOCKWISE Rotation
//==========================================//
else if (bc->GetBool(PLANETX_GENERAL_ENABLE_ROTATION) &&
bc->GetBool(PLANETX_GENERAL_ROTATION_DIRECTION) == PLANETX_GENERAL_ROTATION_CLOCKWISE)
{
//Remove Existing Track
//==========================================//
if (prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0))))
{
prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)))->Remove();
}
//Insert the New Track
//==========================================//
CTrack *track = prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)));
if (!track)
{
track = CTrack::Alloc(prnt,DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)));
if (!track) return FALSE;
prnt->InsertTrackSorted(track);
}
//Get the Base Time
//==========================================//
BaseTime bstime = time;
//Set the Frame Rate (FPS)
//==========================================================================
bstime.SetDenominator(fps);
Real deNomin;
deNomin = (60 *fps) / bc->GetReal(PLANETX_GENERAL_ROTATION_SPEED);
//First Key will be set at 0
//==========================================================================
bstime.SetNumerator(0);
CKey *keyH = track->GetCurve()->AddKey(bstime,0);
if (!keyH) return false;
keyH->SetValue(track->GetCurve(),6.283185307); //Set Position to 0
//Second Key will be placed at 3 times the location of the frame rate (i.e. if FPS is set to 30, then the key will be placed at frame 45.
//==========================================================================
bstime.SetNumerator(deNomin);
CKey *keyH2 = track->GetCurve()->AddKey(bstime,0);
if (!keyH2) return false;
keyH2->SetValue(track->GetCurve(),0); //Set Position to 360
track->SetAfter(CLOOP_REPEAT);
}
else
{
if (prnt->FindCTrack(DescLevel(myID,DTYPE_REAL,0)))
{
prnt->FindCTrack(DescLevel(myID,DTYPE_REAL,0))->Remove();
}
}
}
PS this code compiles fine in R12 but does not rotate the object at all.