majinosity Posted August 2, 2014 Posted August 2, 2014 This is just a simple console application I've been fooling around with to create quick "random" generation of facial animations to a file 1.txt. Face.exe file sits in the Skyrim Data folder (you open it once and it stays open). It opens the 1.txt file and randomly generates phoneme, a few modifiers (only blink and look direction right now), and expression. From the Skyrim console, with a character selected, you run "bat 1" to change expression. With my very limited C++ knowledge this is a very crude attempt, but I think a few people might be interested in the idea or have a better solution or mod to replicate what I'm trying to do. An example of a randomly generated expression set: mfg resetmfg phoneme 12 84mfg phoneme 10 20mfg phoneme 6 70mfg modifier 0 8mfg modifier 1 8mfg modifier 2 0mfg modifier 3 0mfg modifier 4 0mfg modifier 5 0mfg modifier 6 0mfg modifier 7 0mfg modifier 8 77mfg modifier 11 0mfg modifier 9 0mfg modifier 10 0mfg modifier 12 0mfg modifier 13 0mfg modifier 14 0mfg modifier 15 0mfg modifier 16 0mfg expression 4 11 Here is what I do to run the program quickly: Run Face.exe in the background Setup 2 keyboard macros One for swapping windows (from Skyrim to app, app and back) Another keyboard macro to type " ` bat 1 <enter> ` " this opens my console in game types bat 1, hits enter, and then closes console. Within 4 quick keystrokes I have a brand new, random facial expression. Some of the results are obviously horrible, but others I have saved to use for future screenshots. Let me know your thoughts? Here is the exe: Face.rar If you don't feel comfortable downloading an exe (here is my C++ source so you can compile yourself) #include "stdafx.h" #include <iostream> #include <fstream> #include <stdio.h> #include <stdlib.h> #include <time.h> using namespace std; int getRandomNumber(void) { return rand(); } int getRandomNumberRanged(int base, int limit) { return rand() % (limit - base + 1) + base; } int main () { while (true) { //This repeats the program. You close console window manually by clicking "x". system ("CLS"); //this will clear the screen of any text from prior run cin.clear(); //this will clear any values remain in cin from prior run srand ( (unsigned int)time(NULL) ); ofstream myfile; myfile.open ("1.txt"); myfile << "mfg reset\n"; //baseline int x = 0; //how heavy the experession should be (0-100) int expIntensity; //total expression "points", will be able to set in future int expPoints; //how many phoneme attributes there should be total (1-15) int expRange; //Inside the loop, select a random expression (1-15) int expSelector; expRange = getRandomNumberRanged(1, 15); expPoints = getRandomNumberRanged(1, 1500); while( x < expRange ) { expSelector = getRandomNumberRanged(1, 15); if ( expPoints > 0 ) { expIntensity = getRandomNumberRanged(0, 100); expPoints = expPoints - expIntensity; } else { expIntensity = 0; } if ( expPoints > 0 ) { myfile << "mfg phoneme "; myfile << expSelector; myfile << " "; myfile << expIntensity; myfile << "\n"; } x++; } int eyeClose = getRandomNumberRanged(1,30); int leftRight = getRandomNumberRanged(1, 3); int leftRightIntensity = getRandomNumberRanged(1, 100); int upDown = getRandomNumberRanged(1, 3); int upDownIntensity = getRandomNumberRanged(1, 100); int expExp = getRandomNumberRanged(1, 100); myfile << "mfg modifier 0 " << eyeClose << " \n"; myfile << "mfg modifier 1 " << eyeClose << " \n"; myfile << "mfg modifier 2 0 \n"; myfile << "mfg modifier 3 0 \n"; myfile << "mfg modifier 4 0 \n"; myfile << "mfg modifier 5 0 \n"; myfile << "mfg modifier 6 0 \n"; myfile << "mfg modifier 7 0 \n"; if ( upDown == 1 ) { myfile << "mfg modifier 8 " << upDownIntensity << " \n"; myfile << "mfg modifier 11 0 \n"; } if ( upDown == 2 ) { myfile << "mfg modifier 8 0 \n"; myfile << "mfg modifier 11 " << upDownIntensity << " \n"; } if ( upDown == 3 ) { myfile << "mfg modifier 8 0 \n"; myfile << "mfg modifier 11 0 \n"; } if ( leftRight == 1 ) { myfile << "mfg modifier 9 " << leftRightIntensity << " \n"; myfile << "mfg modifier 10 0 \n"; } if ( leftRight == 2 ) { myfile << "mfg modifier 9 0 \n"; myfile << "mfg modifier 10 " << leftRightIntensity << " \n"; } if ( leftRight == 3 ) { myfile << "mfg modifier 9 0 \n"; myfile << "mfg modifier 10 0 \n"; } myfile << "mfg modifier 12 0 \n"; myfile << "mfg modifier 13 0 \n"; myfile << "mfg modifier 14 0 \n"; myfile << "mfg modifier 15 0 \n"; myfile << "mfg modifier 16 0 \n"; myfile << "mfg expression " << expRange << " " << expExp; myfile.close(); system ("PAUSE"); } // this ends while loop return 0; } // this ends your main function. Feel free to suggest edits as I'm sure this code is complete rubbish
Recommended Posts
Archived
This topic is now archived and is closed to further replies.