[DEV] better mesh display and other
This commit is contained in:
parent
8aa072783d
commit
2b946f19d0
@ -46,60 +46,6 @@ class ImportEMF(bpy.types.Operator, ImportHelper):
|
||||
options={'HIDDEN'},
|
||||
)
|
||||
|
||||
use_ngons = BoolProperty(
|
||||
name="NGons",
|
||||
description="Import faces with more than 4 verts as ngons",
|
||||
default=True,
|
||||
)
|
||||
use_edges = BoolProperty(
|
||||
name="Lines",
|
||||
description="Import lines and faces with 2 verts as edge",
|
||||
default=True,
|
||||
)
|
||||
use_smooth_groups = BoolProperty(
|
||||
name="Smooth Groups",
|
||||
description="Surround smooth groups by sharp edges",
|
||||
default=True,
|
||||
)
|
||||
|
||||
use_split_objects = BoolProperty(
|
||||
name="Object",
|
||||
description="Import EMF Objects into Blender Objects",
|
||||
default=True,
|
||||
)
|
||||
use_split_groups = BoolProperty(
|
||||
name="Group",
|
||||
description="Import EMF Groups into Blender Objects",
|
||||
default=True,
|
||||
)
|
||||
|
||||
use_groups_as_vgroups = BoolProperty(
|
||||
name="Poly Groups",
|
||||
description="Import EMF groups as vertex groups",
|
||||
default=False,
|
||||
)
|
||||
|
||||
use_image_search = BoolProperty(
|
||||
name="Image Search",
|
||||
description="Search subdirs for any associated images "
|
||||
"(Warning, may be slow)",
|
||||
default=True,
|
||||
)
|
||||
|
||||
split_mode = EnumProperty(
|
||||
name="Split",
|
||||
items=(('ON', "Split", "Split geometry, omits unused verts"),
|
||||
('OFF', "Keep Vert Order", "Keep vertex order from file"),
|
||||
),
|
||||
)
|
||||
|
||||
global_clamp_size = FloatProperty(
|
||||
name="Clamp Size",
|
||||
description="Clamp bounds under this value (zero to disable)",
|
||||
min=0.0, max=1000.0,
|
||||
soft_min=0.0, soft_max=1000.0,
|
||||
default=0.0,
|
||||
)
|
||||
axis_forward = EnumProperty(
|
||||
name="Forward",
|
||||
items=(('X', "X Forward", ""),
|
||||
@ -128,12 +74,6 @@ class ImportEMF(bpy.types.Operator, ImportHelper):
|
||||
# print("Selected: " + context.active_object.name)
|
||||
from . import import_obj
|
||||
|
||||
if self.split_mode == 'OFF':
|
||||
self.use_split_objects = False
|
||||
self.use_split_groups = False
|
||||
else:
|
||||
self.use_groups_as_vgroups = False
|
||||
|
||||
keywords = self.as_keywords(ignore=("axis_forward",
|
||||
"axis_up",
|
||||
"filter_glob",
|
||||
@ -152,18 +92,6 @@ class ImportEMF(bpy.types.Operator, ImportHelper):
|
||||
|
||||
row = layout.row(align=True)
|
||||
|
||||
box = layout.box()
|
||||
row = box.row()
|
||||
row.prop(self, "split_mode", expand=True)
|
||||
|
||||
row = box.row()
|
||||
if self.split_mode == 'ON':
|
||||
row.label(text="Split by:")
|
||||
row.prop(self, "use_split_objects")
|
||||
row.prop(self, "use_split_groups")
|
||||
else:
|
||||
row.prop(self, "use_groups_as_vgroups")
|
||||
|
||||
row = layout.split(percentage=0.67)
|
||||
row.prop(self, "global_clamp_size")
|
||||
layout.prop(self, "axis_forward")
|
||||
|
@ -161,7 +161,7 @@ def mesh_triangulate(me):
|
||||
import bmesh
|
||||
bm = bmesh.new()
|
||||
bm.from_mesh(me)
|
||||
bmesh.ops.triangulate(bm, faces=bm.faces)
|
||||
bmesh.ops.triangulate(bm, faces=bm.faces)#, use_beauty=False)
|
||||
bm.to_mesh(me)
|
||||
bm.free()
|
||||
|
||||
@ -364,9 +364,13 @@ def write_file(filepath,
|
||||
idMesh = idMesh+1;
|
||||
fw('Mesh : %d\n' % idMesh)
|
||||
me.transform(EXPORT_GLOBAL_MATRIX * ob_mat)
|
||||
#print("ploppp : " + str(EXPORT_GLOBAL_MATRIX) )
|
||||
#print("ploppp : " + str(ob_mat) )
|
||||
# _must_ do this first since it re-allocs arrays
|
||||
# triangulate all the mesh :
|
||||
mesh_triangulate(me)
|
||||
# calculated normals:
|
||||
me.calc_normals()
|
||||
# export UV mapping :
|
||||
faceuv = len(me.uv_textures) > 0
|
||||
if faceuv:
|
||||
@ -381,8 +385,7 @@ def write_file(filepath,
|
||||
# clean up
|
||||
bpy.data.meshes.remove(me)
|
||||
continue # dont bother with this mesh.
|
||||
# calculated normals:
|
||||
me.calc_normals()
|
||||
|
||||
materials = me.materials[:]
|
||||
material_names = [m.name if m else None for m in materials]
|
||||
# avoid bad index errors
|
||||
|
2
external/ege
vendored
2
external/ege
vendored
@ -1 +1 @@
|
||||
Subproject commit 327367b1a73be036a447c1f0b5e43f3af43ca0c2
|
||||
Subproject commit c741f6e1c8fe23e68a56937ecea08d6972fa3fd3
|
2
external/ejson
vendored
2
external/ejson
vendored
@ -1 +1 @@
|
||||
Subproject commit 2627da57d8555bd69facc1cff923ab0b8d498893
|
||||
Subproject commit 3c102ab263a93b410c3e0cd118bb8d2bc67e0b28
|
@ -23,7 +23,7 @@ ewol::Mesh::Mesh(const etk::UString& _fileName, const etk::UString& _shaderName)
|
||||
// get the shader resource :
|
||||
m_GLPosition = 0;
|
||||
|
||||
m_light.SetDirection(vec3(0,cos(M_PI/4),sin(M_PI/4)));
|
||||
m_light.SetDirection(vec3(0,-cos(M_PI/4),0));
|
||||
m_light.SetHalfPlane(vec3(1,0,0));
|
||||
m_light.SetAmbientColor(vec4(1,1,1,1));
|
||||
m_light.SetDiffuseColor(vec4(1.0,1.0,1.0,1));
|
||||
@ -70,7 +70,7 @@ ewol::Mesh::~Mesh(void)
|
||||
ewol::resource::Release(m_verticesVBO);
|
||||
}
|
||||
|
||||
#define DISPLAY_NB_VERTEX_DISPLAYED
|
||||
//#define DISPLAY_NB_VERTEX_DISPLAYED
|
||||
|
||||
void ewol::Mesh::Draw(mat4& positionMatrix)
|
||||
{
|
||||
@ -151,59 +151,13 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
|
||||
}
|
||||
}
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
EWOL_DEBUG("Request Draw : " << m_listFaces.Size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]");
|
||||
EWOL_DEBUG(((float)nbElementDraw/(float)nbElementDrawTheoric*100.0f) << "% Request Draw : " << m_listFaces.Size() << ":" << nbElementDraw << "/" << nbElementDrawTheoric << " elements [" << m_name << "]");
|
||||
#endif
|
||||
m_GLprogram->UnUse();
|
||||
ewol::openGL::Disable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
// TODO : UNDERSTAND why ... it is needed
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||
}
|
||||
void ewol::Mesh::Draw2(mat4& positionMatrix)
|
||||
{
|
||||
if (m_GLprogram==NULL) {
|
||||
EWOL_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
ewol::openGL::Enable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
//EWOL_DEBUG(" Display " << m_coord.Size() << " elements" );
|
||||
m_GLprogram->Use();
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 projMatrix = ewol::openGL::GetMatrix();
|
||||
mat4 tmpMatrix = projMatrix;
|
||||
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
m_GLprogram->UniformMatrix4fv(m_GLMatrixPosition, 1, positionMatrix.m_mat);
|
||||
// position :
|
||||
m_GLprogram->SendAttributePointer(m_GLPosition, 3/*x,y,z*/, m_verticesVBO, MESH_VBO_VERTICES);
|
||||
// Texture :
|
||||
m_GLprogram->SendAttributePointer(m_GLtexture, 2/*u,v*/, m_verticesVBO, MESH_VBO_TEXTURE);
|
||||
// position :
|
||||
m_GLprogram->SendAttributePointer(m_GLNormal, 3/*x,y,z*/, m_verticesVBO, MESH_VBO_VERTICES_NORMAL);
|
||||
m_light.Draw(m_GLprogram);
|
||||
|
||||
// draw materials :
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
int32_t nbElementDraw = 0;
|
||||
#endif
|
||||
for (esize_t kkk=0; kkk<m_listFaces.Size(); kkk++) {
|
||||
if (false == m_materials.Exist(m_listFaces.GetKey(kkk))) {
|
||||
EWOL_WARNING("missing materials : '" << m_listFaces.GetKey(kkk) << "'");
|
||||
continue;
|
||||
}
|
||||
m_materials[m_listFaces.GetKey(kkk)]->Draw(m_GLprogram, m_GLMaterial);
|
||||
ewol::openGL::DrawElements(GL_TRIANGLES, m_listFaces.GetValue(kkk).m_index);
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
nbElementDraw += m_listFaces.GetValue(kkk).m_index.Size();
|
||||
#endif
|
||||
}
|
||||
#ifdef DISPLAY_NB_VERTEX_DISPLAYED
|
||||
EWOL_DEBUG("Request Draw : " << m_listFaces.Size() << ":" << nbElementDraw << " elements [" << m_name << "]");
|
||||
#endif
|
||||
m_GLprogram->UnUse();
|
||||
ewol::openGL::Disable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
// TODO : UNDERSTAND why ... it is needed
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0);
|
||||
}
|
||||
|
||||
|
||||
// normal calculation of the normal face is really easy :
|
||||
void ewol::Mesh::CalculateNormaleFace(void)
|
||||
|
@ -112,7 +112,6 @@ namespace ewol
|
||||
virtual ~Mesh(void);
|
||||
virtual const char* GetType(void) { return "ewol::Mesh"; };
|
||||
virtual void Draw(mat4& positionMatrix);
|
||||
virtual void Draw2(mat4& positionMatrix);
|
||||
void GenerateVBO(void);
|
||||
private:
|
||||
void CalculateNormaleFace(void);
|
||||
|
@ -53,7 +53,7 @@ void widget::Mesh::OnDraw(void)
|
||||
* etk::matRotate(vec3(0,1,0),m_angle.y())
|
||||
* etk::matRotate(vec3(0,0,1),m_angle.z());
|
||||
if (NULL != m_object) {
|
||||
m_object->Draw2(transformationMatrix);
|
||||
m_object->Draw(transformationMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user