Fixed Vector directions, tweaked colors, fixed entity scaling. Entities aren't updating, unsure if that's a new thing or not.

master
Auri 2021-09-03 01:20:56 -07:00
parent 838680f0fc
commit 22a6c4c28f
28 changed files with 133 additions and 118 deletions

View File

@ -6,7 +6,7 @@
zepha.register_blockmodel("base:block", {
parts = {
{
face = "left",
face = "back",
tex = 3,
points = {
0, 0, 0, 0, 1,
@ -15,7 +15,7 @@ zepha.register_blockmodel("base:block", {
0, 1, 0, 0, 0
}
}, {
face = "right",
face = "front",
tex = 4,
points = {
1, 1, 1, 0, 0,
@ -42,7 +42,7 @@ zepha.register_blockmodel("base:block", {
0, 0, 1, 0, 1
}
}, {
face = "front",
face = "left",
tex = 5,
points = {
0, 0, 1, 0, 1,
@ -51,7 +51,7 @@ zepha.register_blockmodel("base:block", {
0, 1, 1, 0, 0
}
}, {
face = "back",
face = "right",
tex = 6,
points = {
0, 0, 0, 1, 1,

View File

@ -9,7 +9,7 @@ local amp = 0.1
zepha.register_blockmodel("base:block_foliage", {
parts = {
{
face = "left",
face = "back",
tex = 3,
points = {
0, 0, 0, 0, 1,
@ -18,7 +18,7 @@ zepha.register_blockmodel("base:block_foliage", {
0, 1, 0, 0, 0
}
}, {
face = "right",
face = "front",
tex = 3,
points = {
1, 1, 1, 0, 0,
@ -45,7 +45,7 @@ zepha.register_blockmodel("base:block_foliage", {
0, 0, 1, 0, 1
}
}, {
face = "front",
face = "left",
tex = 3,
points = {
0, 0, 1, 0, 1,
@ -54,7 +54,7 @@ zepha.register_blockmodel("base:block_foliage", {
0, 1, 1, 0, 0
}
}, {
face = "back",
face = "right",
tex = 3,
points = {
0, 0, 0, 1, 1,
@ -64,7 +64,7 @@ zepha.register_blockmodel("base:block_foliage", {
}
}, {
--Floats begin here
face = "front",
face = "left",
tex = 4,
points = {
0, 1, 1, 0, 0,
@ -77,7 +77,7 @@ zepha.register_blockmodel("base:block_foliage", {
amplitude = amp
}
}, {
face = "back",
face = "right",
tex = 4,
points = {
1.005, 0.2, -0.2, 0, 1,
@ -90,7 +90,7 @@ zepha.register_blockmodel("base:block_foliage", {
amplitude = amp
}
}, {
face = "right",
face = "front",
tex = 4,
points = {
1.2, 0.2, 1.005, 0, 1,
@ -103,7 +103,7 @@ zepha.register_blockmodel("base:block_foliage", {
amplitude = amp
}
}, {
face = "left",
face = "back",
tex = 4,
points = {
0, 1, 0, 0, 0,

View File

@ -6,7 +6,7 @@
zepha.register_blockmodel("base:block_slab", {
parts = {
{
face = "left",
face = "back",
tex = 3,
points = {
0, 0, 0, 0, 0.5,
@ -15,7 +15,7 @@ zepha.register_blockmodel("base:block_slab", {
0, 0.5, 0, 0, 0
}
}, {
face = "right",
face = "front",
tex = 4,
points = {
1, 0.5, 1, 0, 0,
@ -42,7 +42,7 @@ zepha.register_blockmodel("base:block_slab", {
0, 0, 1, 0, 1
}
}, {
face = "front",
face = "left",
tex = 5,
points = {
0, 0, 1, 0, 0.5,
@ -51,7 +51,7 @@ zepha.register_blockmodel("base:block_slab", {
0, 0.5, 1, 0, 0
}
}, {
face = "back",
face = "right",
tex = 6,
points = {
0, 0, 0, 1, 0.5,

View File

@ -6,7 +6,7 @@
zepha.register_blockmodel("base:block_slab_foliage", {
parts = {
{
face = "left",
face = "back",
tex = 3,
points = {
0, 0, 0, 0, 0.5,
@ -15,7 +15,7 @@ zepha.register_blockmodel("base:block_slab_foliage", {
0, 0.5, 0, 0, 0
}
}, {
face = "right",
face = "front",
tex = 4,
points = {
1, 0.5, 1, 0, 0,
@ -42,7 +42,7 @@ zepha.register_blockmodel("base:block_slab_foliage", {
0, 0, 1, 0, 1
}
}, {
face = "front",
face = "left",
tex = 5,
points = {
0, 0, 1, 0, 0.5,
@ -51,7 +51,7 @@ zepha.register_blockmodel("base:block_slab_foliage", {
0, 0.5, 1, 0, 0
}
}, {
face = "back",
face = "right",
tex = 6,
points = {
0, 0, 0, 1, 0.5,
@ -61,7 +61,7 @@ zepha.register_blockmodel("base:block_slab_foliage", {
}
}, {
--Floats begin here
face = "front",
face = "left",
tex = 7,
points = {
0, 0.5, 1, 0, 0,
@ -70,7 +70,7 @@ zepha.register_blockmodel("base:block_slab_foliage", {
1, 0.5, 1, 1, 0
}
}, {
face = "back",
face = "right",
tex = 7,
points = {
1, -0.3, -0.2, 0, 1,
@ -79,7 +79,7 @@ zepha.register_blockmodel("base:block_slab_foliage", {
1, 0.5, 0, 0, 0
}
}, {
face = "right",
face = "front",
tex = 7,
points = {
1.2, -0.3, 1, 0, 1,

View File

@ -9,7 +9,7 @@ local amp = 0.2
zepha.register_blockmodel("base:leaf_like", {
parts = {
{
face = "left",
face = "back",
tex = 1,
points = {
0, 0, 0, 0, 1,
@ -22,7 +22,7 @@ zepha.register_blockmodel("base:leaf_like", {
amplitude = amp
}
}, {
face = "right",
face = "front",
tex = 1,
points = {
1, 1, 1, 0, 0,
@ -61,7 +61,7 @@ zepha.register_blockmodel("base:leaf_like", {
amplitude = amp
}
}, {
face = "front",
face = "left",
tex = 1,
points = {
0, 0, 1, 0, 1,
@ -74,7 +74,7 @@ zepha.register_blockmodel("base:leaf_like", {
amplitude = amp
}
}, {
face = "back",
face = "right",
tex = 1,
points = {
0, 0, 0, 1, 1,

View File

@ -6,7 +6,7 @@
zepha.register_blockmodel("base:pillar", {
parts = {
{
face = "left",
face = "back",
tex = 3,
points = {
0, 0, 4/16, 0, 1,
@ -15,7 +15,7 @@ zepha.register_blockmodel("base:pillar", {
0, 1, 4/16, 0, 0
}
}, {
face = "right",
face = "front",
tex = 3,
points = {
1, 1, 12/16, 0, 0,
@ -23,26 +23,46 @@ zepha.register_blockmodel("base:pillar", {
1, 0, 4/16, 8/16, 1,
1, 1, 4/16, 8/16, 0
}
-- }, {
-- face = "top",
-- tex = 1,
-- points = {
-- 0, 1, 0, 0, 0,
-- 0, 1, 1, 0, 1,
-- 1, 1, 1, 1, 1,
-- 1, 1, 0, 1, 0
-- }
-- }, {
-- face = "bottom",
-- tex = 2,
-- points = {
-- 0, 0, 0, 0, 0,
-- 1, 0, 0, 1, 0,
-- 1, 0, 1, 1, 1,
-- 0, 0, 1, 0, 1
-- }
}, {
face = "front",
face = "top",
tex = 1,
points = {
4/16, 1, 0, 4/16, 0,
4/16, 1, 1, 4/16, 1,
12/16, 1, 1, 12/16, 1,
12/16, 1, 0, 12/16, 0,
0, 1, 4/16, 0, 4/16,
0, 1, 12/16, 0, 12/16,
4/16, 1, 1, 4/16, 1,
4/16, 1, 0, 4/16, 0,
12/16, 1, 0, 12/16, 0,
12/16, 1, 1, 12/16, 1,
1, 1, 12/16, 1, 12/16,
1, 1, 4/16, 1, 4/16
}
}, {
face = "bottom",
tex = 2,
points = {
4/16, 0, 0, 4/16, 0,
12/16, 0, 0, 12/16, 0,
12/16, 0, 1, 12/16, 1,
4/16, 0, 1, 4/16, 1,
0, 0, 4/16, 0, 4/16,
4/16, 0, 0, 4/16, 0,
4/16, 0, 1, 4/16, 1,
0, 0, 12/16, 0, 12/16,
12/16, 0, 0, 12/16, 0,
1, 0, 4/16, 1, 4/16,
1, 0, 12/16, 1, 12/16,
12/16, 0, 1, 12/16, 1
}
}, {
face = "left",
tex = 3,
points = {
4/16, 0, 1, 0, 1,
@ -51,7 +71,7 @@ zepha.register_blockmodel("base:pillar", {
4/16, 1, 1, 0, 0
}
}, {
face = "back",
face = "right",
tex = 3,
points = {
4/16, 0, 0, 8/16, 1,
@ -67,33 +87,18 @@ zepha.register_blockmodel("base:pillar", {
0, 0, 4/16, 10/16, 0,
0, 1, 4/16, 10/16, 1,
4/16, 1, 0, 1, 1,
4/16, 0, 0, 1, 0
}
},
{
face = "nocull",
tex = 3,
points = {
4/16, 0, 0, 1, 0,
12/16, 0, 0, 1, 0,
12/16, 1, 0, 1, 1,
1, 1, 4/16, 10/16, 1,
1, 0, 4/16, 10/16, 0
}
},
{
face = "nocull",
tex = 3,
points = {
1, 0, 4/16, 10/16, 0,
4/16, 0, 1, 1, 0,
4/16, 1, 1, 1, 1,
0, 1, 12/16, 10/16, 1,
0, 0, 12/16, 10/16, 0
}
},
{
face = "nocull",
tex = 3,
points = {
0, 0, 12/16, 10/16, 0,
1, 0, 12/16, 10/16, 0,
1, 1, 12/16, 10/16, 1,
12/16, 1, 1, 1, 1,

View File

@ -33,17 +33,17 @@ class SelectionBox {
const float THRESH = 0.02f;
if (std::abs(vec.y - b.y) < THRESH && vec.x > a.x && vec.x < b.x && vec.z > a.z && vec.z < b.z)
return EVec::TOP;
return EVec::YPOS;
if (std::abs(vec.y - a.y) < THRESH && vec.x > a.x && vec.x < b.x && vec.z > a.z && vec.z < b.z)
return EVec::BOTTOM;
return EVec::YNEG;
if (std::abs(vec.z - a.z) < THRESH && vec.x > a.x && vec.x < b.x && vec.y > a.y && vec.y < b.y)
return EVec::FRONT;
return EVec::ZNEG;
if (std::abs(vec.z - b.z) < THRESH && vec.x > a.x && vec.x < b.x && vec.y > a.y && vec.y < b.y)
return EVec::BACK;
return EVec::ZPOS;
if (std::abs(vec.x - b.x) < THRESH && vec.z > a.z && vec.z < b.z && vec.y > a.y && vec.y < b.y)
return EVec::RIGHT;
return EVec::XPOS;
if (std::abs(vec.x - a.x) < THRESH && vec.z > a.z && vec.z < b.z && vec.y > a.y && vec.y < b.y)
return EVec::LEFT;
return EVec::XNEG;
return EVec::NONE;
}
@ -52,6 +52,6 @@ class SelectionBox {
return Vec::TO_VEC[static_cast<unsigned short>(f)];
}
glm::vec3 a{}, b{ 1, 1, 1 };
glm::vec3 a {}, b { 1, 1, 1 };
};

View File

@ -13,7 +13,7 @@
#include "util/Space.h"
enum class EVec {
LEFT = 0, RIGHT = 1, BOTTOM = 2, TOP = 3, BACK = 4, FRONT = 5,
BACK = 0, FRONT = 1, BOTTOM = 2, TOP = 3, RIGHT = 4, LEFT = 5,
XNEG = 0, XPOS = 1, YNEG = 2, YPOS = 3, ZNEG = 4, ZPOS = 5,
INVALID = -1, NONE = -1,

View File

@ -245,7 +245,7 @@ void LocalDimension::serverEntitiesInfo(Deserializer& e) {
}
case NetField::POS: {
activeEntity->setPos(d.read<vec3>());
activeEntity->interpPos(d.read<vec3>());
break;
}
@ -260,12 +260,12 @@ void LocalDimension::serverEntitiesInfo(Deserializer& e) {
}
case NetField::SCALE: {
activeEntity->setScale(d.read<vec3>());
activeEntity->interpScale(d.read<vec3>());
break;
}
case NetField::VISUAL_OFF: {
activeEntity->setVisualOffset(d.read<vec3>());
activeEntity->interpVisualOffset(d.read<vec3>());
break;
}

View File

@ -29,7 +29,7 @@ void DrawableEntity::setModel(std::shared_ptr<Model> model) {
void DrawableEntity::update(double delta) {
Entity::update(delta);
float factor = static_cast<float>(fmin(delta * 8, 1));
float factor = static_cast<float>(fmin(delta * 15, 1));
visualPosition = visualPosition * (1 - factor) + pos * factor;
visualVisualOffset = visualVisualOffset * (1 - factor) + visualOff * factor;

View File

@ -15,13 +15,13 @@ LocalLuaEntity::LocalLuaEntity(SubgamePtr game, DimensionPtr dim) :
void LocalLuaEntity::setScale(f32 newScale) {
if (appearance == "wireframe") model->fromMesh(
WireframeEntity::createMesh({ {}, vec3(newScale) }, 0.035, wfStroke, wfFill));
else DrawableEntity::setScale(scale);
else DrawableEntity::setScale(newScale);
}
void LocalLuaEntity::setScale(vec3 newScale) {
if (appearance == "wireframe") model->fromMesh(
WireframeEntity::createMesh({ {}, newScale }, 0.035, wfStroke, wfFill));
else DrawableEntity::setScale(scale);
else DrawableEntity::setScale(newScale);
}
void LocalLuaEntity::setAppearance(const string& mode, const string& argA, const string& argB) {

View File

@ -113,8 +113,7 @@ void MapGen::generateVoronoi(const std::unordered_set<u16>& biomes) {
auto& biome = game.getBiomes().biomeFromId(biomeInd);
points.emplace_back(vec3 {
static_cast<u16>(std::fmin(voronoiSize - 1,
std::fmax(0, (biome.temperature + 1) / 2 * voronoiSize))),
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, (biome.temperature + 1) / 2 * voronoiSize))),
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, biome.humidity * voronoiSize))),
static_cast<u16>(std::fmin(voronoiSize - 1, std::fmax(0, biome.roughness * voronoiSize)))
}, biomeInd);

View File

@ -55,7 +55,7 @@ public:
Job(ivec3 pos, u16 size) :
pos(pos), size(size),
volume(u16vec3(size * 16), 4),
volume(u16vec3(size * 16, (size + 1) * 16, size * 16), 4),
heightmap(u16vec2(size * 16), 4),
temperature(u16vec2(size * 16), 4),

View File

@ -38,15 +38,20 @@ LocalPlayer::LocalPlayer(SubgamePtr game, LocalWorld& world, DimensionPtr dim, R
}}}
});
debug->setProp(Gui::Prop::VISIBLE, false);
// debug->setProp(Gui::Prop::VISIBLE, false);
indicators->append<Gui::BoxElement>();
callbacks.emplace_back(renderer.window.input.events.bind(Input::CBType::MOUSE_PRESS, [&](u32 button, i32) {
if (button == GLFW_MOUSE_BUTTON_LEFT) mouseLeftClicked = true;
else if (button == GLFW_MOUSE_BUTTON_RIGHT) mouseRightClicked = true;
}));
}
void LocalPlayer::update(f64 delta, vec2 mouseDelta) {
root.update();
// handItemModel.setVisible(gameGui.isVisible());
updatePhysics(delta, mouseDelta);
vec3 newPos, newVel;
@ -60,6 +65,8 @@ void LocalPlayer::update(f64 delta, vec2 mouseDelta) {
updateWireframe();
if (!isInMenu()) updateInteract(delta);
mouseLeftClicked = false;
mouseRightClicked = false;
}
string LocalPlayer::getUsername() {
@ -362,29 +369,29 @@ void LocalPlayer::updateCamera() {
}
void LocalPlayer::updateWireframe() {
// if (gameGui.isVisible() && target.type != Target::Type::NOTHING) {
// std::vector<SelectionBox> boxes {};
// vec3 thicknessOffset {};
// vec3 renderPos {};
//
// if (target.type == Target::Type::BLOCK) {
// boxes = game->getDefs().blockFromId(dim->getBlock(target.data.block.pos)).sBoxes;
// renderPos = target.data.block.pos;
// thicknessOffset = vec3(0.5);
// }
// else {
// const auto& entity = **dim.l()->getEntityById(target.data.entity.id).entity;
// boxes.push_back(*entity.getCollisionBox());
// renderPos = entity.getPos();
// }
//
// float distance = glm::distance(pos, renderPos + thicknessOffset);
//
// wireframe.updateMesh(boxes, 0.002f + distance * 0.0014f);
// wireframe.setPos(renderPos);
// wireframe.setVisible(true);
// }
// else wireframe.setVisible(false);
if (target.type != Target::Type::NOTHING) {
std::vector<SelectionBox> boxes {};
vec3 thicknessOffset {};
vec3 renderPos {};
if (target.type == Target::Type::BLOCK) {
boxes = game->getDefs().blockFromId(dim->getBlock(target.data.block.pos)).sBoxes;
renderPos = target.data.block.pos;
thicknessOffset = vec3(0.5);
}
else {
const auto& entity = **dim.l()->getEntityById(target.data.entity.id).entity;
boxes.push_back(*entity.getCollisionBox());
renderPos = entity.getPos();
}
float distance = glm::distance(pos, renderPos + thicknessOffset);
wireframe.updateMesh(boxes, 0.002f + distance * 0.0014f);
wireframe.setPos(renderPos);
wireframe.setVisible(true);
}
else wireframe.setVisible(false);
}
void LocalPlayer::updateWieldAndHandItems() {
@ -463,7 +470,7 @@ void LocalPlayer::updateInteract(f64 delta) {
breakTime += delta;
}
}
else if (renderer.window.input.isMouseDown(GLFW_MOUSE_BUTTON_RIGHT)) {
else if (mouseRightClicked) {
if (target.type == Target::Type::BLOCK) {
auto& wieldItem = game->getDefs().fromId(this->wieldItem);
auto& targetedBlock = game->getDefs().blockFromId(dim->getBlock(target.data.block.pos));

View File

@ -139,6 +139,8 @@ private:
/** The interval at which the currently wielded tool can hit. */
f64 breakInterval = 0;
bool mouseLeftClicked = false, mouseRightClicked = false;
/** The targeted wireframe entity. */
WireframeEntity wireframe;
@ -147,5 +149,7 @@ private:
/** The actual wield-item model, set to the currently held item. */
DrawableEntity handItemModel;
vec<CallbackRef> callbacks;
};

View File

@ -4,8 +4,8 @@ zepha.register_block(":leaves", {
culls = false,
model = "base:leaf_like",
textures = {
"tint(0, zeus:default:leaves)",
"tint(0, zeus:default:leaves_puff)"
"zeus:default:leaves",
"zeus:default:leaves_puff"
},
lowdef_textures = {
"tint(0, zeus:default:leaves_opaque)",

View File

@ -3,8 +3,8 @@ zepha.register_block(":wood", {
model = "base:pillar",
textures = {
"zeus:default:oak_log_top",
"zeus:default:oak_log_top",
"zeus:default:oak_log_top_pillar",
"zeus:default:oak_log_top_pillar",
"zeus:default:oak_log_side_pillar"
},
culls = false,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 624 B

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 413 B

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 B

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -200,7 +200,7 @@ zepha.register_biome(identifier, {
},
tags = { natural = 1, default = 1 },
structures = structures,
biome_tint = "#6effee",
biome_tint = "#46cfc0",
noise = noise
})