Reply
Reply
 
Thread Tools Display Modes
Okt's Avatar
Old (#1)
It might just be that I'm not totally thinking straight it's 4am, however I'm working on some scripts for a project and was wondering if anyone knows how I could lets say duplicate a mesh in my max file to a new location in the same scene. I have a mesh in my file called "box01" and an array of x,y,z coords. I'd like to be able to duplicate this mesh and move it to a location based on one of the elements in the array.

Coords are returned as [x,y,z]

Mesh names aren't important because I'm attaching them all to a single mesh before exporting it all.

Thanks
Offline , spline, 120 Posts, Join Date Mar 2005, Location Calgary, AB  
   Reply With Quote

jerry's Avatar
Old (#2)
<bool>maxOps.CloneNodes <&node array>nodes offset:<point3> expandHierarchy:<boolean> cloneType:<enum> actualNodeList:<node array> newNodes:<node array>

I think this function should do the trick, for more info look in the help as always Found this by using the listener, it actually is helpfull sometimes :P

I hope this was what you were looking for.

Last edited by jerry; 03-13-2009 at 05:36 AM..
while(true){ MakeArt(); }
Offline , triangle, 353 Posts, Join Date Oct 2006, Location Shanghai  
   Reply With Quote

renderhjs's Avatar
Old (#3)
more complete info can be found here:
http://www.kxcad.net/autodesk/Autode...ace_maxops.htm

search on that page for 'CloneNodes'

example code:
PHP Code:
--Clone the source.
result #()
--Instanced copy.
maxOps.cloneNodes object_to_clone_here offset:[0,0,0expandedHierarchy:true cloneType:#instance actualNodeList:#() newNodes:&result
the_result result[1
http://www.3dbuzz.com/vbforum/showthread.php?t=86499
Offline , veteran polycounter, 3,041 Posts, Join Date Mar 2008, Location Sydney Australia Send a message via AIM to renderhjs Send a message via MSN to renderhjs  
   Reply With Quote

Mark Dygert's Avatar
Old (#4)
http://www.neilblevins.com/soulburns...urnscripts.htm

Have you checked out Neil Blevins Object Replacer script? Probably does what you need it to, if not could have some handy insight.
(AKA Vig) Portfolio | Lab | Brawl | Decker |
Offline , Polycount.com Editor, 13,966 Posts, Join Date Oct 2004, Location Seattle, Wa Send a message via MSN to Mark Dygert  
   Reply With Quote

SyncViewS's Avatar
Old (#5)
Hi Okt,
here is a function doing the job. Works with Editable Poly and Mesh. Gets an object and an array of Point3 and clones the source to specified positions, then attaches them to the source.

You may want to look to this thread discussing how to speed up attachment of a large number of objects.

Code:
function cloneNodesToPos oSample ap3Pos =
(
    if ( ( ((classOf oSample) == Editable_Poly)    
        or ((classOf oSample) == Editable_Mesh) ) 
        and ((classOf ap3Pos) == Array) ) then
    (
        local iNumClones = ap3Pos.count
        local aoTempClone = #()
        
        local aoClones = #()
        
        with redraw off
        (
            for i = 1 to iNumClones do
            (
                maxOps.CloneNodes oSample offset:(ap3Pos[i] - oSample.pos) expandHierarchy:false cloneType:#copy newNodes:&aoTempClone
                aoClones[i] = aoTempClone[1]
            )
            
            if ((classOf oSample) == Editable_Poly) then
                for item in aoClones do
                    polyop.attach oSample item
            else if ((classOf oSample) == Editable_Mesh) then
                for item in aoClones do
                    meshop.attach oSample item
        )
    )    
    else
    (
        throw "Wrong input in function cloneNodesToPos()"
    )
)

(
    aPos = #()

    for i = 1 to 10 do
        aPos[i] = (random [-100, -100, -100] [100, 100, 100])

    EPolySample = convertToPoly(Torus())
    cloneNodesToPos EPolySample aPos
    
    for i = 1 to 10 do
        aPos[i] = (random [-100, -100, -100] [100, 100, 100])

    EMeshSample = convertToMesh(Sphere())
    cloneNodesToPos EMeshSample aPos
)
IllusionCatalyst – Instrument set for 3ds Max │ AliquaForma – Personal portfolio in fieri
Offline , polygon, 586 Posts, Join Date Dec 2008, Location Leamington Spa, UK  
   Reply With Quote

Mark Dygert's Avatar
Old (#6)
Wow, or just have the man that knows how to get things done, step in out of left field and save the day! NICE work SyncViewS! Fast too!

/saved =P
(AKA Vig) Portfolio | Lab | Brawl | Decker |
Offline , Polycount.com Editor, 13,966 Posts, Join Date Oct 2004, Location Seattle, Wa Send a message via MSN to Mark Dygert  
   Reply With Quote

SyncViewS's Avatar
Old (#7)
Hey Vig thanks, it's just a little function. I like coding snippets here and there when got the chance. Some of them may eventually grow into more complex scripts.
IllusionCatalyst – Instrument set for 3ds Max │ AliquaForma – Personal portfolio in fieri
Offline , polygon, 586 Posts, Join Date Dec 2008, Location Leamington Spa, UK  
   Reply With Quote

Okt's Avatar
Old (#8)
Wow guys thanks, the maxOps.CloneNodes function was what I was looking for.

@SyncViewS, thanks for the function, unfortunately for what I'm applying the functionality to it isn't really what I need. But seeing how to structure the resulting array and all that was a big help.

I'm writing a script which takes in all the gameplay telemetry from our student game project and turning it into a visual representation our level designers can toss into their maps in UnrealEd to get a better idea of the player path and player's use of our mechanics. I'll be posting in a few days to get some help turning it into a lean mean script.

Basically I get a log file from the game which after being parsed and reformatted by a simple perl script looks something like this:

LEVELSTART&
PLAYERSPAWN&
102092.01,3741.62,-64822.92,HEAVY&
102092.02,3741.63,-64964.61,HEAVY&
102092.05,3741.67,-65389.59,HEAVY&
CAMERARESET&
102092.06,3741.70,-66097.70,LIGHT&
102092.10,3741.71,-66524.59,LIGHT&
102092.09,3741.72,-66666.93,LIGHT&
PLAYERDEATH&
...


102092.01,3741.62,-64822.92,HEAVY&, this is basically the player's x,y,z, and state. Our game has three states, HEAVY, LIGHT, and NORMAL. it just allows us to see where the player is switching between the states.

LEVELSTART&, PLAYERSPAWN&, CAMERARESET&, PLAYERDEATH&, and a few others are simply events which occur.

So what I do is create a new spline and add knots at the player location every line. Every time the state changes I start a new spline with a new materialID. (This allows for different colouring in the game version) Also there is a set of simple geometry which relates to the different states and all the different events. These get placed when the event happens at the last known player location.

Being a student and all I'd be curious to know how much of this kind of thing actually gets done during the production stage of a game being developed by industry professionals.

Cheers all!
-Evan
Offline , spline, 120 Posts, Join Date Mar 2005, Location Calgary, AB  
   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 1998-2012 A. Risch