Jump to content

[SOLVED] setTexCoord0 not working


photo

Recommended Posts

Posted

Hello,

I am trying to update UV texture coordinates for a ObjectMeshStatic for each vertex in runtime.

Here is my code for now :

const auto value = ...;
const int num_vertices = mesh->getNumVertex(0);
for (int i = 0; i < num_vertices; i++)
{
    auto tex = mesh->getTexCoord0(i,0);
    tex.y = value;
    mesh->setTexCoord0(i, tex, 0);
}

setTextCoord0 seems to have no effect visually on the mesh.

Is there anything I am doing wrong?

Is there anyway I can use a UV transform which corresponds to the mesh and not the material?

Thanks

Posted

Hi @silent,

By saving the mesh you mean saving it as a .mesh file using the saveMesh method?

Normally, the uv coordinates are updated in realtime, writing the mesh into disk on each drawcall can reduce the performance.

Posted

If you need to update coordinates in runtime you can try to use ObjectMeshDynamic instead.

You can also use expressions for the UV transforms in runtime. For example, in order to simulate some simple animations (like texture sliding across the mesh or scaling):

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Multiple meshes (with the same material) can have different UV transforms. I think the solution is to use a ObjectMeshDynamic instead.

I will try this and get back to you to keep you up to date :) Thanks.

Posted

It works!

I used an ObjectMeshDynamic instead, updated the UV texCoords and called flushVertex at each frame.

Thanks again.

Posted

Even better! I retried the static mesh and just added flushMesh at the end of the update method and it worked.

  • silent changed the title to [SOLVED] setTexCoord0 not working
×
×
  • Create New...