So i tried to create all objects in GameInit and hide them - it works but i rather dont want to do that. And then i changed texture UV mapping and it is not working also.
I mean, when i change UV for my object in GameInit procedure, then it works but after that, changes i made have no effect at all, it stays like i set them when initialising. Is there any method to update texture so engine knows there are new UV coords?
With new UV coords i am changing texture too, and it iworks good but with old UV.
And this is my procedure
- Code: Select all
private BrumeSquareTextured[,] gameGrid;
private void resize()
{
for (int i = 0; i < boardWidth; i++)
{
float posx = i * 20 - boardWidth * 9 + 0.5f;
for (int j = 0; j < boardHeight; j++)
{
float posy = j * 20 - boardHeight * 16 + 0.0f;
this.gameGrid[j, i].RenderStates.Texture[0] = game.GetTexture(number+".jpg");
BrumeSquareMeshTextured b = (BrumeSquareMeshTextured)this.gameGrid[j, i].Mesh;
float yy = boardHeight - j - 1;
float vu = 1 / (float)boardWidth;
float vv = 1 / (float)boardHeight;
b.vertices[0].Tu = i * vu;
b.vertices[0].Tv = yy * vv;
b.vertices[1].Tu = i * vu + vu;
b.vertices[1].Tv = yy * vv;
b.vertices[2].Tu = i * vu;
b.vertices[2].Tv = yy * vv + vv;
b.vertices[3].Tu = i * vu + vu;
b.vertices[3].Tv = yy * vv + vv;
this.gameGrid[j, i].Mesh = b;
this.gameGrid[j, i].Pos.X = posx;
this.gameGrid[j, i].Pos.Y = posy;
this.gameGrid[j, i].Pos.Z = 1.0f;
this.gameGrid[j, i].Size = 19.98f;
}
}
}
And this is supposed to be puzzle game, so i created few planes with different coordinates of the same texture (dunno better solution for now) - they have to be different mesh because they are animated.
resize() is called always when user change board size, it works when i call resize() from overrided GameInit() but after that it is not working. Do i miss something?