[Query] Vraylight to Spline Rectangle ... Will I be able ?

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 09 September 2010   #1
Smile [Query] Vraylight to Spline Rectangle ... Will I be able ?

Spline Rectangle ->>> Vraylight....

Last edited by seoul : 09 September 2010 at 04:13 PM.
 
Old 09 September 2010   #2
easy, just get the position of the vray light and the dimension properties, then create a new rectangle shape with those dimensions.
 
Old 09 September 2010   #3
Select your Vray Light plane.

Rectangle length:($.size1 * 2) width:($.size0 * 2) cornerRadius:0 transform:$.transform
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 09 September 2010   #4
Wink [Q] David Wortley... says wrong ;;



Multi Select your Spline VrayLight

VrayLight to Edittable Spline
 
Old 09 September 2010   #5
hehe...let's see if I say right:

for i in selection where (classOf i==VRayLight) do if i.type==0 do rectangle length:(i.size1 * 2) width:(i.size0 * 2) cornerRadius:0 transform:i.transform
 
Old 09 September 2010   #6
Unhappy [RQ] Spline => VRayLight



Spline => VRayLight
 
Old 09 September 2010   #7
try this..
(
	newselection = #()
	for i in selection do
	(
		if classof i == rectangle do
		(
			light = vraylight()
			light.size0 = i.width/2
			light.size1 = i.length/2
			light.transform = i.transform
			append newselection light
		)
	)
	deselect $*
	select newselection
)

Last edited by HornBerger : 09 September 2010 at 12:34 PM.
 
Old 09 September 2010   #8
Wink [RQ] Rectangle no, Spline Yes -> VRayLight



< x > Multi Select Rectangle -> VRayLight
< o > Multi Select Editable Spline -> VRayLight
 
Old 09 September 2010   #9
here's a quick way of doing it..

(
	try (delete $vraylightfromsplineshape*) catch()
	newselection = #()
	for i in selection do 
	(
		if (classof i) == splineshape do
		(
			extrudeMod = extrude amount:0
			addmodifier i extrudeMod
			light = vraylight()
			light.type = 3			
			light.mesh_source = i
			light.transform = i.transform
			light.multiplier = 2		
			--light.mesh_flip = false
			--light.mesh_flip = true
			light.doubleSided = true
			light.name = uniquename "VrayLightFromSplineShape"
			deletemodifier i extrudeMod
			append newselection light
		)
	)
	deselect $*
	select newselection
)
 
Old 09 September 2010   #10
Unhappy [req] E R R O R ~



ERROR...
 
Old 09 September 2010   #11
works fine for me.. hmm maybe its because of version difference (select a vray light and type
show $
in the listener and paste the result here)

 
Old 09 September 2010   #12
Unhappy [Q] Please...

Version is used...
3dsmax 8.0 & Vray RC3
 
Old 09 September 2010   #13
i think rc3 didn't have mesh support for vray lights.. anyways try this.. maybe it will work..

(
	newselection = #()
	try (delete $vraylightfromsplineshape*) catch()
	for j in selection do
	(
		if classof j == splineshape do 
		(
			xArr = #()
			yArr = #()
			zArr = #()
			for k = 1 to (numsplines j) do
			(
				for i = 1 to (numknots j k) do 
				(
					xArr[i] = (getknotpoint j k i).x
					yArr[i] = (getknotpoint j k i).y
					zArr[i] = (getknotpoint j 1 i).z
				)
				shapeWidth = (amax xArr) - (amin xArr)
				shapeLength = (amax yArr) - (amin yArr)
				vlight = vraylight()
				vlight.size0 = shapeWidth /2 
				vlight.size1 = shapeLength/2
				vlight.transform = j.transform
				vlight.pos = [(((amax xArr) + (amin xArr))/2),(((amax yArr) + (amin yArr))/2),(((amax zArr) + (amin zArr))/2)]
				vlight.name = uniquename "VraylightFromSplineShape"
				append newselection vlight
			)
		)
	)
	deselect $*
	select newselection
)
 
 
Old 09 September 2010   #14
here's a more sophisticated approach (the advantage of this script is it calculates the correct transformation matrix irrespective of the transformations applied to the pivot or the spline sub-object of the Spline shape) the script assumes that all the spline shapes are "rectangular" i.e adjacent sides are perpendicular and the shape has 4 knot points :

(
	global o,a,b,c
	try (delete $vrayLightFromSplineShape*) catch()
	newSelection = #()
	fn computeTm v1 v2 ss = 
	(
		n = normalize (cross (normalize v1) (normalize v2))
		maxX = amax o.x a.x b.x c.x
		minX = amin o.x a.x b.x c.x
		maxY = amax o.y a.y b.y c.y
		minY = amin o.y a.y b.y c.y
		maxZ = amax o.z a.z b.z c.z
		minZ = amin o.z a.z b.z c.z
		center = [(maxX + minX)/2 , (maxY + minY)/2, (maxZ + minZ)/2]
		tm = matrix3 (normalize v1) (normalize v2) n center
		shapewidth = length v1
		shapelength = length v2	
		Vlight = vraylight size0:(shapewidth/2) size1:(shapelength/2) transform:tm name:(uniqueName "vrayLightFromSplineShape")
		append newselection Vlight
	)

	for i in selection do
	(
		if ((classOf i) == SplineShape) do 
		(
			for j = 1 to numsplines i do
			(
				o = getknotpoint i j 1
				a = getknotpoint i j 2
				b = getknotpoint i j 3
				c = getknotpoint i j 4
				v1 = (a - o)
				v2 = (b - o)
				v3 = (c - o)
				angle1 = acos (dot (normalize v1) (normalize v2))
				angle2 = acos (dot (normalize v1) (normalize v3)) 
				angle3 = acos (dot (normalize v2) (normalize v3)) 	
				if ((angle1 as string) == "90.0") do (computeTM v1 v2 i)
				if ((angle2 as string) == "90.0") do (computeTM v1 v3 i) 
				if ((angle3 as string) == "90.0") do (computeTM v2 v3 i) 
			)
			
		)
		
	)
	deselect $*
	select newselection
	"OK"
)


note: for some reason angle1 == 90.0 always yields false even when angle is 90.0 :S so i had to convert it to string to make the comparison :S

here's a snap :
 
Old 09 September 2010   #15
Smile [Success] Resolve ...

Thank you very much for your help


plastic ^^
DaveWortley ^^
HornBerger ^^


해결되었습니다..
HornBerger님 앞으로 잘 부탁드리겠습니다. 감사합니다.
 
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 02:29 AM.


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