Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lofting, and it's efficiency in collision modelling
01-19-2007, 02:04 AM,
#1
Lofting, and it's efficiency in collision modelling
-=Download Max Scenes=- for this tutorial.

It's a 7-zip archive. 7-zip is a freeware zip program which can be downloaded from 7-zip.org. It can achieve superior compression compared to any other zip program out there.

What you need for this tutorial:
- 3D Studio Max v8.0
- NifSkope (optional)

I don't know who first discovered that lofting produced more efficient collision models. I read a comment about it on ESF, something along the lines of that "someone had gotten it to work and it was better". So I tried it out, it worked like a charm, and so I thought I'd write a tutorial. But I want to make clear that I was not the one who discovered it.

I'm not an expert, and I'm not saying that this method is the best possible way to go about this - only that it works.

WHAT IS LOFTING?
Lofting is a way of modelling based on splines. Usually you would model with modifying primitives, or create splines that are quickly converted to editable meshes, or whichever way you prefer. But by lofting a spline you're creating a threedimensional object that'll never be an editable mesh.

WHY SHOULD I LEARN TO USE IT?
Lofting splines produces more efficient collision models. In other words you can improve the performance of your models in-game, or get collision molded closer to your model without sacrificing any.

WHY IS IT MORE EFFICIENT?
Hmm. Hmmmmm... *cough*. I don't have the faintest idea Big Grin It's a fact that can be proven though, which I'll show at the end of the tutorial.

[Image: th_TutCollisionLoft_TutorialScene01.jpg]

1.

Open TutorialScene01.max, which looks like the image above. There are two objects in the scene;

* CollisionBoxModel is, despite its name, the threedimensional object since I was creating my own collision box object during this job.
* CollisionLine is a spline I created that will form the base for the collision.

As you see, I drew the spline so that it would match the silhouette of the threedimensional object. Before I discovered lofting, I would have converted it to an editable mesh, extruded the polygon, then added a Cap Holes modifier, then just to be sure I would have added an Optimize modifier just to be sure there were no redundant faces.

What you should do now is create a new Spline consisting of only two vertices. Place the first vertice at X0 Y0 Z0 and the second vertice at X0 Y55,8 Z0 so that you end up with a simple line. This line will be used for what is called a "path". It will tell CollisionLine how it should extend.

[Image: th_TutCollisionLoft_TutorialScene02.jpg]

2.

Open TutorialScene02.max, which looks like the image above. As you see I've created the line mentioned in the previous paragraph.

Select CollisionLine. Now go to the Create panel, select Compound Objects in the drop-down list, and click the Loft button.

In the Loft rollout, find the Skin Parameters and expand it. Set the Shape Steps to 1 and Path Steps to 0. (Image #1)

Now, under Creation Method, click the button Get Path. With the button depressed, click on the LineForLoft, and it should look like Image #2.

As you see, the Loft model extruded the wrong way. I'm not sure why it does that, but it can be fixed very easily. Select LineForLoft, which through the lofting process has now been connected to CollisionLine. In the Line modifier, select Vertex, then select the far vertex. (Image #3) Just for fun, try to drag it around a bit and you'll see some interesting things happening with CollisionLine. Big Grin When you're done, set the coordinates of that vertex to X0 Y-55,8 Z0. Presto, it's flipped to where it should be for this model. (Image #4)

Delete LineForLoft and CollisionLine from the scene, you won't need them anymore. If you've been working on your own model in this tutorial you should keep a copy of them for backup purposes, it may come in handy. They should not be exported with the model though.

Like you would normally do, select the collision model, go to the Utilities panel, click on the NifProps button, tick "Is Collision Mesh" and set the appropriate material and layer settings. Since my model is an invisible speedbump to facilitate movement, I went with Metal and Transparant. You'd think it would be Ground, but if I had used that layer the player would have seen the yellow frame. (Image #5)

[Image: th_TutCollisionLoft_TutorialScene03.jpg]

3.

If you haven't completed step 2, or if you want to doublecheck if my description of step 2 made sense, open TutorialScene03.max which looks like the image above.

All that's left now is to export the model like you would usually do. But what I would suggest is that you check out the two nifs I included in the Experiments folder in NifSkope. Select the NiTriStripsData block, then scroll down the Block Details window until you find the value Num Triangles. This value equals the collision model's facecount. In the case of the lofted collision there are 64 triangles, while the usual collision resulted in 96. The more complex your collision, the more noticeable the optimization effect is.

Here's what the triangle info looks like:

[Image: th_TutCollisionLoft_ColBox02-LoftedC.jpg] [Image: th_TutCollisionLoft_ColBox02-UsualC.jpg]
¤ How to add images or files to your post ¤ Silgrad's UBBCode
My pet peeve: huge images in img code. I reserve the right to make any such image into a clickeable thumbnail whenever I see it.
Angel mired in filth
[Image: SignatureBannerRazorwing.jpg]
Reply
02-02-2007, 02:58 AM,
#2
 
*applause*

Efficient collision meshes are a must. They are controlled entirely by the CPU, which, no matter how powerful it is, just isn't cut out for rendering invisible meshes. During one of the earlier releases of RP (0.6, methinks), there were serious FPS issues right inside RP, because so many models had just a copy of their mesh as a collision. So the CPU was trying to render one version of th world while feeding your graphics card... a total mess. Newer collision meshes for those models has yielded somewhere around a 40% increase in FPS. Turning off collision, which stopped the collision mesh math from taking place, yielded the same result.

Those of you who think you don't have to worry about collision, please reconsider. It's way more important than you might think!
.:.::..::: Zarf - [url="http://www.youtube.com/watch?v=gbU_YqGZF5Y"]WARNING: Do not fall down mountains[/url] :::..::.:.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)