Snap vertices to grid//round off vertex coordinates

Started by Itszutak, June 12, 2015, 12:03:45 AM

Previous topic - Next topic

Itszutak

I'm having a bit of trouble with a map I'm working on, and a feature to round off coordinates of vertices from within 3ds max would be insanely useful. I noticed there's a similar feature already in the map exporter, where it truncates vertex coordinates--but upon loading the map in Hammer I notice it's still far off from something useable. If there was an additional option to round vertices enough that they'd be "on-grid" in Hammer, I'd be saving myself probably...about a month of moving vertices by hand.

Thanks!

wallworm

Well yes, this is a feature in a commercial modifier I wrote here: SnapVertsToGrid Modifier. You can get it on the WW store for $2.95.

Itszutak


wallworm

:)

Take note of the Docs. Instancing the same instance of the modifier on multiple objects isn't currently supported. In other words, if you need it on 10 different objects, apply it separately to the ten nodes.

wallworm

Also, for what it's worth, the plugins CorVex and ShellVex both have native utilities to help you keep everything on the grid. In my own personal view of world geometry... they should be 80-90% CorVex nodes and 5-20% ShellVex nodes... and the remainder a few Box primitives :) That's because those geometry classes work so well for brushes and I made them entirely for making brushes.

Itszutak

#5
Quote from: wallworm on June 12, 2015, 12:56:19 AM
:)

Take note of the Docs. Instancing the same instance of the modifier on multiple objects isn't currently supported. In other words, if you need it on 10 different objects, apply it separately to the ten nodes.
...Oh jeez. This thing's about 1000 different objects...Is there a way to just automate applying the modifier to everything?

I guess I should explain what I'm doing. I've got a model of the cliffs of Blood Gulch, which I've attempted to turn into brushwork using the "shell" modifier and a script that splits the model's elements into individual named objects.

This process turns it into about 1300 objects-- although I may be misunderstanding how wwmt works. Can it handle a single named object that's got a bunch of elements to it?

edit: for a bit of context, here's a screenshot of the "raw" model I'm attempting to turn into brushwork:


Joris Ceoen

Quote from: Itszutak on June 12, 2015, 03:50:21 AM
Quote from: wallworm on June 12, 2015, 12:56:19 AM
:)

Take note of the Docs. Instancing the same instance of the modifier on multiple objects isn't currently supported. In other words, if you need it on 10 different objects, apply it separately to the ten nodes.
...Oh jeez. This thing's about 1000 different objects...Is there a way to just automate applying the modifier to everything?

I guess I should explain what I'm doing. I've got a model of the cliffs of Blood Gulch, which I've attempted to turn into brushwork using the "shell" modifier and a script that splits the model's elements into individual named objects.

This process turns it into about 1300 objects-- although I may be misunderstanding how wwmt works. Can it handle a single named object that's got a bunch of elements to it?
1300 objects may be... problematic. I'm not sure what you're meaning but what definitly is possible is having one object that contains different elements as long as ALL of the elements are convex. An object can be concave, but every element inside that concave object must be convex.

Joris Ceoen

I didn't see the image before I posted (as it didn't load at first). To turn that into brushwork is just incredibly tedious, both for performance and texturing. It would instead be logical to make it with displacements. One method I advise you to attempt is to create planar faces around the model and turn them into displacements through WW Anvil. Then, snap the vertices to the model itself. All additional vertices should be scattered on the planes/triangles of the model.

That's about the only way I can see this working. That, or you simply turn it into a model. With staticproplighting it could turn out just as well. The reason for this method is because displacements can rarely cause lighting problems if they're too wacky (however it only happens with overlapping displacements, which wouldn't happen with the first method I provided). Lemme know if it worked for you!

The smaller rocks on the model should absolutely be turned into a model, as it wouldn't fare well with either brushwork or displacements, at all.

wallworm

#8
Sorry I didn't answer last night as I went to sleep.

Generally, most of what Joris said is valid advice. However, to answer your questions directly:

To apply the snap modifier to many objects at once, you have two options:

1) Select all the objects and run this code in the MAXScript listener (F11)

for obj in selection where superclassof obj == geometryclass do addModifier obj (SnapVertsToGrid())

Hit Enter at the end of the line to execute it.

2) Or, you can select all the objects and collapse them into a single object. There are currently two buttons that can do this in WW tools: 1) Wall Worm > Wall Worm Model Tools > Hull Helper > Merge Selected Hulls and Wall Worm > Wall Worm Level Design > Wall Worm Carver > Combine. Then to make sure this geometry exports as a bunch of brushes, select it and Tag it as Concave Brush.



Now the thing that I'd point out is accomplishing this kind of task is actually one of the features in the ShellVex plugin. With ShellVex installed, you can select a bunch of arbitrary geometry and hit Wall Worm > Wall Worm Level Design > ShellVex: Create Terrain. That will create a ShellVex object where each face of your selected mesh(es) becomes the top of a brush, already sealed and ready to export as a brush--and the snap to grid is actually a property of ShellVex already (so no modifier needed for it).


As recommended above, using displacements is probably a really good idea. However, I did make ShellVex for several tasks--and this is specifically one of them.

Itszutak

Quote from: Joris Ceoen on June 12, 2015, 05:44:44 AM
I didn't see the image before I posted (as it didn't load at first). To turn that into brushwork is just incredibly tedious, both for performance and texturing. It would instead be logical to make it with displacements. One method I advise you to attempt is to create planar faces around the model and turn them into displacements through WW Anvil. Then, snap the vertices to the model itself. All additional vertices should be scattered on the planes/triangles of the model.

That's about the only way I can see this working. That, or you simply turn it into a model. With staticproplighting it could turn out just as well. The reason for this method is because displacements can rarely cause lighting problems if they're too wacky (however it only happens with overlapping displacements, which wouldn't happen with the first method I provided). Lemme know if it worked for you!

The smaller rocks on the model should absolutely be turned into a model, as it wouldn't fare well with either brushwork or displacements, at all.

Turning everything into prop_statics was actually the first thing I tried-- after splitting the object up a bit first. The problem was self-shadowing; not visible from that angle is a series of caves that did not light reallistically as a set of props. I also felt a little bad about 90% of my visible map being static props...even if they are low-poly.

Displacements were my second attempt but as this model is triangle-based I found I had tremendous difficulty with the fine detail on the object, as well as imitating the UV-wrapped texture.

My third attempt, by extruding brushwork, almost worked. There were too many "t-junctions" (edges, not faces, touching) and it seems that the compiler throws an error after a certain number of those.

Looking at ShellVex, it looks like exactly what I need. I'll post an update once I try it out.

wallworm

I'm sure you'll enjoy ShellVex. There is a zip file named ShellVex_Example_Terrain.zip you can download when you've purchased it that has an example of converting a terrain mesh into brushes. If you enjoy it I hope you write a review on the product page.

Itszutak

#11
I'm really enjoying it so far! Unfortunately I'm still running into issues. Here's some cave geometry I imported:



Admittedly this is probably one of the more difficult things to throw at Hammer. Here is what the brushwork looks like, imported into Hammer:

(I hid the floor for this one, linked because it's a large picture) http://puu.sh/imQsq.png

I'm not quite sure what to do about this. It seems like Hammer moved the verts around when I saved the file...

here's a closeup of some of those vertices. grid scale is 1 unit:


edit: From past experience I think Hammer would like this better if triangles could be extruded to a single plane (chosen based on the normal and some average distance) like so:


This is the most successful method I found, but it had serious problems with texture mapping that I wouldn't have if I used wall worm (as it allows for arbitrary texture mapping and UV wrapping that properly imports into Hammer)

wallworm

Glad it's getting closer.

Here are some hints to get the best results for this tool:

1) Apply a SnapVertsToGrid modifier to the original mesh. This forces all the starting planes to be derived from grid.
2) Apply a Turn To Poly modifier to the original mesh. Check Keep Polygons Convex and use a planar threshold of something like 1.0 - 4.0. (If the original is entirely tris, you can skip this)
3) Experiment with NOT using the Snap to Grid on the ShellVex node. I say this because the only sides that matter are those that will appear in game and they are already on grid because step 1. The outside faces will get thrown away and the grid value shouldn't matter. This might alleviate some vertices getting moved when resaved.
4) Try turning on the Precise Coords in the VMF Exporter.

Also, have you tried to compile straight into source with the VMF exporter instead of compiling from Hammer? Compare the results.

As for the UVs being wrong, I'm not sure. I've had the UVs working fine so far. Can you send me your original scene as an Archive (File > Save As > Archive ) and I will see if there is something that can be done to fix it.

wallworm

Wanted to make note that there were several bugs fixed in ShellVex just now. One was a critical bug relating to reloading a scene with a ShellVex node crashing Max and/or corrupting the ShellVex geometry. Also fixes some other bugs.

Itszutak

Sorry for the late update! My sister graduated from college this weekend so I had to take a bit of a trip to get there.

I'm still having problems with shellvex, which I've been toying around with all day...

My current 3 complaints are this:

1: The vertices are still nowhere near the grid, although using snapvertices appears to have made them less bad-- there are still a few holes in the object, but not nearly as many as before. The inaccuracies with the vertices mean I can't add any new brushwork seamlessly to my map in Hammer, as dragging the shellvex-generated vertices causes invalid brushes.

2: the shellvex object is being generated WAY away from my model in 3ds max so importing often results in an object that's too far away from the origin for Hammer to display or save vertices of:


3: The brushes created by shellvex use an extrude modifier rather than something similar to the "shell" modifier built into 3ds max. The 3ds max shell modifier makes sure that the side faces of extruded shapes touch, which prevents issues caused by "T-junctions" (spots where edges, but not faces, touch) in Hammer, such as the poorly-named MAX_MAP_PLANES error.


I wish I could work entirely in 3ds max but from past experience my map has some quirks when I import it, and I haven't found a way to blend lightmapped_4wayblend textures with WWMT...

If you would like copies of my assets and maps, I'd be glad to send you them-- but I don't know a good way of sending such a large amount of data :(

I feel like a lot of these problems could be solved if there was some mode on snapvertices to apply that modifier from within 3ds max, so that all the vertices of the 3ds max model were on 3ds max grid points. Additionally, it would be nice if shellvex behaved more like the "shell" modifier in 3ds max, which creates a nearly-seamless "shell" around objects.

Once again thank you for your time and for wwmt, it's been a great help even if I'm having troubles with the final leg of this map (outside of entity population, which is the actual final step...)

SMF spam blocked by CleanTalk