Author Topic: Official Coding Resources Thread (02/29/2016)  (Read 50862 times)





Needs more perlin noise

I found code posted by Blocki about rotating a vector around an axis angle
I have no idea whether anyone actually has any use for this but here it is:
Code: [Select]
function rotatevector(vector, angleaxis)
{
%x = getword(%vector,0);
%y = getword(%vector,1);
%z = getword(%vector,2);
%u["x"] = getword(%angleaxis,0);
%u["y"] = getword(%angleaxis,1);
%u["z"] = getword(%angleaxis,2);
%angl = getword(%angleaxis,3) * -1;
%cos = mcos(%angl);
%sin = msin(%angl);
%a[1,1] = %cos + (%u["x"] * %u["x"] * (1 - %cos));
%a[1,2] = (%u["x"] * %u["y"] * (1 - %cos)) - (%u["z"] * %sin);
%a[1,3] = (%u["x"] * %u["z"] * (1 - %cos)) + (%u["y"] * %sin);
%a[2,1] = (%u["y"] * %u["x"] * (1 - %cos)) + (%u["z"] * %sin);
%a[2,2] = %cos + (%u["y"] * %u["y"] * (1 - %cos));
%a[2,3] = (%u["y"] * %u["z"] * (1 - %cos)) - (%u["x"] * %sin);
%a[3,1] = (%u["z"] * %u["x"] * (1 - %cos)) - (%u["y"] * %sin);
%a[3,2] = (%u["z"] * %u["y"] * (1 - %cos)) + (%u["x"] * %sin);
%a[3,3] = %cos + (%u["z"] * %u["z"] * (1 - %cos));
%newx = (%a[1,1] * %x) + (%a[1,2] * %y) + (%a[1,3] * %z);
%newy = (%a[2,1] * %x) + (%a[2,2] * %y) + (%a[2,3] * %z);
%newz = (%a[3,1] * %x) + (%a[3,2] * %y) + (%a[3,3] * %z);
return %newx SPC %newy SPC %newz;
}



Add this resource, because it's important for gamemodes: http://forum.blockland.us/index.php?topic=225595.0




In smart message make %type the actual command instead of that if statement, it allows for more flexibility.

In smart message make %type the actual command instead of that if statement, it allows for more flexibility.

More flexibility as in running your own functions through it?

« Last Edit: March 22, 2013, 05:40:02 PM by Evar678 »