猫史档案馆


如何拥有全岛独一无二的皮肤?

用户:神岛吉吉喵神岛吉吉喵查看:39 回复:55 评论:39 创建时间:2021-12-06T15:06:00


答案很简单:

自己亲手做的当然是独一无二的啦~emotion_doge

答应大家的“穿衣教程”来了,上视频:

开始之前

记得先把所有的部位做成对应的模型放入地图中!

代码如下:

1.隐藏某个部位,以头部为例:

world.onPlayerJoin(({ entity }) => {
    /**
     * 以下代码是穿戴(addWearable) API结合 隐藏身体部位(skinInvisible) 功能的展示效果代码
     */
    // ----------------------------从这里开始--------------------------------------

    // API: addWearable - 在玩家某身体部位附上穿戴配件物体
    // 戴上南瓜头
    entity.player.addWearable({
        bodyPart: Box3BodyPart.HEAD,  // 南瓜头要加到“头”这个部位上
        mesh: 'mesh/小南瓜4.vb', // 南瓜头的模型位置(需要提前把模型放到场景里!)
        orientation: new Box3Quaternion(0, 1, 0, 0).rotateY(-Math.PI / 2), // 转到正确的方向
        scale: new Box3Vector3(0.5, 0.5, 0.5), 
        offset: new Box3Vector3(0, 0.3, 0),
    });

    //使用 “隐藏身体部件” 功能,把指定的身体部位隐藏掉!
    entity.player.skinInvisible.head = true;


})

其他的部件也是用同样的方式穿在身上

2.全身部件隐藏教程

const bodyData = [
 { bodyPart: Box3BodyPart.HEAD, name: '头', mesh: 'mesh/部件教程-头.vb', offset: [0, 0.4, -0.1], rotate: [0, 450, 0], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.TORSO, name: '躯干', mesh: 'mesh/部件教程-躯干.vb', offset: [0, 0.1, 0], rotate: [0, 90, 0], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.TORSO, name: '臀部', mesh: 'mesh/部件教程-臀部.vb', offset: [0, -0.25, 0], rotate: [0, 90, 0], scale: [0.5, 0.7, 0.4] },
 { bodyPart: Box3BodyPart.LEFT_UPPER_ARM, name: '左上臂', mesh: 'mesh/部件教程-左上臂.vb', offset: [0.1, 0.07,-0.02], rotate: [-128, 120, -85], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.RIGHT_UPPER_ARM, name: '右上臂', mesh: 'mesh/部件教程-右上臂.vb', offset: [-0.1, 0.07,-0.02], rotate: [-45, -120, -85], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.LEFT_LOWER_ARM, name: '左下臂', mesh: 'mesh/部件教程-左下臂.vb', offset: [0, 0.11, 0], rotate: [-128, 120, -85], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.RIGHT_LOWER_ARM, name: '右下臂', mesh: 'mesh/部件教程-右下臂.vb', offset: [0, 0.09, 0], rotate: [-45, -120, -85], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.LEFT_UPPER_LEG, name: '左上腿', mesh: 'mesh/部件教程-左上腿.vb', offset: [0, -0.05, 0], rotate: [0, 90, 0], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.RIGHT_UPPER_LEG, name: '右上腿', mesh: 'mesh/部件教程-右上腿.vb', offset: [0, -0.1, 0], rotate: [0, 90, 0], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.LEFT_LOWER_LEG, name: '左下腿', mesh: 'mesh/部件教程-左下腿.vb', offset: [0, 0.07, 0], rotate: [0, 90, 0], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.RIGHT_LOWER_LEG, name: '右下腿', mesh: 'mesh/部件教程-右下腿.vb', offset: [0, 0.07, 0], rotate: [0, 90, 0], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.LEFT_FOOT, name: '左脚', mesh: 'mesh/部件教程-左脚.vb', offset: [0, 0.06, 0.05], rotate: [0, 90, 0], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.RIGHT_FOOT, name: '右脚', mesh: 'mesh/部件教程-右脚.vb', offset: [0, 0.06, 0.05], rotate: [0, 90, 0], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.LEFT_LOWER_ARM, name: '左手', mesh: 'mesh/部件教程-左手.vb', offset: [0.16, 0.16, 0.09], rotate: [-56, -喵, 90], scale: [0.5, 0.5, 0.5] },
 { bodyPart: Box3BodyPart.RIGHT_LOWER_ARM, name: '右手', mesh: 'mesh/部件教程-右手.vb', offset: [-0.16, 0.05, 0.1], rotate: [-138, 60, 95], scale: [0.5, 0.5, 0.5] },
    ]
    world.onPlayerJoin(({ entity }) => {

        // 隐藏所有身体部件!
        for (const bodyPart in entity.player.skinInvisible) {
            entity.player.skinInvisible[bodyPart] = true;
        }

        // 根据配置穿戴身体各个部件
        for (const data of bodyData) {
            addWearable(entity, data)
        }
    });

    // 添加部件
    function addWearable(entity, data) {
        // 这一步是把角度转成弧度
        const orientation = new Box3Quaternion(0, 0, 0, 1)
                .rotateZ(data.rotate[2] * Math.PI / 180) 
                .rotateX(data.rotate[0] * Math.PI / 180) 
                .rotateY(data.rotate[1] * Math.PI / 180) 
        // 将上面声明的配置一一对应地传递给传递API
        entity.player.addWearable({
            bodyPart: data.bodyPart,
            mesh: data.mesh,
            orientation: orientation,
            scale: data.scale,
            offset: data.offset,
        })
    }

其中offset、rotate和scale分别代表

模型的偏移量、旋转角度和缩放值

需要根据具体的模型去自行调整数值

直接用的话可能导致模型角度不对的情况哦

emotion_编程猫_紧张

这一期简简单单的穿衣视频

相信大家都能学得会

圣诞皮肤创作节还在如火如荼的举行中!!

https://shequ.codemao.cn/community/414400

获奖了有奖品

没获奖也能做一套独一无二的皮肤

怎么样都不亏,快来参加吧!


回复

上一页1 页 / 共 2下一页
Architect_皮卡awaArchitect_皮卡awa

sofa

点赞0


评论


凌cloud凌cloud

好的现在没人我赶紧把剩下的前排板凳天花板地下室地板桌子椅子啥的全拖走

点赞0


评论


凌cloud凌cloud

emmmmm这次的教程有意思

点赞1


评论


果果1~果果1~

龙椅

点赞0


评论


该账号已被封禁该账号已被封禁

这不就skinInvisible那个么)

点赞1


评论


东方_山梦0317东方_山梦0317

中排

点赞1


评论


aygaeig315aygaeig315

ohhhhh

点赞1


评论


高贵的木叶龙A35d高贵的木叶龙A35d

12名

点赞1


评论


OHDaveOHDave

好诶()

点赞0


评论


墨染云天墨染云天

imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"

点赞0


评论


全能代码师全能代码师

前排

点赞0


评论


codegoucodegou

唯一存活官方

点赞1


评论


YLG_個YLG_個

前排

点赞0


评论


黑客熊猫黑客熊猫

不太会搞诶!!!,就不能直接加一个穿衣按钮吗

点赞0


评论


全能代码师全能代码师

好耶(

吉吉,出个代码控制放大/缩小游戏画面(也就是倍镜),

还有控制准星样式,比如+,^,-等

点赞0


评论


37303730

center_image

点赞0


评论


星星上的雪花星星上的雪花

好 

点赞0


评论


难起的名字难起的名字

啊好家伙吉吉,西(西伯利亚狐)他研究了好久的:https://box3.fun/e/745b5729d9b1c86e7309()()

点赞0


评论


虚无之空虚无之空

https://box3.codemao.cn/p/2a18efb72583a喵072e2

点赞0


评论


BXS_asteroidBXS_asteroid

隐身之后就全剧终了……()

点赞1


评论


XYS林深时见鹿XYS林深时见鹿

《简简单单》

点赞0


评论


建议不测建议不测

我还以为自定义皮肤真的出了呢。。。。

点赞1


评论


AbnormalLOGAbnormalLOG

我把屑和平做出来了()

center_image

点赞1


评论


本喵已死本喵已死

可以哦~

点赞1


评论


敏感的小电鼠zhvX敏感的小电鼠zhvX

啊这,我不会代码,吉吉喵快救救我,https://box3.fun/e/38fe5d91f56fb650baa0

点赞1


评论


敏感的小电鼠zhvX敏感的小电鼠zhvX

急招代码师,https://box3.fun/e/38fe5d91f56fb650baa0

点赞0


评论


Architect_煎饼Architect_煎饼

臀部 好评()()()

点赞3


评论


偶素提米偶素提米

话说官方这次给的皮肤模板貌似没有真正的皮肤精细

点赞0


评论


MrAssMrAss

怎么做局部皮肤部位

点赞0


评论


玖玙玖玙

呜呜呜!我连怎么写代码都不知道!!!求教啊啊啊啊!!!

点赞0


评论