Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  import and export blueprint property values in script
#3
Dedo arriba 
josemendez

Note it is trivial to write your own method that reads an existing texture at runtime, outside of the editor. All you need to do is iterate over all vertices in the mesh, read the texel value at the vertex uv coordinate, and then map the value to any property/range you need. For instance:

Code:
void Read(Texture2D input, ObiMeshBasedActorBlueprint blueprint)
{
            Vector2[] uvs = blueprint.inputMesh.uv;

            // Iterate over all vertices in the mesh reading back colors from the texture:
            for (int i = 0; i <  blueprint.inputMesh.vertexCount; ++i)
            {

                    int particleIndex = blueprint.topology.rawToWelded[i];
                    var color = input.GetPixelBilinear(uvs[i].x, uvs[i].y));

                   // map the color to any property you want:
                   blueprint.principalRadii[particleIndex] = color.r  * 10;
            }
}

Thanks @josemendez. that is what i was looking for 
It seems i can directly write particle parameter values on a texture map. I'll test the idea soon.
 
In the meantime, can you please help me to understand a few more things about the code?
  • Q1> does it mean that ObiCloth will generate the same number of particles as inputMesh.vertexCount? (I thought it would create a sparse set of particles by approximating the input mesh)
  • Q2> what is rawToWelded? I can find the name in the class reference but cannot find what it is.
Probably fundamental concepts but I cannot find any useful information from the class reference Triste

Many thanks!
Reply


Messages In This Thread
RE: import and export blueprint property values in script - by joe smith - 13-09-2021, 10:15 PM