弹跳球。从而减缓在高度高峰高度、高峰

2023-09-07 17:30:31 作者:神深爱的少女

我创建了一个反弹球的动画在X3D。我只是好奇,我怎么可能让球慢下来,在其高度的峰值,使它看起来更逼真。谢谢你在前进。

I have created a bouncing ball animation in x3d. I am just curious how I could make the ball slow down at the peak of its height to make it look more realistic. Thank you in advance.

<X3D profile="interactive">
    <Scene>
        <Background skyColor='0.5 0.5 1'/>

    <Transform DEF="Ball" translation="0 1 0" >
    <TouchSensor DEF="Touch"/>
            <Shape>
                <Appearance>
                    <Material diffuseColor="1 0 0 "/>
                </Appearance>
                <Sphere radius='1'/>
            </Shape>
        </Transform>

    <TimeTrigger DEF="Trigger"/>
        <TimeSensor DEF="Clock" loop="false" cycleInterval="5" />    
        <PositionInterpolator DEF="Position" key="0.0 0.5 1.0" keyValue="0 1 0 0 5 0 0 1 0"/>

        <ROUTE fromNode="Clock" fromField="fraction_changed" toNode="Position" toField="set_fraction"/> 
        <ROUTE fromNode="Position" fromField="value_changed" toNode="Ball" toField="set_translation"/>
    <ROUTE fromNode="Touch" fromField="isActive" toNode="Trigger" toField="set_boolean"/>
    <ROUTE fromNode="Trigger" fromField="triggerTime" toNode="Clock" toField="startTime"/>

</Scene>

推荐答案

使用真实的物理为。

球有参数

ball have parameters 加速度(AX,AY,AZ)[米/秒^ 2] ...这是推动球各方力量SUMM由它的质量分 在速度V(VX,VY,VZ)[M / S] ...实际速度=整合加速的V + = A * DT 在位置p(X,Y,Z)[M] ...实际位置=整合速度的P + = V * DT 在半径r [M] 在质量m [公斤] 在DT [S] ...迭代步(更新时间) 在初始化启动,V值(0,0,0)和P开始位置

应用重力,摩擦,碰撞

重力例如G(GX = 0,GY = -9.81,GZ = 0) 在摩擦F2 = - (| V | ^ 2)* C2 *(V / | V |)...燃气 在摩擦F3 = - (| V | ^ 3)* C3 *(V / | V |)...液体 如果之前和跨边界冲突后的位置反映速度*碰撞系数&LT; = 1通过影响正常 也能体现的位置,如果跨越边界是不可能

把它都聚集在某些定时器/更新code与DT间隔

put it all together in some timer / updating code with dt interval

a =g+(f2+f3+(driving force))/m
v+=a*dt
p+=v*dt
test_collisions()
redraw()

对于位置手动更改

for manual change of position

在刚成立P(X,Y,Z)到新的位置 ,也可以设置V =(0,0,0),以阻止皮球
 
精彩推荐
图片推荐