QQ聊天

MaxScript调用IGame

IGame是MaxSDK中的一个组件,在原生接口上做了封装来方便导出数据,以往在MaxScript中是不能调用IGame的,不过从Max2013开始MaxSDK有了.net版本(Max2012安装了扩展包也可以),MaxScript也可以使用MaxSDK的全部接口了。范例如下

Fn InitializeMaxSDK = 
(
    local result = false
    if (MaxVersion())[1] >= 14000 do
    (
        result = (DotNetClass "Autodesk.Max.GlobalInterface") != undefined
        if not result do
        try
        (
            DotNet.LoadAssembly (PathConfig.GetDir #MaxRoot + "\Autodesk.Max.dll")
            result = true
        )
        catch()
    )
    result
)

Fn GetMaxGlobal = (DotNetClass "Autodesk.Max.GlobalInterface").Instance
Fn GetMaxCoreInterface = (DotNetClass "Autodesk.Max.GlobalInterface").Instance.CoreInterface

Fn ParseIGameScene argIGameScene = 
(
    local tempIGameNode,tempNode
    local tempNodeName,tempChildrenNames,tempParentName
    for i = 1 to argIGameScene.TotalNodeCount do
    (
        tempChildrenNames = ""
        tempIGameNode = argIGameScene.GetIGameNode i
        for ci = 0 to tempIGameNode.ChildCount do
        (
            tempNode = tempIGameNode.GetNodeChild ci
            if undefined != tempNode do tempChildrenNames += " " + tempNode.name
        )
        if tempIGameNode.NodeParent != undefined do tempParentName = tempIGameNode.NodeParent.Name
        print ("Name:" + tempIGameNode.Name + "\t\t Parent:" + tempParentName as string + "\t\t Children:" + tempChildrenNames)
    )
)

Fn SimpleIGameMain = 
(
    if InitializeMaxSDK() do
    (
        MaxGolbal = GetMaxGlobal()
        MaxCoreInterface = GetMaxCoreInterface()
        theIGameScene = MaxGolbal.IGameInterface
        theIGameScene.InitialiseIGame false
        ParseIGameScene theIGameScene
    )
)
SimpleIGameMain()

 

 

 

posted @ 2013-05-29 14:23  SITT  阅读(771)  评论(0编辑  收藏  举报
QQ聊天