Wall Worm Forums

Design Tools => Wall Worm Level Design in 3ds Max => Feature Requests => Topic started by: Itszutak on June 12, 2015, 12:03:45 AM

Title: Snap vertices to grid//round off vertex coordinates
Post by: Itszutak on June 12, 2015, 12:03:45 AM
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!
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: wallworm on June 12, 2015, 12:41:45 AM
Well yes, this is a feature in a commercial modifier I wrote here: SnapVertsToGrid Modifier (http://dev.wallworm.com/topic/77/snap_verts_to_grid_modifier.html). You can get it on the WW store for $2.95.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: Itszutak on June 12, 2015, 12:42:43 AM
oh! Somehow I missed that. Thank you!
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: 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.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: wallworm on June 12, 2015, 12:59:43 AM
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.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: 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?

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

(https://www.wallworm.net/proxy.php?request=http%3A%2F%2Fpuu.sh%2FilQYn.png&hash=69305e265d70cd7d660c10c7e47f3bcf8fd4ecea)
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: Joris Ceoen on June 12, 2015, 05:40:06 AM
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.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: 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.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: wallworm on June 12, 2015, 09:19:33 AM
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 (http://dev.wallworm.com/topic/76/shellvex.html) 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.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: Itszutak on June 12, 2015, 02:00:41 PM
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.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: wallworm on June 12, 2015, 06:37:53 PM
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.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: Itszutak on June 12, 2015, 11:32:22 PM
I'm really enjoying it so far! Unfortunately I'm still running into issues. Here's some cave geometry I imported:

(https://www.wallworm.net/proxy.php?request=http%3A%2F%2Fpuu.sh%2FimQlR.png&hash=ed3d402fd652e3e070bc463888e98d98a1218652)

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:
(https://www.wallworm.net/proxy.php?request=http%3A%2F%2Fpuu.sh%2FimQF0.png&hash=fe6b5e4455d2c490b9f09d2f56078cb6d5cf706f)

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:
(https://www.wallworm.net/proxy.php?request=http%3A%2F%2Fpuu.sh%2FimTZu.png&hash=320fda33381cbfa2763ea8aa89de5ee44f8513cc)

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)
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: wallworm on June 13, 2015, 11:09:28 AM
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.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: wallworm on June 15, 2015, 03:17:23 PM
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.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: Itszutak on June 16, 2015, 08:03:41 PM
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:
(https://www.wallworm.net/proxy.php?request=http%3A%2F%2Fpuu.sh%2Firua7.png&hash=a4370730fe962f63acf6ffd7a9ad71034bbc65f3)

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...)
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: wallworm on June 16, 2015, 08:49:46 PM
I've sent you a PM.

First, make sure you download the latest ShellVex. It was updated yesterday and should say Version 1.21 in the About rollout.

In this version, there are some new features as well as bug fixes, one of which was a critical bug the caused a problem when re-opening a scene that already had a ShellVex node.

Why the object is offset is a total mystery to me. I've not seen that happen. Can you click File > Save As ... Archive and email the zip file to me? The only thing I can think of is that the XForm of the geometry is incorrect. You can try selecting the source geometry and clicking Utilities > Reset XForm and then click Reset Selected.

In the latest version there is a Sew Outer Verts that will sew the vertices (and create the Shell-like affect ). There is also a Snap Verts to Grid inside ShellVex itself.

I'm not 100% certain, but I believe that MAX_MAP_PLANES might not be affected by sides that have materials like nodraw. If so, the need for the sew can be skipped for those sides simply have a nodraw material. That's something that would need testing.

At this point, here's the best results I've gotten for terrain using ShellVex:

Once you have added the source Geometry, click the Clean Geometry button in the utilities tab. It will apply a Turn To Poly modifier (as well as a snapVertsToGrid modifier if installed) onto the Source.

Now in ShellVex, turn on Force Convex Polygons and then turn on the Auto Edge and set it to a value of 1.0 or 2.0 . If you have Edge Faces on in Max (F4) you can see how changes to the Auto Edge threshold affects the polygons on the ShellVex geo (note that the more faces in the source geo, the slower all the calculations are). If it is true that nodraw sides are ignored for the MAX_MAP_PLANES, then simply turn on the cap side and the sides to material id 2 in the materials rollout and update the ShellVex material to a multi/sub-object material with tools/toolsnodraw in ID 2; otherwise, you can use the sew command and/or Snap Verts.
Title: Re: Snap vertices to grid//round off vertex coordinates
Post by: Itszutak on June 16, 2015, 10:20:02 PM
(PM appears not to be showing up unless I don't know how this forum works)

How do I apply the Clean Geometry button? Once I select my target geometry it generates a shape and all the options disappear.