2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
mtl.matrix problems?
#44832
04/24/05 19:55
04/24/05 19:55
|
Joined: Dec 2003
Posts: 1,097 Maryland, USA
Steempipe
OP
Serious User
|
OP
Serious User
Joined: Dec 2003
Posts: 1,097
Maryland, USA
|
I was sitting down to do some scaling and shifting. Gstudio 6.31.4 Pro. When I ran into a situation where I could only scale the texture "hardcoded" into the effect file. Here are (2) level blocks. Left one is using material floor_two. Right one is using material floor_one. They are identical texture images. They are only different in the way I attempt scaling. Could you advise?? It follows. Thanks, Eric Code:
var d3d_automaterial=1;
function mtl_scale() {
mtl.matrix11 = float(10); mtl.matrix12 = float(0); mtl.matrix13 = float(0); mtl.matrix14 = float(0);
mtl.matrix21 = float(0); mtl.matrix22 = float(10); mtl.matrix23 = float(0); mtl.matrix24 = float(0);
mtl.matrix31 = float(0); mtl.matrix32 = float(0); mtl.matrix33 = float(0); mtl.matrix34 = float(0);
mtl.matrix41 = float(0); mtl.matrix42 = float(0); mtl.matrix43 = float(0); mtl.matrix44 = float(0);
}
material floor_one {
effect = "
texture entSkin1;
technique one {
pass p0 {
Texture[0] = (entSkin1); TextureTransformFlags[0] = Count2;
TextureTransform[0]= { 10.0, 0.0, 0.0, 0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
Colorop[0] = Modulate; ColorArg1[0]=Texture; ColorArg2[0] = Diffuse; ColorOp[1] = Disable;
} }
"; }
////////////////////////////////////////////////// // Material Floor_Two //
material floor_two { event = mtl_scale;
effect = "
matrix matMtl; texture entSkin1;
technique one {
pass p0 {
Texture[0] = (entSkin1); TextureTransformFlags[0] = Count2;
TextureTransform[0] = (matMtl);
Colorop[0] = Modulate; ColorArg1[0]=Texture; ColorArg2[0] = Diffuse; ColorOp[1] = Disable;
} }
"; }
|
|
|
Re: mtl.matrix problems?
[Re: Rigoletto]
#44838
04/26/05 20:57
04/26/05 20:57
|
Joined: Dec 2003
Posts: 1,097 Maryland, USA
Steempipe
OP
Serious User
|
OP
Serious User
Joined: Dec 2003
Posts: 1,097
Maryland, USA
|
No prob, man. Glad that you are taking a keen interest in these things Rigoletto. Okay.... if it helps anyone else, here is some code to spark ideas. What is it??: An example to allow a bit of user interaction with a material effect applied to level geometry. This example is very simple; It shows a bit of scaling and shifting of the block texture. Code:
////////////////////////////////////////////////// // Example of adjusting the material.matrix // while using an FX file on _Level Geometry_. // Enlists the help of a Starter Function to // call additional functions. // // Here we adjust the scale with key 2, or key 4 // And also make it scroll in a direction. // // Eric Hendrickson-Lambert (Steempipe) // // 4/26/04: -Put into operation // // Todo: -Add more examples, etc. // -Tighten up code //
var d3d_automaterial=1;
//bind <ffp_scale.fx>;
// Material assignment for the level geometry // The name of the texture in WED. material floor_one {
// Because my effect file is not too long, // I will just use the effect string inside the material. // NOTE: If you use <effect_load>, then take // the effect string out of here.
effect = "
matrix matMtl; texture entSkin1;
technique one {
pass p0 {
Texture[0] = <entSkin1>;
TextureTransformFlags[0] = Count2; TexCoordIndex[0]=0; //1
TextureTransform[0] = <matMtl>;
Colorop[0] = Modulate; ColorArg1[0]=Texture; ColorArg2[0] = Diffuse;
} } ";
}
function load_shader() { //effect_load(floor_one,"ffp_scale.fx"); wait(1); }
function scale_x2() {
floor_one.matrix11 = float(2); floor_one.matrix22 = float(2);
}; function scale_x4() {
floor_one.matrix11 = float(4); floor_one.matrix22 = float(4);
};
function scroll_tex() {
floor_one.skill1 -= time; floor_one.matrix31 = floatd(floor_one.skill1,500); floor_one.matrix32 = floatd(floor_one.skill1,500);
}
starter floor_init {
// Set a default texture scale // floor_one.matrix11 = float(1); floor_one.matrix22 = float(1);
//floor_one.skill1 = 50;
// Pressing key 2 will scale texture x2 // Pressing key 4 will scale texture x4 while(1) { if (key_2) { scale_x2(); };
if (key_4) {scale_x4(); };
scroll_tex();
wait(1); }
}
|
|
|
Re: mtl.matrix problems?
[Re: Steempipe]
#44839
05/16/05 15:09
05/16/05 15:09
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
I dont get it =\ I have created a map entity with a texture assigned... I copied the code, wrote a main with a load_level... And then? Should it work when I press 2 or 4? nothing happens when I press them. Jostie
Last edited by Jostie; 05/16/05 15:12.
|
|
|
Re: mtl.matrix problems?
[Re: Steempipe]
#44841
05/16/05 19:01
05/16/05 19:01
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Now THAT explains a lot... HURRAY!!! It works Big thanx! Jostie p.s. Keep it going with your tutorials, they are great for noobs like me
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
|