return bones created into array

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 12 December 2012   #1
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.


(
	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 December 2012   #2
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 December 2012 at 03:57 AM. Reason: Using Python terminology
 
Old 12 December 2012   #3
rubbish! check the currently nodes, and all after that are new
 
Old 12 December 2012   #4
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 December 2012   #5
what do you mean by memory intensive?

local objCount = objects.count	
boneToChildren a false size:10	
local newObjs = for o = objCount + 1 to objects.count collect objects[o]
 
Old 12 December 2012   #6
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 December 2012   #7
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 December 2012   #8
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 December 2012   #9
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:

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 December 2012   #10
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 December 2012   #11
eek, there was some Typographical mistakes in your code:
BoneSys.create >> BoneSys.createBone
Point>>Points -- in line 20
__________________
http://3dcutout.com/
 
Old 12 December 2012   #12
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 December 2012   #13
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



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:49 PM.


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