在max中,调用max渲染器对场景进行渲染

设置渲染灯光的灯光强度:

//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参考:

  • 16
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值