PDA

View Full Version : Script for rotating/translating faces separately?


Lightweight
01-25-2011, 01:06 PM
Im working on a tiled floor at the moment, and instead of just putting a repeated tile texture w/ bump, Im modelling each tile.
What Im after is a script that could rotate/translate each mesh/tile a little little bit, just to add a bit more realism, so that their position, rotation and what not isn't so uniform as if snapping each tile to the grid.

I think I've seen one here before but I cant find it.

Much appreciated.

Lightweight
01-25-2011, 01:48 PM
I found a script which can randomly rotate your meshes to your specifications.


//Get selected objects $selObj = `ls -sl`;
//For each object
for($sel in $selObj)
{
//Generate a random number between -360 to 360
$randX = `rand -0.7 0.7`;
$randY = `rand -0.7 0.7`;
$randZ = `rand -0.7 0.7`;
//Rotate the current object to the random values
rotate -r -os $randX $randY $randZ $sel;
}

Geuse
01-25-2011, 02:00 PM
select tiles and run this


string $sel[] = `ls -long -type "transform" -sl`; for($each in $sel)
{
rotate -r 0 (rand(-1.5,1.5)) 0 $each;
}

whisperwing
02-02-2011, 04:19 AM
correct me if I'm wrong, but I assume that when you say a tiled floor, you have one or several big piece of mesh surfaces instead of a lot of disconnected polygons. If so I think it's easier to just add some random noise value to the vertex position and/or add noise to the normals of each face, so you won't have to change the UV set.

Im working on a tiled floor at the moment, and instead of just putting a repeated tile texture w/ bump, Im modelling each tile.
What Im after is a script that could rotate/translate each mesh/tile a little little bit, just to add a bit more realism, so that their position, rotation and what not isn't so uniform as if snapping each tile to the grid.

I think I've seen one here before but I cant find it.

Much appreciated.

Lightweight
02-02-2011, 03:51 PM
correct me if I'm wrong, but I assume that when you say a tiled floor, you have one or several big piece of mesh surfaces instead of a lot of disconnected polygons. If so I think it's easier to just add some random noise value to the vertex position and/or add noise to the normals of each face, so you won't have to change the UV set.

This got me interested in how to add random noise to the normals. A concept I've never really heard of. I am aware of the fact that if I rotate or scale a mesh, the UV does the same, but I didn't know about the noise thing, could you please clarify?

whisperwing
02-02-2011, 04:18 PM
uvs are per vertex attributes. Rotate/translate/scale a mesh will not change any of the vertex attribute in the mesh object space, that's why uvs will not change. Even when you tweak the vertices of the mesh, as long as the topology (connectivity information) doesn't change, you can still apply the same uv set if you want to. But tweaking vertices requires you to recalculate the normal. Or you can simply tweak the normals with random variations, so at render time the mesh will not look flat (that's basically the same idea as bump map in the first place).

CGTalk Moderation
02-02-2011, 04:18 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.