Try this:
Code:
material* mtl1;
function mtl_copy(mtl_source)
{
mtl1 = mtl_source;
vec_set(mtl.ambient_blue,mtl1.ambient_blue);
vec_set(mtl.specular_blue,mtl1.specular_blue);
vec_set(mtl.diffuse_blue,mtl1.diffuse_blue);
vec_set(mtl.emissive_blue,mtl1.emissive_blue);
mtl.power = mtl1.power;
}
// 5-state machine for texture shifting and scaling
function mtl_rolleye_1();
function mtl_rolleye_2()
{
mtl.skill1 -= time; // shift eyeball right
if (mtl.skill1 < 0) { mtl.event = mtl_rolleye_1; }
mtl.matrix13 = floatd(mtl.skill1,500); // u offset
}
function mtl_rolleye_1()
{
mtl.skill1 += time; // shift eyeball left
if (mtl.skill1 > 50) { mtl.event = mtl_rolleye_2; }
mtl.matrix13 = floatd(mtl.skill1,500); // u offset
}
function mtl_eye_init()
{
// copy standard model material properties
mtl_copy(mat_model);
mtl.matrix11 = float(1); // default u scale
mtl.matrix22 = float(1); // default v scale
mtl.event = mtl_rolleye_1;
mtl.enable_view = on;
}
material auge_mdl
{
event = mtl_eye_init;
effect = "
matrix matMtl;
technique scale
{
// use material transformation matrix, leave everything else at default values
pass p0
{
TextureTransformFlags[0] = Count2;
TextureTransform[0] = <matMtl>;
}
}
technique fallback { pass p0 { } }
";
}
action eye {
my.material = auge_mdl;
}