Scale mesh to bounds
This commit is contained in:
@@ -131,35 +131,35 @@ class Loader {
|
||||
}
|
||||
|
||||
// Returns true if v1 can be considered equal to v2
|
||||
function isNear(v1:Float, v2:Float):Bool {
|
||||
return Math.abs(v1 - v2) < 0.001;
|
||||
}
|
||||
// function isNear(v1:Float, v2:Float):Bool {
|
||||
// return Math.abs(v1 - v2) < 0.001;
|
||||
// }
|
||||
|
||||
// Searches through all already-exported vertices for a similar one.
|
||||
// Similar = same position + same UVs + same normal
|
||||
function getSimilarVertexIndex(
|
||||
vertexX:Float, vertexY:Float, vertexZ:Float,
|
||||
uvX:Float, uvY:Float,
|
||||
normalX:Float, normalY:Float, normalZ:Float
|
||||
):Bool {
|
||||
// Lame linear search
|
||||
for (i in 0...Std.int(indexedVertices.length / 3)) {
|
||||
if (
|
||||
isNear(vertexX, indexedVertices[i * 3]) &&
|
||||
isNear(vertexY, indexedVertices[i * 3 + 1]) &&
|
||||
isNear(vertexZ, indexedVertices[i * 3 + 2]) &&
|
||||
isNear(uvX , indexedUVs [i * 2]) &&
|
||||
isNear(uvY , indexedUVs [i * 2 + 1]) &&
|
||||
isNear(normalX, indexedNormals [i * 3]) &&
|
||||
isNear(normalY, indexedNormals [i * 3 + 1]) &&
|
||||
isNear(normalZ, indexedNormals [i * 3 + 2])
|
||||
) {
|
||||
index = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// No other vertex could be used instead.
|
||||
// Looks like we'll have to add it to the VBO.
|
||||
return false;
|
||||
}
|
||||
// // Searches through all already-exported vertices for a similar one.
|
||||
// // Similar = same position + same UVs + same normal
|
||||
// function getSimilarVertexIndex(
|
||||
// vertexX:Float, vertexY:Float, vertexZ:Float,
|
||||
// uvX:Float, uvY:Float,
|
||||
// normalX:Float, normalY:Float, normalZ:Float
|
||||
// ):Bool {
|
||||
// // Lame linear search
|
||||
// for (i in 0...Std.int(indexedVertices.length / 3)) {
|
||||
// if (
|
||||
// isNear(vertexX, indexedVertices[i * 3]) &&
|
||||
// isNear(vertexY, indexedVertices[i * 3 + 1]) &&
|
||||
// isNear(vertexZ, indexedVertices[i * 3 + 2]) &&
|
||||
// isNear(uvX , indexedUVs [i * 2]) &&
|
||||
// isNear(uvY , indexedUVs [i * 2 + 1]) &&
|
||||
// isNear(normalX, indexedNormals [i * 3]) &&
|
||||
// isNear(normalY, indexedNormals [i * 3 + 1]) &&
|
||||
// isNear(normalZ, indexedNormals [i * 3 + 2])
|
||||
// ) {
|
||||
// index = i;
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// // No other vertex could be used instead.
|
||||
// // Looks like we'll have to add it to the VBO.
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -36,7 +36,9 @@ class CamBall extends Trait {
|
||||
// Rotate
|
||||
object.transform.rotate(new Vec4(0, 0, 1), mouse.movementX / 100);
|
||||
object.transform.buildMatrix();
|
||||
object.transform.rotate(object.transform.right(), mouse.movementY / 100);
|
||||
var v = object.transform.right();
|
||||
v.normalize();
|
||||
object.transform.rotate(v, mouse.movementY / 100);
|
||||
object.transform.buildMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
+13
-1
@@ -620,7 +620,7 @@ class UITrait extends armory.Trait {
|
||||
if (paintHandle.changed) {
|
||||
UINodes.changed = true;
|
||||
}
|
||||
brushBias = ui.slider(Id.handle({value: brushBias}), "Bias", 0.0, 3.0, true);
|
||||
brushBias = ui.slider(Id.handle({value: brushBias}), "Bias", 0.0, 4.0, true);
|
||||
ui.row([1/2, 1/2]);
|
||||
// ui.combo(Id.handle(), ["Draw", "Fill"], "Type");
|
||||
ui.combo(Id.handle(), ["Draw"], "Type");
|
||||
@@ -793,8 +793,20 @@ class UITrait extends armory.Trait {
|
||||
new MeshData(raw, function(md:MeshData) {
|
||||
currentObject.data.delete();
|
||||
iron.App.notifyOnRender(clearTargetsHandler);
|
||||
|
||||
currentObject.setData(md);
|
||||
|
||||
// Scale to bounds
|
||||
md.geom.calculateAABB();
|
||||
var r = Math.sqrt(md.geom.aabb.x * md.geom.aabb.x + md.geom.aabb.y * md.geom.aabb.y + md.geom.aabb.z * md.geom.aabb.z);
|
||||
if (r > 3) {
|
||||
currentObject.transform.scale.set(3 / r, 3 / r, 3 / r);
|
||||
currentObject.transform.buildMatrix();
|
||||
}
|
||||
|
||||
// Face camera
|
||||
currentObject.transform.setRotation(Math.PI / 2, 0, 0);
|
||||
|
||||
UITrait.dirty = true;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ class RenderPathCreator {
|
||||
|
||||
#if (rp_background == "World")
|
||||
{
|
||||
path.loadShader("shader_datas/world/world");
|
||||
path.loadShader("shader_datas/world_pass/world_pass");
|
||||
}
|
||||
#end
|
||||
|
||||
@@ -150,7 +150,7 @@ class RenderPathCreator {
|
||||
path.drawMeshes("mesh");
|
||||
#if (rp_background == "World")
|
||||
{
|
||||
path.drawSkydome("shader_datas/world/world");
|
||||
path.drawSkydome("shader_datas/world_pass/world_pass");
|
||||
}
|
||||
#end
|
||||
|
||||
@@ -205,7 +205,7 @@ class RenderPathCreator {
|
||||
static function init() {
|
||||
#if (rp_background == "World")
|
||||
{
|
||||
path.loadShader("shader_datas/world/world");
|
||||
path.loadShader("shader_datas/world_pass/world_pass");
|
||||
}
|
||||
#end
|
||||
|
||||
@@ -808,7 +808,7 @@ class RenderPathCreator {
|
||||
|
||||
#if (rp_background == "World")
|
||||
{
|
||||
path.drawSkydome("shader_datas/world/world");
|
||||
path.drawSkydome("shader_datas/world_pass/world_pass");
|
||||
}
|
||||
#end
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user