3d Model Extrusion / Expansion, Cell Shading / Fatting effect |
![]() ![]() |
3d Model Extrusion / Expansion, Cell Shading / Fatting effect |
Nov 5 2009, 07:12 AM
Post
#1
|
|
|
GMC Member Group: GMC Member Posts: 79 Joined: 3-September 08 Member No.: 114219 |
Hello. A friend and I were chatting and we thought it would be neat to make a script to create a model with the polygon outlines for "Cartoon Effect"
Sure, admittedly its gona be slower than Grandma in the supermarket in GML but thats a start, Once I know I can make a GML script, I can make a DLL for gamemaker to use, and thats far faster. My idea is to extrude every face from its original position to a given outline distance. I have two problems with this... I'm a noob at 3D math, and secondly I can't find / don't know where or what to look for to find that math. I guess I'm saying is if anyone can make me a model expansion script, great! I'd be giving you 50% credit. If you can't, but can give me a link to resources that may help, thats good too I want to try to do this myself, but its not gona be fun if I can't make it work at all. Post if you don't understand what I just said. |
|
|
|
Nov 5 2009, 07:44 AM
Post
#2
|
|
|
^destroyed evil chicken^ Group: GMC Member Posts: 393 Joined: 18-January 07 From: The land of AUS Member No.: 68535 |
Why dont you try
1. creating the model as a wireframe and scaling it by a small number 2. Finding the visible points and using yourselfs 3d-2d scripts draw the lines on a ortho projection Because what I understand your trying to do is draw the outline as a plane eg: | |--- | ^edge ^face If thats incorrect please explain |
|
|
|
Nov 5 2009, 12:58 PM
Post
#3
|
|
|
GMC Member Group: GMC Member Posts: 79 Joined: 3-September 08 Member No.: 114219 |
What I'm trying to do is create a geometry outline. Its more than just scaling a model... I'll show you a pic.
The black outline is a version of the model with every face "Shell Extruded, Extracted or Net Extruded" till desired outline size and every normal reversed. In GM Culling would be on. Proper Outline - Extruded / Expanded Failed Outline - Scaling.. or d3d_transform_add_scale(1.1, 1.1, 1.1) kinda thing.. I did those effects in a my modeling software. That is the EXACT effect I'm lokign to acheive, but as a auto generated effect at room load. This post has been edited by Advokara: Nov 5 2009, 01:06 PM |
|
|
|
Nov 5 2009, 03:13 PM
Post
#4
|
|
|
GMC Member Group: GMC Member Posts: 3355 Joined: 1-June 07 From: Finland Member No.: 80090 |
I guess I'm saying is if anyone can make me a model expansion script, great! I'd be giving you 50% credit. If I was going to write a script for this, I'd make it and publish it with my own name, with 100% credit to me. Like... otherwise you'd expect to get your 50% for nothing ? So basically you're going to have to write the script yourself. This is not a code request forum (and neither is any other forum), you know. As for the mathematics, I can remember having thought about how to calculate the new vertices when doing this kind of effect. I didn't come to any kind of conclusion, though, but I'll tell you what I have in mind about this. First of all, you want to push all triangles into the direction of their normals. This happens by simply adding a scaled version of the normal vector to the vertex positions. The scalar is the amount of push. This will, however, pull the triangles apart (1). You'd need to somehow identify which edge joins which triangle. This may seem difficult as the model as data consists of only triangles (in the most simple file types). Nevertheless, it's not hard to write a script that when read through a model will find the vertices where all the three coordinates of the vertices are the same (i.e the vertices join some triangles). If you face too-hard-to-solve problems with putting this into practice, making the rest of the script is pretty much a dream. Ok let's say you've got a two-dimensional array of points that equal, where the points are coded with numbers and one index denotes a number of a set of points and the other denotes a point of the set. Now the main idea is to translate all equaling vertices so that they will move in the direction of the sum of triangle normal vectors. I.E. find all the triangles that the vertex joins and calculate the sum of all the normal vectors of those triangles. The vertices can be looped through with the arrays, and the triangles as well as their data can be backtracked using the fact that the sequential triplets of vertices form triangles (make use of n mod 3; the n is the vertex number). The vertices that aren't attached to any other triangle will get translated as in the pushing method (1). Telling whether it actually works is another thing. Now thinking about it this seems a logical method, but then again it wouldn't surprise me if someone found a practical dilemma in it. Anyone? |
|
|
|
Nov 5 2009, 08:41 PM
Post
#5
|
|
|
GMC Member Group: GMC Member Posts: 79 Joined: 3-September 08 Member No.: 114219 |
@Tepi
I meant 50% because I'd write a DLL of the Gamemaker script... I know its now a code request, thats why I asked for the math or links that can help with making it myself And I barely understood what you said. :/ I guess I really need help with the whole 3D math thing... |
|
|
|
Nov 6 2009, 12:19 AM
Post
#6
|
|
|
GMC Member Group: GMC Member Posts: 1357 Joined: 9-October 07 Member No.: 90249 |
i tried making the cell shading.
this reads the vertexes and creates a model slightly larger than the original, not scaling, but creating another triangle away from the original a certain amount depending on the vertex normal. it pretty much fails, but it reads data, finds a triangles normal, and flips the triangle over so the culling faces the right way. maybe you can start with it and improve it. http://host-a.net/slayer64/crap%20shading.zip |
|
|
|
Nov 6 2009, 12:35 AM
Post
#7
|
|
|
GMC Member Group: GMC Member Posts: 1288 Joined: 5-November 05 Member No.: 38296 |
GM's d3d models are saved in a plaintext format.
This is what I'd try if I were to do it. Take the model you want to cell-shade, save it using d3d_model_save (or whatever the function is called). Your script now will dig through this file - it's plaintext and not at all complicated, but the explaination of it's format is beyond the scope of this post - and grab all the coordinates for the verticies. It will find the surface normal for every triangle in the model. For each vertex sum all of the surface normals for all of the triangles it is a part of. Normalize this vector. Multiply this new vector by the width you want your outline to be. Store this vertex in a new model. Reverse the normals on the vertexes (or just use opposite of the surface normals you already calculated) and your new model is done. I haven't tested the script, but I think the method is sound. It made sense in my head anyways. It's not realtime fast... but if it were put in a dll it could probably be done at loading time. EDIT: Lol... well originally I'd skipped through Tepi's post, but I just went back and read it. Glad to see I'm on the same page as the mathematician. If we both have the same method, that makes me more confident that the method is sound. This post has been edited by T-Bird: Nov 6 2009, 12:44 AM |
|
|
|
Nov 6 2009, 07:06 AM
Post
#8
|
|
|
GMC Member Group: GMC Member Posts: 79 Joined: 3-September 08 Member No.: 114219 |
I have mosiac lite and my own GM model loader, I use get the wireframe and boundign box data.
I'm gona look at slayer's thing. And yeah, the idea is to make a model with and without an outline generated by a DLL at room start or the first time a model is loaded. It would allow one copy of a model and allow an option to enable and disable ooutlines |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 23rd November 2009 - 10:41 AM |