I cannot get the timed float keys to be recognized, they appear as
garbage and the application then crashes.
So, the questions I have are as follows.
1) Is it possible to save, just key frame data without having first
saved an animation set or an animation. ( for, I have tried with and
without ).
2) When calculating the size of the animation_key , are all the
objects added together
i.e. sizeof (Animation_Key) +
sizeof(TimedFloatKeys) +
sizeof(FloatKeys) +
sizeof( DWORD ) + (3 * float ) // Float key
sizeof( DWORD) + // time
sizeof ( 2 * DWORD ) // type + nKeys
3) As the application crashes with an access violation, the size of
the
object in bytes is wrong and/or the structure of the pointer I am
passing is
wrong.
The structures and code follow.
typedef struct _FloatKeys
{
DWORD nValues;
float* fvalues;
}FloatKeys;
typedef struct _TimedFloatKeys
{
DWORD time;
FloatKeys tfkeys;
}TimedFloatKeys;
typedef struct pAnimationKey {
DWORD keyType;
DWORD nKeys;
TimedFloatKeys* keys;
}Animation_Key;
;
HRESULT ffile_handling::Save_Animation_Keys( int dxf )
{
HRESULT hr;
char output[255];
DWORD dw_size = 0;
DWORD dw_value = 0;
DWORD dw_time;
int i = 0;
int j = 0;
float* f;
f = new float [3];
f[0] = 0.0f;
f[1] = 1.0f;
f[2] = 2.0f;
DWORD cbsize;
cbsize = 40; // ( DWORD )( 1 * sizeof(Animation_Key* ) +
// ( 1 * sizeof(TimedFloatKeys ) +
//( 1 * sizeof(FloatKeys ) ) + 1 * ( 4 * sizeof( DWORD) ) +
( 3 * sizeof(float) ) ) ) ;
Animation_Key* p_ani_key = ( Animation_Key* ) malloc(cbsize);;
p_ani_key->keyType = 2;
p_ani_key->nKeys = 1;
p_ani_key->keys = (TimedFloatKeys* ) malloc( 1 *( ( 2 * sizeof
( DWORD) ) + ( 3 * sizeof(float) ) ) );
//p_ani_key->keys->tfkeys = ( FloatKeys* ) malloc(float_key_size);
sprintf(output," cbsize %d \n", cbsize );
OutputDebugString(output);
p_ani_key->keys->tfkeys.nValues = 3;
p_ani_key->keys->tfkeys.fvalues = new float [3];
p_ani_key->keys->tfkeys.fvalues[0] = 0.1f;
p_ani_key->keys->tfkeys.fvalues[1] = 0.5f;
p_ani_key->keys->tfkeys.fvalues[2] = 1.0f;
p_ani_key->keys->time = 0;
sprintf(output," nValues %d \n", p_ani_key->keys->tfkeys.nValues );
OutputDebugString(output);
sprintf(output," f 1 %f \n", p_ani_key->keys->tfkeys.fvalues[0] );
OutputDebugString(output);
sprintf(output," f 2 %f \n", p_ani_key->keys->tfkeys.fvalues[1] );
OutputDebugString(output);
sprintf(output," f 2 %f \n", p_ani_key->keys->tfkeys.fvalues[2] );
OutputDebugString(output);
hr = m_pxofSave->CreateDataObject( TID_D3DRMAnimationKey,
"key_frame",
NULL,
cbsize ,
&p_ani_key,
&ObjAnimationKey );
free (p_ani_key);
return hr;
}
Robert <watki...@hotmail.com> spake the secret code
<c3d161fc-af9a-46fd...@26g2000yqo.googlegroups.com> thusly:
>1) Is it possible to save, just key frame data without having first
>saved an animation set or an animation. ( for, I have tried with and
>without ).
Well, you can save anything you want in a .x file, so the strict
answer is yes. However, the point of animation keys is to have them
associated with an animation, so I don't think in practice you'll
find much success with that route.
>2) When calculating the size of the animation_key , are all the
>objects added together
>i.e. sizeof (Animation_Key) +
> sizeof(TimedFloatKeys) +
> sizeof(FloatKeys) +
> sizeof( DWORD ) + (3 * float ) // Float key
> sizeof( DWORD) + // time
> sizeof ( 2 * DWORD ) // type + nKeys
I'm not sure what you mean here. The data is stored in the .x file
according to the layout of the template. Once the data is read out
of the file, then its in your own data structures for you to handle.
You definately need to have all the data in a contiguous chunk of
memory when you write it to the .x file using the API.
>3) As the application crashes with an access violation, the size of
>the
>object in bytes is wrong and/or the structure of the pointer I am
>passing is
>wrong.
Is this your application, or another application?
You may want to look at Chapter 21 "X Files" from my book:
<http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>
You should use the newer ID3DXFile interfaces instead of the older
IDirectXFile interfaces. They fixed some bugs in the D3DX versions.
The older interfaces are officially deprecated and not recommended.
See ID3DXFile on MSDN:
<http://msdn.microsoft.com/en-us/library/ee421074(VS.85).aspx>
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>
Legalize Adulthood! <http://legalizeadulthood.wordpress.com>
Many thanks for answering, I like your book.
What I managed to do was to Build a class of my own and then impliment
it ! (wooo!).
It works and as a work around I save the model and then append my
data!
At last I am a real c++ programmer, I always wondered what those
constructors were used for !!!