CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 12-06-2012, 02:52 AM   #1
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,307
Send a message via AIM to JokerMartini
return bones created into array

What would be the best way to go about returning an array containing the newly created bones for use in a script I'm creating?

Script contains everything you need for testing.

Code:
( delete objects a = point pos:[0,0,0] wirecolor:yellow b = point pos:[30,5,0] parent:a wirecolor:yellow c = point pos:[75,25,0] parent:b wirecolor:yellow d = point pos:[120,0,0] parent:c wirecolor:yellow fn nubCreation endBone= ( --Create a bone with default settings. b=boneSys.createBone [0,0,0] [1,0,0] [0,0,1] --Set the transforms. b.transform=endBone.transform b.pos=endBone.transform.pos+(endBone.length*endBon e.transform.row1) --Set all the params needed. b.width=endBone.width b.height=endBone.height b.length=endBone.width b.taper=endBone.taper --Clean up. b.parent=endBone b.name=endBone.name+"_nub" b ) fn boneToChildren startPoint parentBone size:2.0 = ( if (startPoint.children.count > 0) then ( for c in startPoint.children do ( newBone = BoneSys.createBone startPoint.pos c.pos [0,0,1] newBone. width = newBone.height = size if (parentBone != false) then newBone.parent = parentBone boneToChildren c newBone size:size ) ) else ( n = nubCreation parentBone ) ) boneToChildren a false size:10 --return an array of created bones for later use completeRedraw() )
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 12-06-2012, 03:37 AM   #2
eek
Fixer
 
eek's Avatar
portfolio
Charles Looker
Snr Technical Artist
Electronic Arts
Vancouver, Canada
 
Join Date: Feb 2002
Posts: 4,221
I'd think you'd pass the append method in your boneToChildren fn, because your passing in your initial function again during a loop.
__________________
Disclaimer: My opinions are not those of my employer.



Last edited by eek : 12-06-2012 at 03:57 AM. Reason: Using Python terminology
 
Old 12-06-2012, 03:46 AM   #3
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,511
Send a message via ICQ to denisT
rubbish! check the currently nodes, and all after that are new
 
Old 12-06-2012, 04:34 AM   #4
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,307
Send a message via AIM to JokerMartini
Quote:
Originally Posted by denisT
rubbish! check the currently nodes, and all after that are new


That seems more memory intense than necessary. Although it may be a quick and dirty method.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 12-06-2012, 08:23 AM   #5
lo
the frequentest!
portfolio
Rotem Shiffman
Tel Aviv, Israel
 
Join Date: Jul 2005
Posts: 2,837
what do you mean by memory intensive?

Code:
local objCount = objects.count boneToChildren a false size:10 local newObjs = for o = objCount + 1 to objects.count collect objects[o]
 
Old 12-06-2012, 02:29 PM   #6
PePeTD
The One and Only
 
PePeTD's Avatar
portfolio
Felipe Nogueira
Technical Artist
Bethesda Softworks
Rockville, USA
 
Join Date: Jul 2008
Posts: 208
Send a message via ICQ to PePeTD Send a message via MSN to PePeTD
Haha cool way of doing it I would have just used the append method like eek mentioned, Live and learn right?
__________________
Felipe Nogueira aka: PePeTD
Technical Artist/Character TD
http://felipenogueira3d.com
 
Old 12-06-2012, 02:34 PM   #7
PePeTD
The One and Only
 
PePeTD's Avatar
portfolio
Felipe Nogueira
Technical Artist
Bethesda Softworks
Rockville, USA
 
Join Date: Jul 2008
Posts: 208
Send a message via ICQ to PePeTD Send a message via MSN to PePeTD
Also joker if you create the helpers first rotate point 2 down (as if you were setting the arm at a 45 degree angle) and run the rest of the script your bones become slightly miss aligned just thought you should know, but you probably know that already.
__________________
Felipe Nogueira aka: PePeTD
Technical Artist/Character TD
http://felipenogueira3d.com
 
Old 12-06-2012, 03:16 PM   #8
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,307
Send a message via AIM to JokerMartini
Very cool way of doing it.
I never really messed with it that way.
Thanks guys.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 12-06-2012, 04:18 PM   #9
eek
Fixer
 
eek's Avatar
portfolio
Charles Looker
Snr Technical Artist
Electronic Arts
Vancouver, Canada
 
Join Date: Feb 2002
Posts: 4,221
Quote:
Originally Posted by PePeTD
Haha cool way of doing it I would have just used the append method like eek mentioned, Live and learn right?


Really just for cleanliness I like systems to be self contained. If other process happen to the scene whilst this is taking place for instance things may break. Something like this:

Code:
local points = #( [0,0,0], [0,0,10], [0,0,20], [0,0,30]) local theBones = #() local vec, nub if points.count > 1 do ( for i = 2 to points.count do ( theBone = boneSys.create points[i-1] points[i] [0,0,1] append theBones theBone if theBones.count > 1 do ( theBone.parent = theBones[i-2] ) ) ) vec = normalize (points[point.count] - points[points.count-1]) nub = boneSys.create points[points.count] (vec * 5.0 + points[points.count]) [0,0,1] nub.parent = theBones[theBones.count]
__________________
Disclaimer: My opinions are not those of my employer.


 
Old 12-10-2012, 06:16 PM   #10
PePeTD
The One and Only
 
PePeTD's Avatar
portfolio
Felipe Nogueira
Technical Artist
Bethesda Softworks
Rockville, USA
 
Join Date: Jul 2008
Posts: 208
Send a message via ICQ to PePeTD Send a message via MSN to PePeTD
Yep! exactly how I would have imagined it, but cool to learn a different quick way to get nodes that were created I will keep using append just because it is more organized for me .
__________________
Felipe Nogueira aka: PePeTD
Technical Artist/Character TD
http://felipenogueira3d.com
 
Old 12-14-2012, 09:23 AM   #11
MZ
Expert
 
MZ's Avatar
portfolio
Mehdi Zangeneh
Animation TD
Bina Film
Tehran, Iran
 
Join Date: Sep 2007
Posts: 339
eek, there was some Typographical mistakes in your code:
BoneSys.create >> BoneSys.createBone
Point>>Points -- in line 20
__________________
http://3dcutout.com/
 
Old 12-15-2012, 06:58 AM   #12
eek
Fixer
 
eek's Avatar
portfolio
Charles Looker
Snr Technical Artist
Electronic Arts
Vancouver, Canada
 
Join Date: Feb 2002
Posts: 4,221
Quote:
Originally Posted by MZ
eek, there was some Typographical mistakes in your code:
BoneSys.create >> BoneSys.createBone
Point>>Points -- in line 20


Sweet, thank you MZ
__________________
Disclaimer: My opinions are not those of my employer.


 
Old 12-15-2012, 06:58 AM   #13
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:26 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.