POP —— Attributes

本文详细介绍了粒子系统中关键的属性驱动机制,包括状态属性如年龄、生命、位置、速度,以及线性和角动力学属性,如力、质量、空气阻力等。还涵盖了碰撞检测的处理方法和一些辅助功能如实例路径和粒子间距离计算。

        粒子系统首先是由属性驱动的,以下是解算器可以理解的属性;可使用POP VOP和POP Wrangle创建属性;

State
agefloat年龄,单位秒
nagefloat@age/@life,隐式属性,不可写入
lifefloat生命,单位秒
idint粒子唯一的标识号,使用findattribval()查找id对应的点号
Linear Physics
forcefloat该帧的力
massfloat质量默认为1.0
spinshapevec3与@pscale相乘,以确定粒子旋转的大致形状,默认(1,1,1)
targetvvec3粒子目标速度
airresistfloat空气阻力,匹配目标速度
speedmin, speedmaxfloat速度限制,单位秒
dragfloat粒子拖拽默认1.0
dragexpfloat1~2的值,默认在解算器上设置,用于角度和线性拖拽
dragshapevec3粒子在其每个局部轴上的拖动量,默认(1,1,1)
dragcentervec3会与质心间的差产生扭矩,此为局部偏移,默认(0,0,0)
dragnomalfloat如没有dragshape或dragnomal不为1,局部形状会被自动计算,默认1
dragtangentfloat当自动计算局部dragshape时,与dragnomal一起使用,默认1
Angular Physics
p@orientvec4粒子方向,默认(0,0,0,1)
wvec3粒子角速度,方向为旋转轴,大小为旋转强度
torquevec3等价于旋转的力
targetwvec3粒子目标旋转速度
spinresistfloat空气阻力,匹配目标旋转速度
speedmin, speedmaxfloat旋转速度限制,单位秒
State
deadint粒子是否死亡
stoppedint粒子是否停止,会保留速度,但不在更新位置、方向、速度等
stuckint粒子是否卡住,会机场速度
slidingint粒子是否沿曲面滑动
clingfloat滑动粒子向内应用力(根据表面法线),有助于弯曲表面停留
pospathstring存储一对象路径
posprimint路径几何体prim,默认-1
posuvvec3prim上的参数化uv
Collisions
hittotalint粒子碰撞累计次数,子步内可能碰撞多次但此属性只计算一次;如其他Compute Hit Total开启,可能重复计算;
hitnumint粒子是否碰撞
hitpathstring存储碰撞对象的路径
hitprimint碰撞面号,默认-1
hituvvec3碰撞面的参数化uv
hitnmlvec3碰撞表面的法线
hitvvec3碰撞表面的速度
hittimevec3碰撞发生的时间
hitimpulsefloat由Gas Impact to Attributes创建,记录碰撞impulse,需在解算器上勾选Add Impact Data;
has_ppreviousint如@pprevious值有效,此属性为1;
ppreviousvec3存储上一帧的粒子位置,用于碰撞检测;
bouncefloat弹力,默认由POP Object上参数控制
bounceforwardfloat弹力切线方向保持的能量,默认由POP Object上参数控制
frictionfloat摩擦力,默认由POP Object上参数控制
collisionignorestring匹配的对象(包括对象名字或id)将不会碰撞,不影响碰撞检测,默认""
Misc
s@instancepathstring复制到粒子上的几何体,可是磁盘上的路径或op:path(Instance SOP)
nearestint最近粒子的@id,如没有id也可能是@ptnum,由Proximity POP创建,默认-1
nearestdistfloat最近粒子的距离,由Proximity POP创建,默认-1
numproximityint指定范围内的粒子数,由Proximity POP创建,默认0

提供了基于BP(Back Propagation)神经网络结合PID(比例-积分-微分)控制策略的Simulink仿真模型。该模型旨在实现对杨艺所著论文《基于S函数的BP神经网络PID控制器及Simulink仿真》中的理论进行实践验证。在Matlab 2016b环境下开发,经过测试,确保能够正常运行,适合学习和研究神经网络在控制系统中的应用。 特点 集成BP神经网络:模型中集成了BP神经网络用于提升PID控制器的性能,使之能更好地适应复杂控制环境。 PID控制优化:利用神经网络的自学习能力,对传统的PID控制算法进行了智能调整,提高控制精度和稳定性。 S函数应用:展示了如何在Simulink中通过S函数嵌入MATLAB代码,实现BP神经网络的定制化逻辑。 兼容性说明:虽然开发于Matlab 2016b,但理论上兼容后续版本,可能会需要调整少量配置以适配不同版本的Matlab。 使用指南 环境要求:确保你的电脑上安装有Matlab 2016b或更高版本。 模型加载: 下载本仓库到本地。 在Matlab中打开.slx文件。 运行仿真: 调整模型参数前,请先熟悉各模块功能和输入输出设置。 运行整个模型,观察控制效果。 参数调整: 用户可以自由调节神经网络的层数、节点数以及PID控制器的参数,探索不同的控制性能。 学习和修改: 通过阅读模型中的注释和查阅相关文献,加深对BP神经网络与PID控制结合的理解。 如需修改S函数内的MATLAB代码,建议有一定的MATLAB编程基础。
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <title>流萤</title> <!-- 引入 Spine Player 样式 --> <link rel="stylesheet" href="./spine-player.css" /> <!-- 引入 Spine Player JS(IIFE 版本) --> <script src="./spine-player.js"></script> <script> // ✅ 添加:强制启用 WebGL alpha 通道 (function () { const original = HTMLCanvasElement.prototype.getContext; HTMLCanvasElement.prototype.getContext = function (type, attributes) { if (type === "webgl" || type === "experimental-webgl") { return original.call(this, type, Object.assign({ alpha: true }, attributes)); } return original.call(this, type, attributes); }; })(); </script> <style> body, html { margin: 0; padding: 0; overflow: hidden; background: rgba(0, 0, 0, 0); /* 使用白色背景代替透明 */ width: 100%; height: 100%; } #spine-container { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; background: rgba(0, 0, 0, 0); /* 使用白色背景代替透明 */ } /* 确保Spine Player创建的canvas也是白色 */ canvas { background-color: rgba(0, 0, 0, 0) !important; background: rgba(0, 0, 0, 0) !important; } /* 覆盖Spine Player可能的默认样式 */ .spine-player { background-color: rgba(0, 0, 0, 0) !important; background: rgba(0, 0, 0, 0) !important; } .spine-player-canvas { background-color: rgba(0, 0, 0, 0) !important; background: rgba(0, 0, 0, 0) !important; } /* 备用方案:如果需要透明,可以尝试使用特定颜色 */ /* .spine-player, .spine-player-canvas, canvas { background-color: rgba(0,0,0,0) !important; } */ </style> </head> <body> <!-- Spine 容器 --> <div id="spine-container"></div> <script> // 🔧 重要:在 new SpinePlayer 之前拦截 getContext,强制启用 alpha (function patchWebGLAlpha() { const originalGetContext = HTMLCanvasElement.prototype.getContext; HTMLCanvasElement.prototype.getContext = function (type, attributes) { if (type === "webgl" || type === "experimental-webgl") { attributes = Object.assign({ alpha: true, premultipliedAlpha: false, antialias: true, stencil: true, preserveDrawingBuffer: true }, attributes); console.log("WebGL context created with alpha:", attributes.alpha); } return originalGetContext.call(this, type, attributes); }; })(); let player = null; window.addEventListener('load', function () { if (typeof spine === 'undefined') { console.error('❌ spine 未定义!请检查 spine-player.js 是否加载成功'); return; } const container = document.getElementById("spine-container"); try { // 尝试使用rgba(0,0,0,0)代替transparent player = new spine.SpinePlayer(container, { jsonUrl: "./assets/1310.json", atlasUrl: "./assets/1310.atlas", animation: "idle", showControls: false, // ✅ 背景设为透明(使用rgba格式) backgroundColor: "#00000000", // ✅ 关键配置:启用透明渲染 premultipliedAlpha: false, realtimeRendering: true, clearColor: "#00000000", preserveDrawingBuffer: true, useWebGL: true, viewport: { debugClipping: false, padLeft: 0.1, padRight: 0.1, padTop: 0.1, padBottom: 0.1 }, success: function (instance) { console.log("✅ Spine Player 加载成功!"); player = instance; // 方法:通过 canvas 获取 WebGL 上下文并设置透明清屏色 const canvas = document.querySelector('#spine-container canvas'); if (canvas) { const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); if (gl) { gl.clearColor(0, 0, 0, 0); // 完全透明 gl.clear(gl.COLOR_BUFFER_BIT); console.log("✅ WebGL 背景已设为透明"); } else { console.warn("⚠️ 无法获取 WebGL 上下文"); } } else { console.warn("⚠️ 未找到 canvas 元素"); } // 处理挂起的动画请求 while (pendingAnimations.length > 0) { const { name, loop } = pendingAnimations.shift(); window.playAnimation(name, loop); } }, error: function (err) { console.error("❌ Spine 加载失败:", err); if (err.xhr) { console.error(`HTTP ${err.xhr.status}:`, err.xhr.statusText); console.error("响应内容:", err.xhr.responseText); } alert("Spine 资源加载失败,请检查路径或服务器环境!"); } }); } catch (e) { console.error("Spine Player 初始化异常:", e); } }); // 提供给外部调用的方法 window.playAnimation = function (name, loop = true) { if (!player || !player.state || !player.skeletonData) { console.warn("Spine player 尚未就绪,无法播放动画:", name); return; } const anim = player.skeletonData.findAnimation(name); if (!anim) { console.warn(`⚠️ 动画 "${name}" 未找到,请检查名称拼写`); return; } player.state.data.defaultMix = 0.2; // 淡入淡出时间 player.state.setAnimation(0, name, loop); }; </script> </body> </html> window.playAnimation = function (name, loop = true) { if (!player || !player.state || !player.skeletonData) { console.warn("Spine player 尚未就绪,无法播放动画:", name); return; } const anim = player.skeletonData.findAnimation(name); if (!anim) { console.warn(`⚠️ 动画 "${name}" 未找到,请检查名称拼写`); return; } player.state.data.defaultMix = 0.2; // 淡入淡出时间 player.state.setAnimation(0, name, loop); }; 加载问题是这里
11-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值