搜索
# 其它对象
# BindModel
客户端
method in mod.client.component.virtualWorldCompClient.VirtualWorldCompClient
描述
把对象绑定到模型上, 支持绑定序列帧,粒子,文本和其它模型
参数
参数名 数据类型说明 virtualWorldObjectType int 对象类型枚举, 支持VirtualWorldObjectType.Sfx, VirtualWorldObjectType.Textboard和VirtualWorldObjectType.Particle, VirtualWorldObjectType.Model objId int 要被绑定的对象的id targetId int 绑定到的目标对象的id, 该对象删掉时,绑定在上面的对象也会删除 posOffset tuple(float,float,float) 绑定后相对目标的位置偏移 rotOffset tuple(float,float,float) 绑定后相对目标的旋转角度偏移 boneName str 要绑定到目标对象哪个骨骼,默认为root 返回值
数据类型说明 bool 是否成功 备注
- 模型绑定模型暂时不支持绑定到具体骨骼
- 模型绑定仅支持原版模型绑定原版模型,或者网易骨骼模型绑定网易骨骼模型,不支持原版模型绑定到网易骨骼模型这种类型交错的绑定
- 序列帧,文本,粒子的生命周期与可见性需要玩家自己管理,虚拟世界在隐藏或者销毁时不做处理。
示例
import client.extraClientApi as clientApi
VirtualWorldObjectType = clientApi.GetMinecraftEnum().VirtualWorldObjectType
virtualWorldComp = clientApi.GetEngineCompFactory().CreateVirtualWorld(clientApi.GetLevelId())
objId = virtualWorldComp.ModelCreateObject("datiangou", "run")
# 序列帧
frameEntityId = self.CreateEngineSfx("textures/sfxs/testSfx")
frameAniTransComp = clientApi.GetEngineCompFactory().CreateFrameAniTrans(frameEntityId)
frameAniControlComp = clientApi.GetEngineCompFactory().CreateFrameAniControl(frameEntityId)
frameAniControlComp.SetLoop(True)
frameAniControlComp.Play()
virtualWorldComp.BindModel(VirtualWorldObjectType.Sfx, frameEntityId, objId, (0.0, 3.0, 0.0), (0.0, 0.0, 0.0), "root")
# 文本
textBoardComp = clientApi.GetEngineCompFactory().CreateTextBoard(clientApi.GetLevelId())
textBoardId = textBoardComp.CreateTextBoardInWorld("Hello", (0.5, 0.4, 0.3, 0.8), (0, 0, 0, 1), True)
virtualWorldComp.BindModel(VirtualWorldObjectType.Textboard, textBoardId, objId, (0.0, 3.0, 0.0), (0.0, 0.0, 0.0), "root")
# 粒子
particleEntityId = self.CreateEngineParticle("effects/testParticle.json", (0.0, 0.0, 0.0))
parComp = clientApi.GetEngineCompFactory().CreateParticleControl(particleEntityId)
parComp.Play()
virtualWorldComp.BindModel(VirtualWorldObjectType.Particle, particleEntityId, objId, (0.0, 3.0, 0.0), (0.0, 0.0, 0.0), "root")
# 模型
childObj = virtualWorldComp.ModelCreateObject("datiangou", "fengxi")
virtualWorldComp.BindModel(VirtualWorldObjectType.Model, childObj, objId, (-1.0, 0.0, 0.0), (0.0, 0.0, 0.0))
# MoveToVirtualWorld
客户端
method in mod.client.component.virtualWorldCompClient.VirtualWorldCompClient
描述
把对象从主世界移到虚拟世界, 非绑定的序列帧,文本,粒子需要调用该方法后才会出现在虚拟世界中,绑定的可以省略调用该方法。
参数
参数名 数据类型说明 virtualWorldObjectType int 对象类型枚举, 支持VirtualWorldObjectType.Sfx, VirtualWorldObjectType.Textboard和VirtualWorldObjectType.Particle objId int 要移动的对象的id 返回值
数据类型说明 bool 是否成功 示例
import client.extraClientApi as clientApi
VirtualWorldObjectType = clientApi.GetMinecraftEnum().VirtualWorldObjectType
virtualWorldComp = clientApi.GetEngineCompFactory().CreateVirtualWorld(clientApi.GetLevelId())
# 序列帧
frameEntityId = self.CreateEngineSfx("textures/sfxs/testSfx")
frameAniTransComp = clientApi.GetEngineCompFactory().CreateFrameAniTrans(frameEntityId)
frameAniTransComp.SetPos((0.0, 0.0, 0.0))
frameAniControlComp = clientApi.GetEngineCompFactory().CreateFrameAniControl(frameEntityId)
frameAniControlComp.SetLoop(True)
frameAniControlComp.Play()
virtualWorldComp.MoveToVirtualWorld(VirtualWorldObjectType.Sfx, frameEntityId)
# 文本
textBoardComp = clientApi.GetEngineCompFactory().CreateTextBoard(clientApi.GetLevelId())
textBoardId = textBoardComp.CreateTextBoardInWorld("Hello", (0.5, 0.4, 0.3, 0.8), (0, 0, 0, 1), True)
virtualWorldComp.MoveToVirtualWorld(VirtualWorldObjectType.Textboard, textBoardId)
# 粒子
particleEntityId = self.CreateEngineParticle("effects/testParticle.json", (0.0, 0.0, 0.0))
parComp = clientApi.GetEngineCompFactory().CreateParticleControl(particleEntityId)
parComp.Play()
virtualWorldComp.MoveToVirtualWorld(VirtualWorldObjectType.Particle, particleEntityId)