바닥 추가
This commit is contained in:
@@ -73,7 +73,7 @@ bool MainScene::init()
|
|||||||
// Grid settings
|
// Grid settings
|
||||||
const int gridSize = 10;
|
const int gridSize = 10;
|
||||||
const float cubeDim = 1.0f;
|
const float cubeDim = 1.0f;
|
||||||
const float spacing = 0.1f;
|
const float spacing = 0.25f;
|
||||||
const float step = cubeDim + spacing;
|
const float step = cubeDim + spacing;
|
||||||
|
|
||||||
// Calculate center of the grid
|
// Calculate center of the grid
|
||||||
@@ -107,6 +107,25 @@ bool MainScene::init()
|
|||||||
ambLight->setCameraMask((unsigned short)CameraFlag::USER1);
|
ambLight->setCameraMask((unsigned short)CameraFlag::USER1);
|
||||||
this->addChild(ambLight);
|
this->addChild(ambLight);
|
||||||
|
|
||||||
|
// Add a Ground Plane
|
||||||
|
auto ground = MeshRenderer::create("cube.obj");
|
||||||
|
if (ground)
|
||||||
|
{
|
||||||
|
// Calculate the exact size needed to cover the grid
|
||||||
|
// Grid size is (gridSize-1)*step + cubeDim
|
||||||
|
float actualSize = gridWidth + cubeDim;
|
||||||
|
float padding = 2.0f; // Increased padding to 2.0
|
||||||
|
|
||||||
|
ground->setScaleX(actualSize + padding);
|
||||||
|
ground->setScaleZ(actualSize + padding);
|
||||||
|
ground->setScaleY(0.25f); // Thickness set to 0.25
|
||||||
|
// Positioned so the top surface is at Y = -0.5 (cubes are at Y=0 with height 1)
|
||||||
|
ground->setPosition3D(Vec3(gridCenter.x, -0.5f - 0.125f, gridCenter.z));
|
||||||
|
ground->setCameraMask((unsigned short)CameraFlag::USER1);
|
||||||
|
ground->setColor(Color3B(100, 100, 100));
|
||||||
|
this->addChild(ground);
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Camera for Quarter View (Isometric-like)
|
// Setup Camera for Quarter View (Isometric-like)
|
||||||
_camera3D = Camera::createPerspective(60.0f, visibleSize.width / visibleSize.height, 0.1f, 1000.0f);
|
_camera3D = Camera::createPerspective(60.0f, visibleSize.width / visibleSize.height, 0.1f, 1000.0f);
|
||||||
_camera3D->setCameraFlag(CameraFlag::USER1);
|
_camera3D->setCameraFlag(CameraFlag::USER1);
|
||||||
|
|||||||
Reference in New Issue
Block a user