History

First working voxel insertion at fingertip

Philip Rosedale committed 12 years ago

Commit ea850361 parent a9139b05 files · +64 −4Browse files

Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all

Unified · Split

interface/src/Application.cpp+40−0
@@ -1487,6 +1487,44 @@ void Application::doKillLocalVoxels() { · 1486 unmodified lines
14871487 _wantToKillLocalVoxels = true;
14881488 }
14891489
1490+void Application::createVoxel(glm::vec3 position,
1491+ float scale,
1492+ glm::vec3 color,
1493+ bool isDestructive) {
1494+ VoxelDetail voxel;
1495+ voxel.x = position.x / TREE_SCALE;
1496+ voxel.y = position.y / TREE_SCALE;
1497+ voxel.z = position.z / TREE_SCALE;
1498+ voxel.s = scale / TREE_SCALE;
1499+ voxel.red = color.x;
1500+ voxel.green = color.y;
1501+ voxel.blue = color.z;
1502+ PACKET_TYPE message = isDestructive ? PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL;
1503+ _voxelEditSender.sendVoxelEditMessage(message, voxel);
1504+
1505+ // create the voxel locally so it appears immediately
1506+
1507+ _voxels.createVoxel(voxel.x, voxel.y, voxel.z, voxel.s,
1508+ voxel.red, voxel.green, voxel.blue,
1509+ isDestructive);
1510+
1511+ // Implement voxel fade effect
1512+ VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f);
1513+ const float VOXEL_BOUNDS_ADJUST = 0.01f;
1514+ float slightlyBigger = voxel.s * VOXEL_BOUNDS_ADJUST;
1515+ fade.voxelDetails.x = voxel.x - slightlyBigger;
1516+ fade.voxelDetails.y = voxel.y - slightlyBigger;
1517+ fade.voxelDetails.z = voxel.z - slightlyBigger;
1518+ fade.voxelDetails.s = voxel.s + slightlyBigger + slightlyBigger;
1519+ _voxelFades.push_back(fade);
1520+
1521+ // inject a sound effect
1522+ injectVoxelAddedSoundEffect();
1523+
1524+ // remember the position for drag detection
1525+ _justEditedVoxel = true;
1526+}
1527+
14901528 const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) {
14911529 return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE,
14921530 (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE,
@@ -4097,6 +4135,8 @@ bool Application::maybeEditVoxelUnderCursor() { · 2604 unmodified lines
40974135 _voxelEditSender.sendVoxelEditMessage(message, _mouseVoxel);
40984136
40994137 // create the voxel locally so it appears immediately
4138+ printf("create voxel from mouse %.4f, %.4f, %.4f, scale %.6f \n", _mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
4139+
41004140 _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s,
41014141 _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue,
41024142 Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t