|
#include "Lib3ds_camera.h"
#include <math.h>
Lib3ds_camera::Lib3ds_camera()
{
}
/*!
* Return a new Lib3dsCamera object.
*
* Object is initialized with the given name and fov=45. All other
* values are 0.
*
* \param name Name of this camera. Must not be NULL. Must be < 64 characters.
*
* \return Lib3dsCamera object or NULL on failure.
*/
Lib3dsCamera Lib3ds_camera::lib3ds_camera_new(QString name)
{
Lib3dsCamera camera;
memset(&camera.setting, 0, sizeof(Lib3dsCamera_setting));
camera.name = name;
camera.setting.fov = 45.0f;
return camera;
}
/*!
* Read a camera definition from a file.
*
* This function is called by lib3ds_file_read(), and you probably
* don't want to call it directly.
*
* \param camera A Lib3dsCamera to be filled in.
* \param io A Lib3dsIo object previously set up by the caller.
*
* \see lib3ds_file_read
*/
bool Lib3ds_camera::lib3ds_camera_read(Lib3dsCamera *camera)
{
Lib3dsChunk c;
uint16_t chunk;
if(!lib3ds_chunk_read_start(&c, CHK_N_CAMERA))
{
return false;
}
{
int i;
for (i = 0; i < 3; ++i)
{
camera->setting.position[i] = lib3ds_io_read_float();
}
for (i = 0; i < 3; ++i)
{
camera->setting.target[i] = lib3ds_io_read_float();
}
}
camera->setting.roll = lib3ds_io_read_float();
{
float s;
s = lib3ds_io_read_float();
if (fabs(s) < LIB3DS_EPSILON)
{
camera->setting.fov = 45.0;
}
else
{
camera->setting.fov = 2400.0f / s;
}
}
lib3ds_chunk_read_tell(&c);
while ((chunk = lib3ds_chunk_read_next(&c)) != 0)
{
switch (chunk)
{
case CHK_CAM_SEE_CONE:
{
camera->setting.see_cone = TRUE;
}
break;
case CHK_CAM_RANGES:
{
camera->setting.near_range = lib3ds_io_read_float();
camera->setting.far_range = lib3ds_io_read_float();
}
break;
default:
lib3ds_chunk_unknown(chunk);
}
}
lib3ds_chunk_read_end(&c);
return true;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.