N-GONE plugin thread

Smart people ~ Great Scripts
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

N-GONE plugin thread

Post by froo »

Ok I don't know what to call it; maybe we can have a contest.

So here's the deal.
The OBJ Exporter already has to get the number of vertices in a face, using
edge neighbors I think. So, the 'hard part' of this plugin-to-be-developed is already done.

Maybe an even harder part is naming it. :D Well, not really. That's the fun part.
What do you think? I think "Dick Tracy" sounds pretty cool but no one will know
what it's for.
User avatar
Steinie
Captain
Posts: 2958
Joined: 21 May 2009, 17:38
Type the number ten into the box: 10

Re: NGON Hunter plugin thread

Post by Steinie »

1) N-Gone
2) Your_Face_Is_A_Disgrace
3) N-Gon_Fishin
4) Poly-Gone
5) Poly-Splitters
6) >4 NoMore
7) N-Gon-B-Gon
8) Myriagon Minus 9996
User avatar
MikomDude
Captain
Posts: 1930
Joined: 04 Oct 2010, 11:12
Type the number ten into the box: 0
Location: The Hague, Netherlands

Re: NGON Hunter plugin thread

Post by MikomDude »

:D Brilliant names Steinie. Nr 1 and 2 are my favorites.
jamesmc
Captain
Posts: 1776
Joined: 08 Jul 2009, 15:35

Re: NGON Hunter plugin thread

Post by jamesmc »

N-GONE is my favorite. :)

I don't think I can upload flash, if not will upload GIF. :(
Attachments
froosNGONE.gif
froosNGONE.gif (10.33 KiB) Viewed 749 times
Walk by faith, not by sight.
pugman 1
Captain
Posts: 1555
Joined: 21 May 2009, 19:26
Type the number ten into the box: 0
Location: Germany

Re: NGON Hunter plugin thread

Post by pugman 1 »

cool stuff here . way to go :bananathumb:
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: NGON Hunter plugin thread

Post by froo »

I spoke with Tomas today. I asked him if the Quadrify script command (and the quadrify tool)
would combine two adjacent triangle-faces into a single quad-face. He said the tool would not do that.
So, I am thinking, I could try to do that. But, my question is this.
If the triangles do not lie in the same plane (like two triangles on one face of a basic cube),
will that cause problems when exported?
For example, if one triangle was picked from one side of a cube, and the other triangle was picked
from another side of the cube.
Would that cause a problem?

One thing I may be able to do is, for one triangle (triangle A), find all its neighbors, and pick the triangle whose 'angle'
is closest to that of triangle A.
For example, the cube again. It makes more sense to combine two triangles that make up a flat side (a face),
than it does to take one triangle from each of two faces.
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: NGON Hunter plugin thread

Post by froo »

I took another look at trueBlue's steps. I got the quadrify tool to work.
So I have a question.
For this plugin, do you only want to highlight the nGons on a mesh, so you can
select those, and quadrify them? Or do you want the plugin to do more than that?

I also have a question about triangles. What do you want to do with them? A couple
things could be done:
1) find a neighboring triangle, and combine the two into a single face, similar to the Merge Polygons tool.
2) quadrify the triangles.

What will usually happen, if we use (1) is, we will end up with single triangles, who do not have a triangle-face
neighbor. So those would have to be quadrified using (2).
But the problem becomes the edge flow, as jamesmc discussed in another thread. When we quadrify a triangle,
we end up with a vertex in the middle of the triangle.
User avatar
Steinie
Captain
Posts: 2958
Joined: 21 May 2009, 17:38
Type the number ten into the box: 10

Re: NGON Hunter plugin thread

Post by Steinie »

I personally wanted a tool that would highlight all the NGons > 4 so that I can correct them.
It might be by merging two vertexes or adding an edge depending on where it is on the model.
The tools are very good in trueSpace and easy to use so a N-Gone tool that can help the user find bad
geometry would be fantastic. If it can do more with options that would make it even better but not necessary
for my needs.
User avatar
clintonman
Captain
Posts: 5659
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California

Re: NGON Hunter plugin thread

Post by clintonman »

If this helps the Object information script half way down this page
http://www.clintons3d.com/plugins/trues ... index.html"
has buttons for selecting 3 sided, 4 sided and more than 4 sided polygons. It is written in jscript, maybe some of it will translate to c++ plugin.
Clinton Reese

http://clintons3d.com
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: NGON Hunter plugin thread

Post by froo »

Hey Clinton.
Thanks for that! :worship:
Yeah this will help.

Steinie, ok. I did do what trueBlue did, and I got it to work:
To see it work, I went into Object mode, and increased the
visibility of triangle edges. Then, I selected a face with more than 4 vertices,
then selected the Quadrify tool. When I did this, I saw an edge get added.

Basically I can harvest code from the OBJ exporter (to get the faces),
he nurbs tool (maybe), and clinton's package (to get the mesh, for counting
triangles/faces.
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: NGON Hunter plugin thread

Post by froo »

Well N-GONE is definitely more cool than

Poly Analyzer.

That is such a nerdy name!

Ok; So N-GONE it is!
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: NGON Hunter plugin thread

Post by froo »

Ok so I stripped out everything I don't need, from the OBJ Exporter.
I need to remove the OBJ Importer part as well since that's not needed.
But that code is not even touched in the exporter code anyway, so I
can leave it alone for now.

Next up is getting the visualization code from the nurbs tool.
Now that part may get a little tricky since I had trouble with
the triangle visualization stream (in edit mode) before.
I would say, for the first run at this, I won't worry about
highlighting ngons in edit mode. The first challenge will be
to highlight the desired ngons while not in edit mode.
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: N-GONE plugin thread

Post by froo »

So, this is where I'm at.
I am trying to update the mesh connector, from a trueSpace command.
This is different from updating the mesh connector from the node itself.
It should be possible, but I have not done it before. It may require a
considerable amount of work/effort, in which case, it may not be worth
that effort. I'll see if I can get it going. If not, as trueBlue said,
the quadrify tool does work.

Another thing I can do is, see if there is a way to force truespace to NOT
generate ngons when I hand it the triangle stream, during obj import.
Though, that does not help the situation where editing is done in trueSpace.
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: N-GONE plugin thread

Post by froo »

I took a look at the file that Norm created, the arena ring demo. It just turns the edge and
vertex opacity on and off. So it does not deal with enabling the visualization streams.
I also could not seem to modify the vertex stream: I tried moving a vertex out, and putting
the mesh back onto the connector, in C++. No go. So I found my flag script that I made
some time ago, with the help of Dele - he wrote some scripts which modified vertex positions.
I may end up trying to do this in script. It may be easier; we'll see. I am not sure. I will have
to port the C++ code to jscript if I do that, I think. I've been wanting to do some script code anyway. Arighty clinton. :D I may need a hand!
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: N-GONE plugin thread

Post by froo »

Long story short:
We may be able to use Clinton's script to identify the face indexes whose triangle count is > 4; I think it does that now. For those, we can paint them a different color/texture/material. I can use the jscript macro record button to record my actions as I paint a face on an object, and put that into clinton's code. Worth a shot.
User avatar
Steinie
Captain
Posts: 2958
Joined: 21 May 2009, 17:38
Type the number ten into the box: 10

Re: N-GONE plugin thread

Post by Steinie »

Looks promising!
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: N-GONE plugin thread

Post by froo »

Man I hope so. 8-)
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: N-GONE plugin thread

Post by froo »

Well I ran the jscript macro.
Naturally, there's no script command available (according to the comments in the macro)
for the 'Paint The Face with This texture/material' command.

So, I'll have to think of something else.
Thing is, I see in the RsExamples plugin, where the node is accessed, and connectors
are modified, from a command. That is what I am doing. So, I guess I will run those and
see if they actually work.

I can also try making the object into an editable shape (if it is not already), and
set the visualization stream items (triangles), maybe.

I got the flag script example that I made before. I will study it. I was able to affect the mesh with it,
making a 'waving flag'.
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: N-GONE plugin thread

Post by froo »

Here's another thing.
The OBJ Exporter *should* be sorting the triangles by material index. So, it is 'getting' the triangles
according to material index. I want to 'Set' the material for specific triangle indexes.
So, maybe I can reuse more of that code. Hm. Lookin at this from every angle I can.

Another possibility:
If Clinton's code identifies triangle indexes or vertex indexes that are part of an Ngon,
I could use that; if there was only a way to paint a face with a color (vertex colors?) in script.
Not the whole stream; just those ones.
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: N-GONE plugin thread

Post by froo »

Does anyone know of a currently existing script that selects a face and attaches a bitmap/texture to it?
I doubt it, but it's worth a shot.
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: N-GONE plugin thread

Post by froo »

Here's another approach, though, it's not pretty. But it will work.
With clinton's script, I did some testing, and where it identifies
a ngon, I get the coordinates of one of the vertices that is part of that
face. Then, I can add a sphere, or cube, the size of that face, at that vertex location.
A slight improvement would be to average the vertex coordinates and put an object there.
Yeah it's not pretty but you could then use the LE, to select the new objects, and go to them.
Delete them, and you see the ngon.

Hey, it's a start.
froo
Captain
Posts: 2554
Joined: 22 May 2009, 12:13

Re: N-GONE plugin thread

Post by froo »

Hm. While that can be done it's not a very good idea, because if there are
1000 ngons then we'll have 1000 new items in the scene and the LE.
That's the long and short of it.

Visualization streams are not available unless we're in edit mode. And,
in edit mode, many folks prefer to keep AutoTriangulation enabled. In
that case, the triangle and vertex streams are sorted. I'd have to get
the visualization streams unsorted before setting them: turning triangle highlighting
on and off. I had problems with that before. That would need to be resolved
before going any further with this approach.

Not using edit mode, I'd need to create a material list / material manager node,
and paint all triangles belonging to an ngon with a texture. For some reason
I really don't find this solution very appealing.

It looks like the best solution would be to enter edit mode and mess with the visualization streams. Solving this dilemna would apply to many plugins.

In any of the cases above, the user will enter edit mode to fix the ngons. Most of the time
they will end up fixing all of the ngons. If, after doing this, some vertices look out of place,
then the user will end up doing some point editing.

Therefore, we may as well use the quadrify tool available with trueSpace.
So, I don't think I will be pursuing this particular plugin anymore as it's not necessary,
since we already have a quadrify tool.

But, I would like to work with the autotriangulate issue.

Return to “Scripts and SDK”