Render To Texture MAking Lod Texture

hi
I m Writing a script to make a LoD texture dinamicly Till now i achive to add modifiers which needed and got to bake the model But i cant get the texture part to work properly or work at all

My case is i have a high detail model want to copy its diffuse map To a Low detail model by RTT as i can do it manualy but i want to write a script for that to speed up
any help Would be Appriciated

here is my code
and My difficulty is in this (fn TextureLOD8 obj_) function May b i m doing it worng Confused need assistance

global Myrollout,Building_name,Texture_name,filenamearr

-- function For ALL the modifires
fn ModifiersLod8 =
(
object_ = $
if ( classof($) == Editable_poly ) do
(
select object_
object_.name
---subobjectLevel = 4
object_.EditablePoly.SetSelection #Face #{1..( polyop.getNumFaces $)}

modPanel.addModToSelection (Uvwmap ()) ui:on
object_.modifiers[#UVW_Mapping].maptype = 4

modPanel.addModToSelection (Unwrap_UVW ()) ui:on
object_.modifiers[#unwrap_uvw].unwrap.edit ()
subobjectlevel = 3
object_.modifiers[#unwrap_uvw].flattenMap 45.0 #([1,0,0], [-1,0,0], [0,1,0], [0,-1,0], [0,0,1], [0,0,-1]) 0.01 true 0 true true
maxOps.CollapseNode object_ off

modPanel.addModToSelection (Projection ()) ui:on
filename = object_.name
filenamearr = filterString filename "_"
filenamearr[6] = "L9"
Building_name = filenamearr[1]+"_"+filenamearr[2]+"_"+filenamearr[3]+"_"+filenamearr[4]+"_"+filenamearr[5]+"_"+filenamearr[6]+"_"+filenamearr[7]+"_"+filenamearr[8]

)
)
-- fuction for the RTT Operation

fn TextureLOD8 obj_ =
(
macros.run "Render" "BakeDialog"
obj_.INodeBakeProjProperties.enabled = true

obj_.INodeBakeProjProperties.projSpace = #raytrace -- properties of the RTT Options after picking
obj_.INodeBakeProjProperties.warnRayMiss = true
obj_.INodeBakeProjProperties.rayMissColor = [150, 150, 150]
obj_.INodeBakeProjProperties.subObjBakeChannel = 1

obj_.modifiers[#Projection].resetCage() --cage reset after picking the projection

be1 = diffusemap()
be1.outputSzX = be1.outputSzY = 512
filenamearr[5] = "MAP"
filenamearr[6] = "L8"
Texture_name = filenamearr[1]+"_"+filenamearr[2]+"_"+filenamearr[3]+"_"+filenamearr[4]+"_"+filenamearr[5]+"_"+filenamearr[6]+"_"+filenamearr[7]+"_"+filenamearr[8]

be1.fileType = (getDir #Textures+"\\"+Texture_name+".tga")

obj_.INodeBakeProperties.bakeEnabled = true
obj_.INodeBakeProperties.bakeChannel = 1
obj_.projectionMod = Projection()
obj_.INodeBakeProjProperties.projectionModTarget = Building_name
gTextureBakeDialog.bRender.pressed()
render rendertype:#bakeSelected
--render rendertype:#bakeSelected vfb:off progressBar:true outputSize:[512,512]
--
)

--Function For baking Of the Lower Detail Model
fn BakeLOD8 =
(

mergeMAXFile (scriptsPath + "data\\Bake_LOD.max" )

ambientColor = [60, 60, 60]
lightTintColor = [255, 255, 255]
backgroundColor = [0, 0, 0]
)

rollout Myrollout " LOD Texture automation " width:252 height:150
(

button bakeLod "BakeLod" pos:[16,50] width:100 height:20
button modifiers "Modifers" pos:[16,10] width:100 height:20
button TextureLOD "Texture LOD" pos:[16,90] width:100 height:20

On bakeLod pressed do
(
BakeLOD8()
)

On modifiers pressed do
(
ModifiersLod8()
)
On TextureLOD pressed do
(
TextureLOD8 object_
)
)

try(destroyDialog Myrollout)catch()
createDialog Myrollout 150 150

--Thanks

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
AR_Rizvi's picture

Helo Anyone?

Helo Anyone?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.