ClothPatch questions

Hello!



I have two noob questions concerning ClothPatch:


  • If I attach my ClothPatch to a Node object, the texture of another child of that node disappears. They have nothing in common, the ClothPatch loads a different texture (and shows it). If I comment out the line attachChild(cloth); , the other part shows its texture. Is this a bug? [edit] If I load the cloth texture from an image and not from a file, everything is fine. Strange, isn't it? [/edit]


  • The Node object I attached the ClothPatch moves slowly, so it would look natural if the patch keeps the initial windDirection and doesn't rotate with the parent node. What can I do to get that behavior?



    Thanks!

    Landei

And one additional question:



My ClothPatch should have different textures from both sides (e.g. text on the flag shouldn't be mirrored).



I tried to use the ClothPatch as target for two SharedMeshes, and applied the textures to the SharedMesh (with the correct culling state). This worked well, just my flag wasn't moving any longer, but looked like a Quad  :expressionless:



Is there no trick to set two textures, which have different culling settings? Any other idea  :?

Landei said:

And one additional question:

My ClothPatch should have different textures from both sides (e.g. text on the flag shouldn't be mirrored).

I tried to use the ClothPatch as target for two SharedMeshes, and applied the textures to the SharedMesh (with the correct culling state). This worked well, just my flag wasn't moving any longer, but looked like a Quad

Works fine!!! llama, you're my personal rock star!

BTW: I also solved the second problem (flag shouldn't turn with the parent node). Probably this is also obvious for most of you, but I post it for the next noob (or you tell me that this is overkill, and show me a one-line-solution)  :smiley:



class MyNode{
   ...

    class WindForce extends SpringPointForce {
        private float strength;
        private boolean addRandom;
        private Vector3f windDirection;
       
        WindForce(float strength, Vector3f windDirection, boolean addRandom) {
            this.strength = strength;
            this.windDirection = windDirection;
            this.addRandom = addRandom;
        }
       
        public void apply(float dt, SpringPoint node) {
            float tStr = (addRandom ? FastMath.nextRandomFloat() * strength : strength);
            Vector3f wind = MyNode.this.getWorldRotation().inverse().mult(windDirection);
            node.acceleration.addLocal(wind.x * tStr, wind.y * tStr, wind.z * tStr);
        }
      
    }
 
}


One more flag question:



The cloth behavior seems to be very instabil when the frame rate chages (even slightly). I thought this comes from the forces provided by ClothUtils: They don't use the dt parameter in the apply method, so they seem to be added up by frame rate, and not depending on the elapsed time. However, playing around using the dt parameter in order to compensate the frame rate changes was not successful. Maybe someone with more physics background could help me with this…



And maybe this nice guy could improve the ClothUtils class as well