Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// Normal and specular map applier script for Kemono - Body (v.1.13.25+)
// If you want to use this with any other version of the M3 head or the venus head or the kemono body or whatever, you will need to figure out the link names and face numbers and replace them in the script.
string specmap = "<UUID goes here>"; // your specular map UUID
vector repeats = <20, 20, 0>; // horizontal and vertical repeats
vector offsets = <0, 0, 0>; // horizontal and vertical offsets
float rot = 0.0; // texture angle
integer gloss = 51; // glossiness
integer env = 0; // environment reflection
vector color = <1.000, 1.000, 1.000>; // specular color
key normal = "<UUID goes here>"; // your normal map UUID
vector Nrepeats = <1, 1, 0>; // horizontal and vertical repeats for normals
vector Noffsets = <0, 0, 0>; // horizontal and vertical offsets for normals
float Nrot = 0.0; // texture angle for normals
// change this if kemono body link names / face numbers change
applySpecMaps() {
// "link_name", [face_1, face_2, ...]
applyLinkSpec("arms", [0, 1, 2, 3, 4, 5, 6, 7]);
applyLinkSpec("neck", [0, 1, 2, 3, 4, 5, 6, 7]);
applyLinkSpec("hips", [0, 1, 2, 3, 4, 5, 6, 7]);
applyLinkSpec("body", [0, 1, 2, 3, 4, 5, 6, 7]);
applyLinkSpec("Lhand", [0, 1, 2, 3, 4]);
applyLinkSpec("Rhand", [0, 1, 2, 3, 4]);
applyLinkSpec("handR", [ALL_SIDES]);
applyLinkSpec("handL", [ALL_SIDES]);
applyLinkSpec("LFleg", [0, 1, 2, 3, 4, 5, 6]);
applyLinkSpec("LHleg", [0, 1, 2, 3, 4, 5, 6]);
applyLinkSpec("RFleg", [0, 1, 2, 3, 4, 5, 6]);
applyLinkSpec("RHleg", [0, 1, 2, 3, 4, 5, 6]);
applyLinkSpec("PG", [0, 1, 2, 3]);
}
list HAND_LINK_NAMES = ["handL", "handR", "Lhand", "Rhand"];
// Shouldn't have to edit below here.
integer LINK_NONE = -99;
integer getNumberOfPrims() {
return (llGetObjectPrimCount(llGetKey()) + llGetNumberOfPrims() * !!llGetAttached());
}
integer getLinkNum(string link_name) {
if (link_name == "MAIN_PRIM") {
return LINK_ROOT;
}
integer prim_count = getNumberOfPrims();
integer link = 1;
do {
if(llGetLinkName(link) == link_name)
return link;
}
while(link++ < prim_count);
return LINK_NONE;
}
applyLinkSpec(string link_name, list faces) {
integer link_num = getLinkNum(link_name);
if (link_num == LINK_NONE) {
// only warn if it's not a hand link, these names changed between
// bento / non-bento
if (llListFindList(HAND_LINK_NAMES, [link_name]) == -1) {
llOwnerSay("Couldn't find " + link_name + " link???");
}
return;
}
integer i;
for(i=0; i<llGetListLength(faces); ++i) {
integer face_num = llList2Integer(faces, i);
llSetLinkPrimitiveParamsFast(link_num, [
PRIM_SPECULAR, face_num, specmap, repeats, offsets, rot, color, gloss, env,
PRIM_ALPHA_MODE, face_num, 0, 0,
PRIM_NORMAL, face_num, normal, Nrepeats, Noffsets, Nrot
]);
}
}
default {
state_entry() {
applySpecMaps();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment