void CActor::PickupInfoDraw(CObject* object) { LPCSTR draw_str = NULL; CInventoryItem* item = smart_cast<CInventoryItem*>(object); if(!item) return; Fmatrix res; res.mul (Device.mFullTransform,object->XFORM()); Fvector4 v_res; Fvector shift; draw_str = item->NameItem(); shift.set(0,0,0); res.transform(v_res,shift); if (v_res.z < 0 || v_res.w < 0) return; if (v_res.x < -1.f || v_res.x > 1.f || v_res.y<-1.f || v_res.y>1.f) return; float x = (1.f + v_res.x)/2.f * (Device.dwWidth); float y = (1.f - v_res.y)/2.f * (Device.dwHeight); UI().Font().pFontLetterica16Russian->SetAligment (CGameFont::alCenter); UI().Font().pFontLetterica16Russian->SetColor (PICKUP_INFO_COLOR); UI().Font().pFontLetterica16Russian->Out (x,y,draw_str); }
float CBaseMonster::get_screen_space_coverage_diagonal() { Fbox b = Visual()->getVisData().box; Fmatrix xform; xform.mul (Device.mFullTransform,XFORM()); Fvector2 mn ={flt_max,flt_max},mx={flt_min,flt_min}; for (u32 k=0; k<8; ++k) { Fvector p; b.getpoint (k,p); xform.transform (p); mn.x = _min(mn.x,p.x); mn.y = _min(mn.y,p.y); mx.x = _max(mx.x,p.x); mx.y = _max(mx.y,p.y); } float const width = mx.x - mn.x; float const height = mx.y - mn.y; float const average_diagonal = _sqrt(width * height); return average_diagonal; }
void occRasterizer::on_dbg_render() { #if DEBUG if( !ps_r2_ls_flags_ext.is(R_FLAGEXT_HOM_DEPTH_DRAW) ) { dbg_HOM_draw_initialized = false; return; } for ( int i = 0; i< occ_dim_0; ++i) { for ( int j = 0; j< occ_dim_0; ++j) { if( bDebug ) { Fvector quad,left_top,right_bottom,box_center,box_r; quad.set( (float)j-occ_dim_0/2.f, -((float)i-occ_dim_0/2.f), (float)bufDepth_0[i][j]/occQ_s32); Device.mProject; float z = -Device.mProject._43/(float)(Device.mProject._33-quad.z); left_top.set ( quad.x*z/Device.mProject._11/(occ_dim_0/2.f), quad.y*z/Device.mProject._22/(occ_dim_0/2.f), z); right_bottom.set ( (quad.x+1)*z/Device.mProject._11/(occ_dim_0/2.f), (quad.y+1)*z/Device.mProject._22/(occ_dim_0/2.f), z); box_center.set ((right_bottom.x + left_top.x)/2, (right_bottom.y + left_top.y)/2, z); box_r = right_bottom; box_r.sub(box_center); Fmatrix inv; inv.invert(Device.mView); inv.transform( box_center ); inv.transform_dir( box_r ); pixel_box& tmp = dbg_pixel_boxes[ i*occ_dim_0+j]; tmp.center = box_center; tmp.radius = box_r; tmp.z = quad.z; dbg_HOM_draw_initialized = true; } if( !dbg_HOM_draw_initialized ) return; pixel_box& tmp = dbg_pixel_boxes[ i*occ_dim_0+j]; Fmatrix Transform; Transform.identity(); Transform.translate(tmp.center); // draw wire Device.SetNearer(TRUE); RCache.set_Shader (dxRenderDeviceRender::Instance().m_SelectionShader); RCache.dbg_DrawOBB( Transform, tmp.radius, D3DCOLOR_XRGB(u32(255*pow(tmp.z,20.f)),u32(255*(1-pow(tmp.z,20.f))),0) ); Device.SetNearer(FALSE); } } #endif }
void CLevelDebug::draw_object_info() { // handle all of the objects for (OBJECT_INFO_MAP_IT it = m_objects_info.begin(); it != m_objects_info.end(); ++it) { // если объект невалидный - удалить информацию if (!it->first || it->first->getDestroy()) { for (CLASS_INFO_MAP_IT it_class = it->second.begin(); it_class != it->second.end(); ++it_class){ xr_delete(it_class->second); } m_objects_info.erase(it); break; } Fmatrix res; res.mul (Device.mFullTransform,it->first->XFORM()); Fvector4 v_res; float delta_height = 0.f; // handle all of the classes for (CLASS_INFO_MAP_IT class_it = it->second.begin(); class_it != it->second.end(); ++class_it) { // get up on 2 meters res.transform(v_res, class_it->second->get_shift_pos()); // check if the object in sight if (v_res.z < 0 || v_res.w < 0) continue; if (v_res.x < -1.f || v_res.x > 1.f || v_res.y<-1.f || v_res.y>1.f) continue; // get real (x,y) float x = (1.f + v_res.x)/2.f * (Device.dwWidth); float y = (1.f - v_res.y)/2.f * (Device.dwHeight) - delta_height; float start_y = y; // handle all of the text inside class class_it->second->draw_info(x,y); delta_height = start_y - y; } } }