Direct3D



         

MeshPickWin::CreateScene()


CreateScene() MeshPick  9.2.

9.2. MeshPickWin::CreateScene()

BOOL MeshPickWin::CreateScene() { // ------- -------- D3DRMLOADRESOURCE resinfo; resinfo.hModule = NULL; resinfo.lpName = MAKEINTRESOURCE(IDR_SPHEREMESH); resinfo.lpType = "MESH"; LPDIRECT3DRMMESHBUILDER meshbuilder; d3drm->CreateMeshBuilder(&meshbuilder); meshbuilder->Load(&resinfo, NULL, D3DRMLOAD_FROMRESOURCE, NULL, NULL); meshbuilder->SetQuality(D3DRMRENDER_FLAT);

//------ ---------- for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { LPDIRECT3DRMMESH mesh; meshbuilder->CreateMesh(&mesh); mesh->SetGroupColorRGB(0, D3DVALUE(x % 2), D3DVALUE(y % 2), D3DVALUE(1));

LPDIRECT3DRMFRAME meshframe; d3drm->CreateFrame(scene, &meshframe); meshframe->AddVisual(mesh); int xoffset = (rand() % 3) - 1; int yoffset = (rand() % 3) - 1; meshframe->SetPosition(scene, D3DVALUE((x - 1) * 10 + xoffset), D3DVALUE((y - 1) * 10 + yoffset), D3DVALUE(0)); meshframe->SetRotation(scene, D3DVALUE(0), D3DVALUE(1), D3DVALUE(0), D3DVALUE(.1));

meshframe->Release(); meshframe = 0; mesh->Release(); mesh = 0; } }

meshbuilder->Release(); meshbuilder = 0;

//------- -------- scene->AddMoveCallback(UpdateDrag, NULL);

// -------- -------- LPDIRECT3DRMLIGHT dlight; d3drm->CreateLightRGB(D3DRMLIGHT_DIRECTIONAL, D3DVALUE(1.00), D3DVALUE(1.00), D3DVALUE(1.00), &dlight);

LPDIRECT3DRMFRAME dlightframe; d3drm->CreateFrame(scene, &dlightframe); dlightframe->AddLight(dlight); dlightframe->SetOrientation(scene, D3DVALUE(0), D3DVALUE(-1), D3DVALUE(1), D3DVALUE(0), D3DVALUE(1), D3DVALUE(0)); dlight->Release(); dlight = 0; dlightframe->Release(); dlightframe = 0;

//------ ---------- d3drm->CreateFrame(scene, &camera); camera->SetPosition(scene, D3DVALUE(0), D3DVALUE(0), D3DVALUE(-50));

d3drm->CreateViewport(device, camera, 0, 0, device->GetWidth(), device->GetHeight(), &viewport);

return TRUE; }

<