How to inspect all faces?
-
i want to inspect all faces of a model,and get coordinats of each face,how to do it?is there any demo?example code?
thank u -
Sure, have you coded anything before? Anything in Ruby? Its pretty simple to get the base of what you want, but I'm concerned about what you want to do with it. Just a list of xyz values for every vertex in the model seems rather useless, but perhaps its useful to you? This will get you started.
` model = Sketchup.active_model
ents = model.entities
faces = []
vert_array = []ents.each { |e| faces << e if e.is_a? Sketchup::Face }
faces.each { |e| vert_array << e.vertices.collect { |ff| ff.position } }puts vert_array`
That will not drill down into components or groups, it just skips them I think. But its a start. Do have any better clues what you wouild like to use this for?
-
yes ,i have coded before,but the peogramme is very simple. thanks for your relpy.the reason why i want to do it is that i want to load SKP model in XNA.yes,it can load directly only if transforming the model type into .fbx.however,the model in XNA is triangular mesh,i want to organize the model with face,which can contains triangular meshes. then i can trace the face from eachtriangular mesh. so i can select each face like doing it in sketchup,rather than a triangular mesh in XNA.
i don't whether my representation is clear,and i am very happy to discuss with u.thank u! -
@chris fullmer said:
Sure, have you coded anything before? Anything in Ruby? Its pretty simple to get the base of what you want, but I'm concerned about what you want to do with it. Just a list of xyz values for every vertex in the model seems rather useless, but perhaps its useful to you? This will get you started.
` model = Sketchup.active_model
ents = model.entities
faces = []
vert_array = []ents.each { |e| faces << e if e.is_a? Sketchup::Face }
faces.each { |e| vert_array << e.vertices.collect { |ff| ff.position } }puts vert_array`
That will not drill down into components or groups, it just skips them I think. But its a start. Do have any better clues what you wouild like to use this for?
yes ,i have coded before,but the peogramme is very simple. thanks for your relpy.the reason why i want to do it is that i want to load SKP model in XNA.yes,it can load directly only if transforming the model type into .fbx.however,the model in XNA is triangular mesh,i want to organize the model with face,which can contains triangular meshes. then i can trace the face from eachtriangular mesh. so i can select each face like doing it in sketchup,rather than a triangular mesh in XNA.
i don't whether my representation is clear,and i am very happy to discuss with u.thank u! -
So you want the vertices of each SU face because SU allows non-triangulated faces. And you want to use that data to convert the triangulated faces in XNA into faces more like in SU? Is that more or less the idea? Do you know how to use this data in xna? Can you create a script in xna that takes a series of vertices, finds all faces in xna bounded by those vertices, then turns them all into a single xna face? That seems to be about what your looking for, maybe?
-
@chris fullmer said:
So you want the vertices of each SU face because SU allows non-triangulated faces. And you want to use that data to convert the triangulated faces in XNA into faces more like in SU? Is that more or less the idea? Do you know how to use this data in xna? Can you create a script in xna that takes a series of vertices, finds all faces in xna bounded by those vertices, then turns them all into a single xna face? That seems to be about what your looking for, maybe?
yes,i am trying to realize the idea.we can just draw point,line,triangle in XNA,so we have to draw a series of triangles to represent a polygon or a face.i know how to draw a series of triangle meshes with a series of vertices. any other method to trace the face from each triangle mesh in .x model or .fbx model?
-
You probably want to look into the
PolygonMesh
class as well. if you useface.mesh
- it willl return aPolygonMesh
for that face. ThePolygonMesh
is triangualted.
I got a plugin that let you hover over a face and visually see the PolygonMesh representation of that face: http://forums.sketchucation.com/viewtopic.php?f=323&t=21472
Advertisement