• <tfoot id='Em0VE'></tfoot>

    1. <small id='Em0VE'></small><noframes id='Em0VE'>

        <bdo id='Em0VE'></bdo><ul id='Em0VE'></ul>
      <legend id='Em0VE'><style id='Em0VE'><dir id='Em0VE'><q id='Em0VE'></q></dir></style></legend>
    2. <i id='Em0VE'><tr id='Em0VE'><dt id='Em0VE'><q id='Em0VE'><span id='Em0VE'><b id='Em0VE'><form id='Em0VE'><ins id='Em0VE'></ins><ul id='Em0VE'></ul><sub id='Em0VE'></sub></form><legend id='Em0VE'></legend><bdo id='Em0VE'><pre id='Em0VE'><center id='Em0VE'></center></pre></bdo></b><th id='Em0VE'></th></span></q></dt></tr></i><div id='Em0VE'><tfoot id='Em0VE'></tfoot><dl id='Em0VE'><fieldset id='Em0VE'></fieldset></dl></div>

      1. 如何创建漩涡/漩涡效果?

        时间:2023-05-20

      2. <small id='LZJk0'></small><noframes id='LZJk0'>

              <tbody id='LZJk0'></tbody>

              • <bdo id='LZJk0'></bdo><ul id='LZJk0'></ul>

                <legend id='LZJk0'><style id='LZJk0'><dir id='LZJk0'><q id='LZJk0'></q></dir></style></legend>
                  <tfoot id='LZJk0'></tfoot>
                  <i id='LZJk0'><tr id='LZJk0'><dt id='LZJk0'><q id='LZJk0'><span id='LZJk0'><b id='LZJk0'><form id='LZJk0'><ins id='LZJk0'></ins><ul id='LZJk0'></ul><sub id='LZJk0'></sub></form><legend id='LZJk0'></legend><bdo id='LZJk0'><pre id='LZJk0'><center id='LZJk0'></center></pre></bdo></b><th id='LZJk0'></th></span></q></dt></tr></i><div id='LZJk0'><tfoot id='LZJk0'></tfoot><dl id='LZJk0'><fieldset id='LZJk0'></fieldset></dl></div>
                1. 本文介绍了如何创建漩涡/漩涡效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我试图在作为传感器的圆形体上制作涡流效果.我一直在寻找这个,我寻找的所有示例都是用 C++ 或 Objective C 编写的,我似乎翻译得不好.

                  Im trying to make a Vortex effect on a Circle Body that is a Sensor. I've been looking for this and all examples i look for are in C++ or Objective C and i dont seem to translate them well.

                  当我的对象碰撞时,它会调用 beginContact(..) 并设置一个标志,以便我可以调用 bodyToUpdate.applyForce(...);

                  when my objects collition, it calls beginContact(..) and it sets a flag so that i can call bodyToUpdate.applyForce(...);

                   public void beginContact(Contact contact) {
                               setColliding(true);
                   }
                  
                   //updating collition every frame
                   public void act(){
                       if (colliding) {
                          ball.getBody().applyForce(....);
                  
                   }
                  

                  如何计算每帧施加的力使其成为漩涡?

                  how to calculate the amount of force to apply every frame to make it a vortex?

                  所以我现在让物体直接进入漩涡的中心,但没有旋转"

                  so i now have the object going straight to the center of the vortex, but no "spin"

                  public void act() {
                      if (colliding) {
                          ball.getBody().setLinearVelocity(0, 0);
                  
                          ball.getBody().applyForce((portal.getBody().getPosition().x - ball.getBody().getPosition().x) * i,
                                  (portal.getBody().getPosition().y - ball.getBody().getPosition().y) * i,
                                  ball.getBody().getPosition().x, ball.getBody().getPosition().y, true);
                  
                          i++;
                      } else
                          i = 10;
                  }
                  

                  推荐答案

                  你想实现一个切向力,其大小向涡流中心增加.

                  You want to implement a tangential force with a magnitude that increases towards the center of the vortex.

                  这是一些伪代码.

                  radialVector = objectPosition - vortexPosition;
                  tangentialVector = radialVector.perpendicularVector();
                  
                  if (radialVector.length() < vortexRadius) {
                  
                      // Swirl faster when near the center of the vortex.
                      // Max tangential force when distance from center is 0.
                      // Min tangential force when distance from center is vortexRadius.
                      forceMagnitude = map(radialVector.length(), vortexRadius, 0, minTangentialForce, maxTangentialForce);
                      force = forceMagnitude * tangentialVector.normalize();
                      object.applyForce(force);
                  
                  }
                  

                  这是显示矢量分量的图像:

                  Here's an image that shows the vector components:

                  要创建漩涡效果,当物体靠近中心时,应增加径向 (Fr) 和切向 (Ft) 力.

                  To create a whirlpool effect there should be increasing radial (Fr) and tangential (Ft) forces as the object moves closer to the center.

                  这篇关于如何创建漩涡/漩涡效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Android/Java - GoogleMaps FragmentActivity 上的自定义视图 下一篇:没有了

                  相关文章

                  最新文章

                  <tfoot id='VCc03'></tfoot>
                2. <legend id='VCc03'><style id='VCc03'><dir id='VCc03'><q id='VCc03'></q></dir></style></legend>
                    • <bdo id='VCc03'></bdo><ul id='VCc03'></ul>
                    <i id='VCc03'><tr id='VCc03'><dt id='VCc03'><q id='VCc03'><span id='VCc03'><b id='VCc03'><form id='VCc03'><ins id='VCc03'></ins><ul id='VCc03'></ul><sub id='VCc03'></sub></form><legend id='VCc03'></legend><bdo id='VCc03'><pre id='VCc03'><center id='VCc03'></center></pre></bdo></b><th id='VCc03'></th></span></q></dt></tr></i><div id='VCc03'><tfoot id='VCc03'></tfoot><dl id='VCc03'><fieldset id='VCc03'></fieldset></dl></div>

                    <small id='VCc03'></small><noframes id='VCc03'>