设置渲染灯光的灯光强度:
//light_node是场景中的灯光节点
//light_intensity是设置的灯光强度
((LightObject*)(light_node->GetObjectRef()->FindBaseObject()))->SetIntensity(GetCOREInterface()->GetTime(), light_intensity);
//将需要继续渲染的灯光显示,不需要渲染的灯光隐藏
//显示
info.light->Hide(false);
//隐藏
info.light->Hide(true);
初始化Bitmap:
Bitmap* map;
Bitmap* shadow_map;
Bitmap* alpha_map;
BitmapInfo bi;
RECT rect;
::GetWindowRect(ip->GetActiveViewExp().getGW()->getHWnd(), &rect);
bi.SetWidth(rect.right - rect.left);
bi.SetHeight(rect.bottom - rect.top);
bi.SetType(BMM_TRUE_64);
bi.SetFlags(MAP_HAS_ALPHA);
bi.SetCustomFlag(0);
map=TheManager->Create(&bi);
shadow_map=TheManager->Create(&bi);
alpha_map=TheManager->Create(&bi);
渲染并获取像素:
//.h
Interface* ip=GetCOREInterface();
//.cpp
BMM_Color_64 ptr_alpha[10000];
BMM_Color_64 ptr[10000];
BitmapInfo bi;
ip->OpenCurRenderer(camera_node, nullptr);//设置摄像机节点
ip->CurRendererRenderFrame(ip->GetTime(), shadow_map);
ip->CurRendererRenderFrame(ip->GetTime(), alpha_map);
for (int i = 0; i < alpha_map->Height(); i++) {
alpha_map->GetPixels(0, i, alpha_map->Width(), ptr_alpha);
map->GetPixels(0, i, map->Width(), ptr);
for (int j = 0; j < alpha_map->Width(); j++) {
ptr[j].a = (ptr_alpha[j].a !=0) ? ptr_alpha[j].a : 0;
}
}
bi = display_map->GetBitmapInfo();
bi.SetName(QString(name));
display_map->OpenOutput(&bi);
display_map->Write(&bi);
display_map->Close(&bi);
ip->CloseCurRenderer();
api参考: