THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/04/2008 at 13:35, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10
Platform: Windows ;
Language(s) : C++ ;
---------
Hi,
in my expression tag, I have a function to record keyframes... it gets global position and rotation, as well as other attributes, from the camera object the tag is attached to, and stores them in keyframes for another camera object.
Some users (they all use Win32) experience a crash immediately when using that function. The problem is: whatever I do, I can't reproduce that crash. It just runs perfectly on my computer. Tested in R10.1 and R10.5, no difference.
Here's my code of the recording function:
> <code> Vector GlobalPos = op->GetMg().off;
> Vector GlobalRot = MatrixToHPB(op->GetMg());
> SC_RecorderCam->SetMg(op->GetMg());
> if (SC_FocusEnabled)
> {
> SC_RecorderCam->GetDataInstance()->SetBool(CAMERAOBJECT_FRONTBLUR, true);
> SC_RecorderCam->GetDataInstance()->SetBool(CAMERAOBJECT_REARBLUR, true);
> CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_TARGETDISTANCE, SC_FocusDistance + SC_FocusOffset + SC_DeFocusOffset);
> CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_FRONTSTART, SC_FocusRangeMin / 2);
> CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_FRONTEND, SC_FocusRangeMin / 2);
> CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_REARSTART, SC_FocusRangeMin / 2);
> CreateKey(doc, SC_RecorderCam, currentTime, CAMERAOBJECT_REAREND, SC_FocusRangeMax / 2);
> CreateKey(doc, SC_RecorderCam, currentTime, CAMERA_FOCUS, SC_FocusZoom);
> }
> CreateVectorKey(doc, SC_RecorderCam, currentTime, ID_BASEOBJECT_POSITION, GlobalPos);
> CreateVectorKey(doc, SC_RecorderCam, currentTime, ID_BASEOBJECT_ROTATION, GlobalRot);
> tag->GetDataInstance()->SetString(SCOOBYCAMEXP_RECORDER_INFOTEXT, GeLoadString(SCOOBYCAMEXP_MSG_RECORD_RECORDING));
> </code>
The functions CreateKey and CreateVectorKey look like this:
> <code>static Bool CreateKey(BaseDocument *doc, BaseObject *op, const BaseTime &time;, LONG index, Real value)
> {
> // check if track exists
> CTrack *track = op->FindCTrack(DescLevel(index,DTYPE_REAL,0));
> if (!track)
> {
> track = CTrack::Alloc(op,DescLevel(index,DTYPE_REAL,0)); if (!track) return FALSE;
> op->InsertTrackSorted(track);
> }
>
> CKey *key = track->GetCurve()->AddKey(time); if (!key) return FALSE;
> key->SetValue(track->GetCurve(),value);
> return TRUE;
> }
>
> static Bool CreateVectorKey(BaseDocument *doc, BaseObject *op, const BaseTime &time;, LONG index, Vector value)
> {
> // check if tracks exist
> CTrack *trackX = op->FindCTrack(DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_X,DTYPE_REAL,0)));
> CTrack *trackY = op->FindCTrack(DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_Y,DTYPE_REAL,0)));
> CTrack *trackZ = op->FindCTrack(DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_Z,DTYPE_REAL,0)));
>
> if (!trackX)
> {
> trackX = CTrack::Alloc(op,DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_X,DTYPE_REAL,0)));
> op->InsertTrackSorted(trackX);
> }
> if (!trackY)
> {
> trackY = CTrack::Alloc(op,DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_Y,DTYPE_REAL,0)));
> op->InsertTrackSorted(trackY);
> }
> if (!trackZ)
> {
> trackZ = CTrack::Alloc(op,DescID(DescLevel(index,DTYPE_VECTOR,0),DescLevel(VECTOR_Z,DTYPE_REAL,0)));
> op->InsertTrackSorted(trackZ);
> }
>
> CKey *keyX = trackX->GetCurve()->AddKey(time); if (!keyX) return FALSE;
> CKey *keyY = trackY->GetCurve()->AddKey(time); if (!keyY) return FALSE;
> CKey *keyZ = trackZ->GetCurve()->AddKey(time); if (!keyZ) return FALSE;
>
> keyX->SetValue(trackX->GetCurve(),value.x);
> keyY->SetValue(trackY->GetCurve(),value.y);
> keyZ->SetValue(trackZ->GetCurve(),value.z);
>
> return TRUE;
> }</code>
Greetings and thanks for any help,
Jack