R
Robert
I am trying to create dynamic constructors but have encountered a
problem.
I am trying to populate a floating point array as part of the class
structure.
But seemingly what ever I try returns the same result.
Which seems to be all data that is not an array, gets passed through
ok.
But if the variable is an array, in this case an array of floats, then
the values are not created.
I figure that, you may be able to help . . .
So, firstly, I have these classes, followed by the code and then the
debug output.
Any help will be very much appreciated.
Rob.
/////////////////////////
class FloatKeys
{
public:
DWORD nValues;
float* fvalues;
FloatKeys( DWORD n_type, float *f );
FloatKeys();
~FloatKeys();
};
FloatKeys::FloatKeys( DWORD n_type, float* fkeys )
{
nValues = n_type;
fvalues = new float [n_type];
fvalues[0] = fkeys[0] ;
fvalues[1] = fkeys[1] ;
fvalues[2] = fkeys[2] ;
}
FloatKeys::FloatKeys()
{
}
FloatKeys::~FloatKeys()
{
}
/////////////////////////////////
class TimedFloatKeys
{
public:
DWORD time;
FloatKeys tfkeys;
TimedFloatKeys ( DWORD dw_time, FloatKeys fltkey );
TimedFloatKeys();
~TimedFloatKeys();
};
TimedFloatKeys::TimedFloatKeys ( DWORD dw_time, FloatKeys fltkey )
{
time = dw_time;
tfkeys.fvalues = new float [3];
tfkeys = fltkey;
}
TimedFloatKeys::TimedFloatKeys()
{
}
TimedFloatKeys::~TimedFloatKeys()
{
}
////////////////////////////////
class Animation_key {
public:
DWORD keyType;
DWORD nKeys;
TimedFloatKeys* timed_float_key;
Animation_key( DWORD dw_type, DWORD n_Key, TimedFloatKeys*
timed_float_array );
Animation_key();
~Animation_key();
};
Animation_key::Animation_key( DWORD dw_type, DWORD n_Key,
TimedFloatKeys*
timed_float_array )
{
DWORD j = 0;
DWORD i = 0;
keyType = dw_type;
nKeys = n_Key;
timed_float_key = new TimedFloatKeys [n_Key];
for( i = 0; i < n_Key; i++ )
{
timed_float_key.time = timed_float_array.time;
timed_float_key.tfkeys.nValues = timed_float_array
.tfkeys.nValues;
for( j = 0; j < timed_float_key[j].tfkeys.nValues; j++ )
{
timed_float_key.tfkeys.fvalues = new float
[timed_float_key.tfkeys.nValues];
timed_float_key.tfkeys.fvalues[j] = (float)j;
//
timed_float_array.tfkeys.fvalues[j];
}
}
}
Animation_key::Animation_key()
{
}
Animation_key::~Animation_key()
{
}
// I try to invoke the classes with this code.
HRESULT ffile_handling::Save_Animation_Keys( )
{
HRESULT hr;
DWORD cbsize = 64;
char output[255];
float* f_key = new float [3];
f_key[0] = 1.0f;
f_key[1] = 5.0f;
f_key[2] = 9.0f;
DWORD t = 24;
// FLOAT KEY
FloatKeys my_flt( 3, f_key );
// TIMED FLOAT KEYS
TimedFloatKeys* tfk_ptr;
TimedFloatKeys my_timed_flts( t, my_flt );
tfk_ptr = &my_timed_flts;
;
// ANIMATION KEY
Animation_key a_key(2, 1, tfk_ptr );
// BREAK POINT –
the output as seen in the debugger is this:
[] a_key {…}
|
|---key_Type 2
|---nKeys 1
|---[] timed_float_key 0x00cb2204
|-------time 24
|---[] tfkeys { … }
|---nValues 3
|---[] fvalues 0x00cb2140
|-- -4.31602e+008
problem.
I am trying to populate a floating point array as part of the class
structure.
But seemingly what ever I try returns the same result.
Which seems to be all data that is not an array, gets passed through
ok.
But if the variable is an array, in this case an array of floats, then
the values are not created.
I figure that, you may be able to help . . .
So, firstly, I have these classes, followed by the code and then the
debug output.
Any help will be very much appreciated.
Rob.
/////////////////////////
class FloatKeys
{
public:
DWORD nValues;
float* fvalues;
FloatKeys( DWORD n_type, float *f );
FloatKeys();
~FloatKeys();
};
FloatKeys::FloatKeys( DWORD n_type, float* fkeys )
{
nValues = n_type;
fvalues = new float [n_type];
fvalues[0] = fkeys[0] ;
fvalues[1] = fkeys[1] ;
fvalues[2] = fkeys[2] ;
}
FloatKeys::FloatKeys()
{
}
FloatKeys::~FloatKeys()
{
}
/////////////////////////////////
class TimedFloatKeys
{
public:
DWORD time;
FloatKeys tfkeys;
TimedFloatKeys ( DWORD dw_time, FloatKeys fltkey );
TimedFloatKeys();
~TimedFloatKeys();
};
TimedFloatKeys::TimedFloatKeys ( DWORD dw_time, FloatKeys fltkey )
{
time = dw_time;
tfkeys.fvalues = new float [3];
tfkeys = fltkey;
}
TimedFloatKeys::TimedFloatKeys()
{
}
TimedFloatKeys::~TimedFloatKeys()
{
}
////////////////////////////////
class Animation_key {
public:
DWORD keyType;
DWORD nKeys;
TimedFloatKeys* timed_float_key;
Animation_key( DWORD dw_type, DWORD n_Key, TimedFloatKeys*
timed_float_array );
Animation_key();
~Animation_key();
};
Animation_key::Animation_key( DWORD dw_type, DWORD n_Key,
TimedFloatKeys*
timed_float_array )
{
DWORD j = 0;
DWORD i = 0;
keyType = dw_type;
nKeys = n_Key;
timed_float_key = new TimedFloatKeys [n_Key];
for( i = 0; i < n_Key; i++ )
{
timed_float_key.time = timed_float_array.time;
timed_float_key.tfkeys.nValues = timed_float_array
.tfkeys.nValues;
for( j = 0; j < timed_float_key[j].tfkeys.nValues; j++ )
{
timed_float_key.tfkeys.fvalues = new float
[timed_float_key.tfkeys.nValues];
timed_float_key.tfkeys.fvalues[j] = (float)j;
//
timed_float_array.tfkeys.fvalues[j];
}
}
}
Animation_key::Animation_key()
{
}
Animation_key::~Animation_key()
{
}
// I try to invoke the classes with this code.
HRESULT ffile_handling::Save_Animation_Keys( )
{
HRESULT hr;
DWORD cbsize = 64;
char output[255];
float* f_key = new float [3];
f_key[0] = 1.0f;
f_key[1] = 5.0f;
f_key[2] = 9.0f;
DWORD t = 24;
// FLOAT KEY
FloatKeys my_flt( 3, f_key );
// TIMED FLOAT KEYS
TimedFloatKeys* tfk_ptr;
TimedFloatKeys my_timed_flts( t, my_flt );
tfk_ptr = &my_timed_flts;
;
// ANIMATION KEY
Animation_key a_key(2, 1, tfk_ptr );
// BREAK POINT –
the output as seen in the debugger is this:
[] a_key {…}
|
|---key_Type 2
|---nKeys 1
|---[] timed_float_key 0x00cb2204
|-------time 24
|---[] tfkeys { … }
|---nValues 3
|---[] fvalues 0x00cb2140
|-- -4.31602e+008