|
#include "Lib3ds_viewport.h"
Lib3ds_viewport::Lib3ds_viewport()
{
}
bool Lib3ds_viewport::lib3ds_viewport_read(Lib3dsViewport *viewport)
{
Lib3dsChunk c;
uint16_t chunk;
memset(&viewport->setting, 0, sizeof(Lib3dsViewport_setting));
if(!lib3ds_chunk_read_start(&c, 0))
{
return false;
}
switch (c.chunk)
{
case CHK_VIEWPORT_LAYOUT: // Flag of viewpost layout
{
int cur = 0;
viewport->setting.layout_style = lib3ds_io_read_word();
viewport->setting.layout_active = lib3ds_io_read_intw();
lib3ds_io_read_intw();
viewport->setting.layout_swap = lib3ds_io_read_intw();
lib3ds_io_read_intw();
viewport->setting.layout_swap_prior = lib3ds_io_read_intw();
viewport->setting.layout_swap_view = lib3ds_io_read_intw();
lib3ds_chunk_read_tell(&c);
while ((chunk = lib3ds_chunk_read_next(&c)) != 0)
{
switch (chunk)
{
case CHK_VIEWPORT_SIZE: // Flag of viewport
{
viewport->setting.layout_position[0] = lib3ds_io_read_word();
viewport->setting.layout_position[1] = lib3ds_io_read_word();
viewport->setting.layout_size[0] = lib3ds_io_read_word();
viewport->setting.layout_size[1] = lib3ds_io_read_word();
break;
}
case CHK_VIEWPORT_DATA_3: // Flag of reading of the views
{
if (cur < LIB3DS_LAYOUT_MAX_VIEWS)
{
lib3ds_io_read_intw();
viewport->layout_views[cur].setting.axis_lock = lib3ds_io_read_word();
viewport->layout_views[cur].setting.position[0] = lib3ds_io_read_intw();
viewport->layout_views[cur].setting.position[1] = lib3ds_io_read_intw();
viewport->layout_views[cur].setting.size[0] = lib3ds_io_read_intw();
viewport->layout_views[cur].setting.size[1] = lib3ds_io_read_intw();
viewport->layout_views[cur].setting.type = lib3ds_io_read_word();
viewport->layout_views[cur].setting.zoom = lib3ds_io_read_float();
lib3ds_io_read_vector(viewport->layout_views[cur].setting.center);
viewport->layout_views[cur].setting.horiz_angle = lib3ds_io_read_float();
viewport->layout_views[cur].setting.vert_angle = lib3ds_io_read_float();
lib3ds_io_read_string(viewport->layout_views[cur].camera, 11);
++cur;
}
break;
}
case CHK_VIEWPORT_DATA:
/* 3DS R2 & R3 chunk unsupported */
break;
default:
lib3ds_chunk_unknown(chunk);
}
}
break;
}
case CHK_DEFAULT_VIEW: // Flag reading of the default view
{
while ((chunk = lib3ds_chunk_read_next(&c)) != 0)
{
switch (chunk)
{
case CHK_VIEW_TOP: // Flag of reading value of the top
{
viewport->setting.default_type = LIB3DS_VIEW_TOP;
lib3ds_io_read_vector(viewport->setting.default_position);
viewport->setting.default_width = lib3ds_io_read_float();
break;
}
case CHK_VIEW_BOTTOM: // Flag of reading value of the bottom
{
viewport->setting.default_type = LIB3DS_VIEW_BOTTOM;
lib3ds_io_read_vector(viewport->setting.default_position);
viewport->setting.default_width = lib3ds_io_read_float();
break;
}
case CHK_VIEW_LEFT: // Flag of reading value of the left
{
viewport->setting.default_type = LIB3DS_VIEW_LEFT;
lib3ds_io_read_vector(viewport->setting.default_position);
viewport->setting.default_width = lib3ds_io_read_float();
break;
}
case CHK_VIEW_RIGHT: // Flag of reading value of the right
{
viewport->setting.default_type = LIB3DS_VIEW_RIGHT;
lib3ds_io_read_vector(viewport->setting.default_position);
viewport->setting.default_width = lib3ds_io_read_float();
break;
}
case CHK_VIEW_FRONT: // Flag of reading value of the front
{
viewport->setting.default_type = LIB3DS_VIEW_FRONT;
lib3ds_io_read_vector(viewport->setting.default_position);
viewport->setting.default_width = lib3ds_io_read_float();
break;
}
case CHK_VIEW_BACK: // Flag of reading value of the back
{
viewport->setting.default_type = LIB3DS_VIEW_BACK;
lib3ds_io_read_vector(viewport->setting.default_position);
viewport->setting.default_width = lib3ds_io_read_float();
break;
}
case CHK_VIEW_USER: // Flag of reading of the user view
{
viewport->setting.default_type = LIB3DS_VIEW_USER;
lib3ds_io_read_vector(viewport->setting.default_position);
viewport->setting.default_width = lib3ds_io_read_float();
viewport->setting.default_horiz_angle = lib3ds_io_read_float();
viewport->setting.default_vert_angle = lib3ds_io_read_float();
viewport->setting.default_roll_angle = lib3ds_io_read_float();
break;
}
case CHK_VIEW_CAMERA: // Flag of reading of value of the view camera
{
viewport->setting.default_type = LIB3DS_VIEW_CAMERA;
lib3ds_io_read_string(viewport->default_camera, 11);
break;
}
default:
lib3ds_chunk_unknown(chunk);
}
}
break;
}
}
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.