Enhancement of 3Ds Max poly extrude

Hi All,

I have a question regarding 3Ds Max poly extrude technique. While modeling I faced a problem lots of time and I try to find some solution but didn't get any thing. I know scriptspot is great community of max scriptors. So if any one can do something, will be great.

I have made a picture, which may describe the problem more elaborately.

Normal Cube with three subdivision.

Middle Polys are selected for extrusion.

While Extrding it happened like this.

If the final result may look like this, then it would be great.
I did manual vertex manipulation to achieve the result.

Thanks $ Regards,
Subhendu

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

Hi! The critics are always

Hi! The critics are always welcome. :)

For instance when I select a lot of faces it seems to be slower than my method(unless I use the loop functionality then it is indeed faster)

I think that the loop functionality is the right way  to doing the extrusion, but I can't figure out why the code works only for single poly loop.

Also I had a crash when I tried to select another object "attempted to access deleted object".

Can you describe me steb by step when this error occur? The most important part of the preview is to press the "Apply", "OK" or "Cancel" button when you don with the extrusion of one objectt. As you can see in the video of the script(in scriptspot page) I have no problems with selecting different objects while the script is open.

Also there seems to be a problem with the implementation of my extrusion function. It doesn't produce the same results as my method when the extrusion value is negative.

I have no problem with negative extrusion. Everything is like standart negative extrusion but with straight lines.


One more thing I like to mention is that my method does indeed not produce straight results when there are faces which form a 3D volume. This is because I forgot or rather neglected that there are two angles involved that describe the orientation of a vector in a 3D space. Right now my method only uses one of them which produces nice results most of the time but there are situations where it doesn't work so well. I believe when I incorporate both of these angles I can make the extrusion model really stable even for complex 3d meshes.
Also I would like to implement a bevel version of the script in the near future which is not an easy task too.

This will be aswame.

 

It would be nice however to mention my nickname inside the scriptUI to advertise my brand since I plan to add some other cool scripts on scriptspot under my nickname soon.

Your nickname is already in the script code, but I will add an about page to scriptUI. Just tell me what information(text) to put in the about page. 

Syphorlate's picture

I think that the loop

I think that the loop functionality is the right way  to doing the extrusion, but I can't figure out why the code works only for single poly loop.

Well, I take the view that it should be up to the user to decide how to extrude faces. Your loop mode is cool since it's really fast in usage. But usage shouldn't be restricted to loops alone. There are enough situations where you just need to select some faces here and there or some pattern for the extrusion. Loop is not wanted in every situation any selection of faces should be supported.

I have no problem with negative extrusion. Everything is like standart negative extrusion but with straight lines.

Here is a picture of the situation I encountered. The blue mesh is using my script the red one using yours. You can see the round edges on the red 3x3 cube.


Your nickname is already in the script code, but I will add an about page to scriptUI. Just tell me what information(text) to put in the about page.

Yes it would be cool if you could mention my nickname in the about page. Doesn't matter what it is saying exactly that's up to you :-)

miauu's picture

Hi! I think that the loop

Hi!

I think that the loop functionality is the right way  to doing the extrusion, but I can't figure out why the code works only for single poly loop.

Well, I take the view that it should be up to the user to decide how to extrude faces. Your loop mode is cool since it's really fast in usage. But usage shouldn't be restricted to loops alone. There are enough situations where you just need to select some faces here and there or some pattern for the extrusion. Loop is not wanted in every situation any selection of faces should be supported.

Sorry for my english. What i mean with "loop functionality" is  that part of the commented function:

                    vertInfo = #()
                    faceSel01Verts = #()
                    --    get starting face selection
                    faceSel01 = poGetFaceSelection curObj as array
                    for i in faceSel01 do
                    (
                        --    collect faces normals
                        faceNormal = poGetFaceNormal curObj i
                        --    collect faces verts
                        faceVerts = poGetFaceVerts curObj i
                        --    collect faces verts position
                        for i in faceVerts do
                        (
                                vx1 = poGetVert curObj i
                                append faceSel01Verts vx1
                        )
                        --    store values to main array
                        append vertInfo #( i, faceNormal, faceVerts, faceSel01Verts)
                    )

 

So, what I want to say is: it will be better(I think that) to collect all faces informations(verts, verts position, face normals etc.) in the begining of the extrusion and then when the user change the spinner value the script will use that information. There is no matter what the selection is - a poly loop or a something else(single faces here and there). I think this aproach will make the extrusion faster, but this is my opinion, may be I am wrong.

Anyway. after few minutes I will post the new version with "About" page. The future development of this script is in your hands. The matematical extrusion is your idea, so I think that is not fear to use your code to my script even if I give you a credit for that.

Fell free to use any part of my script, or the hole script if you want.

Best Regards!

:)

Syphorlate's picture

Oh ok. Yes sure it is faster

Oh ok. Yes sure it is faster to precache the data than recreating there you're absolutely right! But I noticed that when I for example select a few faces on the mesh and then execute your script then the preview is somehow slower than my method. When I use the buttons for making a face-selection-loop then the preview is faster than using my method. So I found that a little weird!

I also noticed a crash when I select only one face and extrude it using your script.

Anyway. after few minutes I will post the new version with "About" page. The future development of this script is in your hands. The matematical extrusion is your idea, so I think that is not fear to use your code to my script even if I give you a credit for that.

Ok that's probably better since there will surely come more updates. As I said I still have to include the version which is using the 2 angles. This will allow a perfect extrusion which will work on all types of faces and thus will allow things that would never be possible with the 3ds max default extrusion. And also I will make a bevel version of the script. So I'll probably release a script on my own then soon.

Syphorlate's picture

Mathematical Solution

There is actually a pretty elegant mathematical solution to this problem which yields perfect results and doesn't just scale the mesh which doesn't work properly for meshes with a lot of corners instead it keeps a perfect outline without the need to select any axis or stuff like that. Also it produces a stable topology which you can meshsmooth just like with the standard extrusion of 3ds max.

3DS max uses a radial extrusion (where all extruded vertices have the same distance from the original vertices) this produces a correct outline but those round edges are not always wanted.
To get rid of them you need to replace the radial extrusion with a quadratic one at the right places. For example when you have a 90° corner in your mesh you need to multiply the extrusion height for that corner point by 1.4142 (which is the diameter of a quad with extrusion height).This however only works for 90° degree corners of course.

But using cosinus function you can calculate the exact number for offsetting your vertices in a quadratic way so that those round edges vanish:

1.) For every vertex of an extruded mesh you need to calculate the angle between the normal of that face and the vector which connects the vertex of the original mesh with the vertex of the new extruded mesh:
vec1=normalize (newvert-oldvert)
vec2=facenormal
ang=acos( dot vec1 vec2)

2.)Then you build the cosinus value of that angle and invert it:
fac=1.0 / (cos ang)

3.) You can use this factor now to offset your radial extruded vertices so that they become quadratic:
newvert=oldvert+fac*(newvert-oldvert)

I attached a sample macroscript which I quickly hacked together. Here are a few pictures:

This is the original mesh

This is the typical 3dsmax extrusion for this mesh:

And this is the much cleaner version using my smartextrude script:

AttachmentSize
smartextrude.rar 1.4 KB
Anubis's picture

New ideas are always

New ideas are always welcome.

I never dig for better method, even this one (2 years old) using scale was just quick solution, the 1st that come to my mind, and its fast but limited.

Nice maths. I'm sure the folks who need that feature will be happy :)

my recent MAXScripts RSS (archive here)

miauu's picture

Hi! Very elegant solution. :)

Hi! Very elegant solution. :) I never tought about how the max extrude faces. :)
If you don't mind I will make some changes to speed up previews and fix the error that occur when I press the "apply" button and then select new faces on the same mesh - every time when I do that: "Runtime Error: Attempt to access deleted scene objects".

:)

Syphorlate's picture

Thanks guys.Yes It's really

Thanks guys.Yes It's really slow and unstable. Didnt have much time to make a perfect and speedy script. Also the preview function is a messy hack since the object is deleted and recreated everytime you change the slider... So yeah would be great if you could improve speed and stability dont have the time to do that now.

xyz3's picture

Hi miauu,

Hi miauu, PolyExtrudeIcons.png is missed, can you attach it?
Thanks¡

miauu's picture

The new mzp with UI images is

The new mzp with UI images is uploaded. Download it again, and sorry fot that stupid mistake. :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.