⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ck_playanimation.ms

📁 3dmax导出3d模型二次开发插件
💻 MS
字号:
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Register PlayAnimation Instruction
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
global instPlayAnimationStr = "Play Animation"
global instPlayAnimationRollout
global instPlayAnimationFct

--------------------------------------------------------
-- Rollout Fonction
--------------------------------------------------------
rollout instPlayAnimationRollout "Play Animation Options" width:408 height:114
(
	label info_Label "" pos:[8,8] width:250 height:64
	checkbox onclick_CheckButton "Play On Click" pos:[268,40] width:120 height:20 checked:true
	checkbox loop_CheckButton "Loop" pos:[268,60] width:80 height:20 checked:false
	checkbox playall_CheckButton "Play All Animations" pos:[268,80] width:120 height:20 checked:false
	spinner duration_Spin "" pos:[82,80] width:50 height:16 range:[0,1000,2] type:#float scale:0.1
	label duration_Label "Duration (sec):" pos:[8,80] width:74 height:16

	include "CKInstScripts\\ApplyPreviewButtons.ms"
	
	local changeInfo
	
	on instPlayAnimationRollout open do (
		duration_Spin.value = (animationrange.end.frame-animationrange.start.frame)/(framerate * 0.125 * pow 2 timeconfiguration.playbackspeed)
		changeInfo()
	)
	
	on onclick_CheckButton changed arg do changeInfo()
	on loop_CheckButton changed arg do changeInfo()
	on playall_CheckButton changed arg do changeInfo()
  
	--------------------------------------------------------
	-- Change Topics
	--------------------------------------------------------
  fn changeInfo = (
		
		if (playall_CheckButton.state==true) then (
			
			onclick_CheckButton.enabled = false
			if (loop_CheckButton.state==true) then (
				info_Label.text = "Info: Plays all object's animations, and constantly loops. Warning !!! the instruction will apply to the \"Virtools Global Helper\" (because there can be only one global animation) not to the selected object(s)"
			) else (
				info_Label.text = "Info: Plays all object's animations just once. Warning !!! the instruction will apply to the \"Virtools Global Helper\" (because there can be only one global animation) not to the selected object(s)"
			)
			
		) else (

			onclick_CheckButton.enabled = true
			if (onclick_CheckButton.state==true) then (
				if (loop_CheckButton.state==true) then (
					info_Label.text = "Info: Starts playing the object's animation when you click on it. Pauses when you click again. Resumes when you click again ...etc. The animation will loops."
					onclick_CheckButton.text = "Play/Pause On Click"
				) else (
					info_Label.text = "Info: Plays the object's animation just once when you click on the it. You need to click again to launch the animation once more."
					onclick_CheckButton.text = "Play On Click"
				)
			) else (
				if (loop_CheckButton.state==true) then (
					info_Label.text = "Info: Plays the object's animation and loops on it."
				) else (
					info_Label.text = "Info: Plays the object's animation just once."
				)
			)

		)
		
	)

	--------------------------------------------------------
	-- Update Rollout From Chunk
	--------------------------------------------------------
	fn UpdateFromChunk = (
		currentChunkBuf = GetCKChunk selection[1] instPlayAnimationStr
		
		local loop = ReadCKBufValue "Loop Animation"

		-- "Global Animation" case
		if (loop==undefined) then (
			-- loop
			loop_CheckButton.state = ReadCKBufValueAsBool "Loop Global Animation"
			-- Duration
			duration_Spin.value = ReadCKBufValueAsTime "Global Animation Duration"
			-- Play All Animations Checkbox
			playall_CheckButton.state=true

		-- "Normal Animation" case
		) else (
			-- loop
			loop_CheckButton.state = ReadCKBufValueAsBool "Loop Animation"
			-- Duration
			duration_Spin.value = ReadCKBufValueAsTime "Animation Duration"
			-- Play All Animations Checkbox
			playall_CheckButton.state=false
      -- Play On Click
			local tmp = findstring currentChunkBuf "On Click"
			onclick_CheckButton.state = (tmp!=undefined)
		)
		
		changeInfo()
	)
	
)


--------------------------------------------------------
-- Apply Instruction
--------------------------------------------------------
fn instPlayAnimationFct = (

	-- Attach Script 
	chunkData = "  " + CKAttacheScriptOnThisStr

	if (instPlayAnimationRollout.playall_CheckButton.state==true) then (

		-- "Global Animation" Case
		chunkData += "(\"Play Global Animation\")\x0d\x0a"
		chunkData += "  " + CKSetParamOnThisStr + "(\"Global Animation Name\", \"CK_EXPORTEDANIMATION\" )\x0d\x0a"
		chunkData += "  " + CKSetParamOnThisStr + "(\"Global Animation Duration\", \"0m " + (instPlayAnimationRollout.duration_Spin.value as string) + "s 0ms\" )\x0d\x0a"
		chunkData += "  " + CKSetParamOnThisStr + "(\"Loop Global Animation\", \"" + (boolAsVirtools instPlayAnimationRollout.loop_CheckButton.state) + "\" )\x0d\x0a"

		AddCKChunk $VirtoolsGlobalHelper instPlayAnimationStr chunkData
		updateInstructionsList()
		return ok
		
	) else (

		if (instPlayAnimationRollout.onclick_CheckButton.state==true) then (
			if (instPlayAnimationRollout.loop_CheckButton.state==true) then (
				chunkdata += "(\"Play-Pause Animation On Click Loop\")"
			) else (
				chunkdata += "(\"Play Animation On Click\")"
			)
		) else (
			chunkdata += "(\"Play Animation 3D Entity\")"
		)
	)
	chunkdata += "\x0d\x0a"
	
	-- Loop
	chunkData += "  " + CKSetParamOnThisStr + "(\"Loop Animation\", \"" + (boolAsVirtools instPlayAnimationRollout.loop_CheckButton.state) + "\" )"
	chunkdata += "\x0d\x0a"
	
	-- Duration
	chunkData += "  " + CKSetParamOnThisStr + "(\"Animation Duration\", \"0m " + (instPlayAnimationRollout.duration_Spin.value as string) + "s 0ms\" )"
	chunkdata += "\x0d\x0a"
	
	if (instPlayAnimationRollout.onclick_CheckButton.state==true) do (
		-- Mouse Hand Rollover
		chunkData += "  " + CKAttacheScriptOnThisStr + "(\"Mouse Hand Rollover\")"
		chunkdata += "\x0d\x0a"
	)
		
	for obj in selection do (
		-- Object Initial Local Matrix
		chunkData2 = "  " + CKSetParamOnThisStr + "(\"Object Initial Local Matrix\", \"" + (matrixInParentAsVirtools obj) + "\" )"
		chunkdata2 += "\x0d\x0a"

		-- Animation Name
		chunkData2 += "  " + CKSetParamOnThisStr + "(\"Animation Name\", \"" + obj.name + "\" )"
		chunkdata2 += "\x0d\x0a"
	
		AddCKChunk obj instPlayAnimationStr (chunkData+chunkData2)
		updateInstructionsList()
	)

	-- Virtools Global Helper Stuff
	-- Make 2d Picking Only Once
	chunkData = "  " + CKAttacheScriptOnThisStr + "(\"2dPick to RollOver\")"
	chunkdata += "\x0d\x0a"
	AddCKChunk $VirtoolsGlobalHelper "2dPick to RollOver" chunkData
	updateInstructionsList()
)

registerInstruction instPlayAnimationStr instPlayAnimationFct instRollout:instPlayAnimationRollout


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -