Home Technical Talk

Topoproject v0.1 Maxscript

polycounter lvl 15
Offline / Send Message
leslievdb polycounter lvl 15
Hey guys,

I have been working on this Topologyprojection script as a school project and thought it might come in handy for some of you.

So what it does is enable you to project a flat shape onto a 3d surface
check out the video for the features

[ame]http://www.youtube.com/watch?v=MB71JECpjRM&fmt=22[/ame]


2d7ezht.png

special thanks to Pior for some suggestions so far :)

Replies

  • Moosey_G
    Options
    Offline / Send Message
    Looking good, downloading now.
  • rollin
    Options
    Offline / Send Message
    rollin polycounter
  • Nysuatro
    Options
    Offline / Send Message
    Koen will be happy, hehe. Nice presentation.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    If you use a NodeEventCallback, specifically geometryChanged: and project your current selection along the camera ray you can make this process realtime.

    I have a working prototype of this at the moment that i keep meaning to finish. the end result is snapping much like topogun or silo. the great thing is its totally realtime and any modeling operations are automatically snapped to the surface of your mesh. Just make sure you have a way of telling the callback that the geometry change after a cast isnt a user input and to ignore it. otherwise you'll get verts sliding all over the model
  • leslievdb
    Options
    Offline / Send Message
    leslievdb polycounter lvl 15
    tnx for the comments

    r_fletch_r: yeah that could be a good feature, i'm going to take a look at that so maybe i could implement it as an extra feature
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    rather than along the camera ray I should have said. gw.transPoint your verts worldspace coord to screenspace and do a mapScreenToWorldRay.
    make sure you've set the graphic window’s transform to the identity.
    gw.setTransform(Matrix3 1)

    This should allow you to cast the vert onto the mesh from the perspective of the user. Heres my code, still a little buggy but it works. I cached the functions outside the casting loop to speed things up.

    if verts.numberSet != 0 then
                    (
                        local aVerts = verts as array --store verts in array for working, rather than a bitarray                    
                        --cache functions to speed up processing
                        local get_vert = polyOp.getVert
                        local set_vert = polyOp.setVert
                        local get_norm = getNormal
                        local intersect_ray = intersectRayEx
                        local  screen_to_world_ray = mapScreenToWorldRay
                        local trans_point = gw.transPoint 
                        local numVerts = aVerts.count
                        
                        --set the graphic window’s transform to the identity so we can transform the vertexs 3d coord to 2d with gw.transpoint
                        gw.setTransform(Matrix3 1)
                        
                        undo "vertex project" on
                        (
                        
                            for v = 1 to numVerts do
                            (
                                local vPos = get_vert nNode aVerts[v]
                                local vPos2D = trans_point vPos 
                                
                                local vRay = screen_to_world_ray vPos2D --get a ray in the direction of the screen camera, through the current Vert
                                --local vRay = screen_to_world_ray mouse.pos
                                local hit = intersect_ray rt_cast_tgt vRay --get the ray collision with the current target mesh.
                                
                                if hit !=undefined then --if the ray hits move the vert to its new position
                                (
                                    offset = rt_cast_offset * normalize(hit[1].dir)
                                    set_vert nNode #(aVerts[v]) #(hit[1].pos + offset)
                                    
                                    --When we move the vert it triggers the GeometryChanged callback.. which in turn calls this function resulting i a loop
                                    --in order to avoid this we tell this function to quite when rt_cast_pause is true, it also sets it to false on exit so the
                                    --next callback which will come from a user edit will be dealt with.
                                    rt_cast_pause = true
                                    
                                )
                                
                                
                            )
                        )
                    
    
    

  • leslievdb
    Options
    Offline / Send Message
    leslievdb polycounter lvl 15
    oh great :D, tnx for the help
    when my exams are over i'm going to put some time into implementing it for sure!
    maybe then i could make a combination of the projection so you could project topology shapes into a mesh that is snapping to the surface and that would automatically have the projected shape welded if points overlap
Sign In or Register to comment.