本文整理汇总了C++中ModelObject::LoadDefineModel方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelObject::LoadDefineModel方法的具体用法?C++ ModelObject::LoadDefineModel怎么用?C++ ModelObject::LoadDefineModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelObject
的用法示例。
在下文中一共展示了ModelObject::LoadDefineModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GameInit
bool GameInit(HWND hwnd)
{
window_hdc = GetDC(hwnd);
buffer_hdc = CreateCompatibleDC(window_hdc);
ReleaseDC(hwnd, window_hdc);
SetClientSize(hwnd, WINDOW_WIDTH, WINDOW_HEIGHT);
BITMAPINFO bmp_info;
bmp_info.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);//结构体的字节数
bmp_info.bmiHeader.biWidth = WINDOW_WIDTH;//以像素为单位的位图宽
bmp_info.bmiHeader.biHeight =WINDOW_HEIGHT;//以像素为单位的位图高,若为负,表示以左上角为原点,否则以左下角为原点
bmp_info.bmiHeader.biPlanes = 1;//目标设备的平面数,必须设置为1
bmp_info.bmiHeader.biBitCount = 32; //位图中每个像素的位数
bmp_info.bmiHeader.biCompression = BI_RGB;
bmp_info.bmiHeader.biSizeImage = 0;
bmp_info.bmiHeader.biXPelsPerMeter = 0;
bmp_info.bmiHeader.biYPelsPerMeter = 0;
bmp_info.bmiHeader.biClrUsed = 0;
bmp_info.bmiHeader.biClrImportant = 0;
if (render_context->frame_buffer == nullptr)
{
render_context->InitFrameBuffer();
}
if (render_context->z_buffer == nullptr)
{
render_context->InitZBuffer();
}
if (now_bitmap == nullptr)
{
now_bitmap = CreateDIBSection(buffer_hdc, &bmp_info, DIB_RGB_COLORS, (void**)&render_context->frame_buffer, NULL, 0);
}
srand(GetTickCount());
InitSinCosTable();
cam.Init( // the camera object
CAM_MODEL_EULER, // the euler model
cam_pos, // initial camera position
cam_dir, // initial camera angles
Vec4f{0,0,0,0}, // no target
1.0, // near and far clipping planes
300.0,
60.0, // field of view in degrees
WINDOW_WIDTH, // size of final screen viewport
WINDOW_HEIGHT);
Vec4f vscale = { 5.0,5.0,5.0,1 }, vpos = { 0,0,0,1 }, vrot = { 0,0,0,1 };
// load the cube
bool load= obj.LoadDefineModel("cube.mod", vscale, vpos, vrot);
//obj.LoadDefineModel("cube.mod", vscale, vpos, vrot);
if (!load)return 0;
// set the position of the cube in the world7 0
obj.world_pos.x = 0;
obj.world_pos.y = 0;
obj.world_pos.z = 100;
bmp.ReadBitmap("brick.bmp");
render_context->bmp = &bmp;
light.color = Vec4f(1.0f, 1.0f, 1.0f, 1.0f);//如果是白光,颜色调制时可以不乘
light.position = Vec4f(0.0f, 0.0f, 1.0f, 1.0f);
light.neg_direction= Vec4f(0.2f, 0.0f, -1.0f, 1.0f);
light.neg_direction.Normalize();
obj.neg_light = light.neg_direction;
render_context->light = &light;
render_context->cam = &cam;
return true;
}