本文整理汇总了C++中Costume类的典型用法代码示例。如果您正苦于以下问题:C++ Costume类的具体用法?C++ Costume怎么用?C++ Costume使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Costume类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_getparam
void Lua_V2::SetActorTalkChore() {
lua_Object actorObj = lua_getparam(1);
lua_Object indexObj = lua_getparam(2);
lua_Object choreObj = lua_getparam(3);
lua_Object costumeObj = lua_getparam(4);
Costume *costume;
int chore;
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R') ||
!lua_isnumber(indexObj) ||
(!lua_isstring(choreObj) && !lua_isnil(choreObj))) {
return;
}
int index = (int)lua_getnumber(indexObj);
if (index < 1 || index > 16)
return;
Actor *actor = getactor(actorObj);
if (!findCostume(costumeObj, actor, &costume))
return;
if (lua_isnil(choreObj)) {
chore = -1;
} else {
const char * choreStr = lua_getstring(choreObj);
chore = costume->getChoreId(choreStr);
}
actor->setTalkChore(index, chore, costume);
}
示例2: lua_getparam
void Lua_V2::SetActorTurnChores() {
lua_Object actorObj = lua_getparam(1);
lua_Object leftChoreObj = lua_getparam(2);
lua_Object rightChoreObj = lua_getparam(3);
lua_Object costumeObj = lua_getparam(4);
Costume *costume;
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) {
return;
} else if (!lua_isnil(leftChoreObj) && !lua_isstring(leftChoreObj)) {
return;
} else if (!lua_isnil(rightChoreObj) && !lua_isstring(rightChoreObj)) {
return;
}
Actor *actor = getactor(actorObj);
if (!findCostume(costumeObj, actor, &costume))
return;
if (!costume) {
costume = actor->getCurrentCostume();
}
int leftChore = costume->getChoreId(lua_getstring(leftChoreObj));
int rightChore = costume->getChoreId(lua_getstring(rightChoreObj));
actor->setTurnChores(leftChore, rightChore, costume);
}
示例3: setColormap
void Actor::setColormap(const char *map) {
if (!_costumeStack.empty()) {
Costume *cost = _costumeStack.back();
cost->setColormap(map);
} else {
warning("Actor::setColormap: No costumes");
}
}
示例4: ofToString
void ofApp::onClap(int trackingId) {
cout<<trackingId<<" clapped!"<<endl;
Costume newCos;
newCos.initRandSensible(&segmentsLib);
std::string cosName = ofToString(trackingId);
newCos.setPositions(activeJointSets[trackingId].getVals());
costumesLib[cosName] = newCos;
activeCostumes.find(trackingId)->second = cosName;
}
示例5: fixFilename
Costume *ResourceLoader::loadCostume(const Common::String &filename, Costume *prevCost) {
Common::String fname = fixFilename(filename);
fname.toLowercase();
Common::SeekableReadStream *stream = openNewStreamFile(fname.c_str(), true);
if (!stream) {
error("Could not find costume \"%s\"", filename.c_str());
}
Costume *result;
if (g_grim->getGameType() == GType_MONKEY4) {
result = new EMICostume(filename, prevCost);
} else {
result = new Costume(filename, prevCost);
}
result->load(stream);
delete stream;
return result;
}
示例6: main
int main(int argc, char **argv) {
if(argc < 2){
std::cout << "Error: filename not specified" << std::endl;
return 0;
}
std::string filename = argv[1];
std::fstream file(filename.c_str(), std::ios::in | std::ios::binary);
if (!file.is_open()) {
std::cout << "Unable to open file " << filename << std::endl;
return 0;
}
Costume c;
c.readFromFile(file);
if (argc == 2) {
c.print();
} else {
c.printChore(argv[2]);
}
}
示例7: findCostume
bool Actor::restoreState(SaveGame *savedState) {
for (Common::List<Costume *>::const_iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
delete *i;
}
_costumeStack.clear();
// load actor name
_name = savedState->readString();
_setName = savedState->readString();
_talkColor = savedState->readColor();
_pos = savedState->readVector3d();
_pitch = savedState->readFloat();
_yaw = savedState->readFloat();
_roll = savedState->readFloat();
_walkRate = savedState->readFloat();
_turnRate = savedState->readFloat();
_constrain = savedState->readBool();
_reflectionAngle = savedState->readFloat();
_visible = savedState->readBool();
_lookingMode = savedState->readBool();
_scale = savedState->readFloat();
_timeScale = savedState->readFloat();
_puckOrient = savedState->readBool();
_talkSoundName = savedState->readString();
_talking = savedState->readBool();
_backgroundTalk = savedState->readBool();
if (isTalking()) {
g_grim->addTalkingActor(this);
}
_collisionMode = (CollisionMode)savedState->readLEUint32();
_collisionScale = savedState->readFloat();
if (savedState->readBool()) {
Common::String fn = savedState->readString();
_lipSync = g_resourceloader->getLipSync(fn);
} else {
_lipSync = NULL;
}
uint32 size = savedState->readLEUint32();
for (uint32 i = 0; i < size; ++i) {
Common::String fname = savedState->readString();
const int depth = savedState->readLESint32();
Costume *pc = NULL;
if (depth > 0) { //build all the previousCostume hierarchy
Common::String *names = new Common::String[depth];
for (int j = 0; j < depth; ++j) {
names[j] = savedState->readString();
}
for (int j = depth - 1; j >= 0; --j) {
pc = findCostume(names[j]);
if (!pc) {
pc = g_resourceloader->loadCostume(names[j], pc);
}
}
delete[] names;
}
Costume *c = g_resourceloader->loadCostume(fname, pc);
c->restoreState(savedState);
_costumeStack.push_back(c);
}
_turning = savedState->readBool();
_moveYaw = savedState->readFloat();
_walking = savedState->readBool();
_destPos = savedState->readVector3d();
_restChore.restoreState(savedState, this);
_walkChore.restoreState(savedState, this);
_walkedLast = savedState->readBool();
_walkedCur = savedState->readBool();
_leftTurnChore.restoreState(savedState, this);
_rightTurnChore.restoreState(savedState, this);
_lastTurnDir = savedState->readLESint32();
_currTurnDir = savedState->readLESint32();
for (int i = 0; i < 10; ++i) {
_talkChore[i].restoreState(savedState, this);
}
_talkAnim = savedState->readLESint32();
_mumbleChore.restoreState(savedState, this);
clearShadowPlanes();
for (int i = 0; i < MAX_SHADOWS; ++i) {
Shadow &shadow = _shadowArray[i];
shadow.name = savedState->readString();
shadow.pos = savedState->readVector3d();
size = savedState->readLEUint32();
Set *scene = NULL;
//.........这里部分代码省略.........
示例8: setYaw
//.........这里部分代码省略.........
}
if (_leftTurnChore.isValid()) {
if (_walkedCur || _walkedLast)
_currTurnDir = 0;
if (_restChore.isValid()) {
if (_currTurnDir != 0) {
if (getTurnChore(_currTurnDir)->isPlaying() && _restChore.isPlaying()) {
_restChore.stop(true, 500);
}
} else if (_lastTurnDir != 0) {
if (!_walkedCur && getTurnChore(_lastTurnDir)->isPlaying()) {
_restChore.playLooping(true);
}
}
}
if (_lastTurnDir != 0 && _lastTurnDir != _currTurnDir) {
getTurnChore(_lastTurnDir)->stop(true);
}
if (_currTurnDir != 0 && _currTurnDir != _lastTurnDir) {
getTurnChore(_currTurnDir)->playLooping(true, 500);
}
} else {
_currTurnDir = 0;
}
// The rest chore might have been stopped because of a
// StopActorChore(nil). Restart it if so.
if (!_walkedCur && _currTurnDir == 0 && !_restChore.isPlaying()) {
_restChore.playLooping(true);
}
_walkedLast = _walkedCur;
_walkedCur = false;
_lastTurnDir = _currTurnDir;
_currTurnDir = 0;
// Update lip syncing
if (_lipSync) {
int posSound;
// While getPosIn60HzTicks will return "-1" to indicate that the
// sound is no longer playing, it is more appropriate to check first
if (g_grim->getSpeechMode() != GrimEngine::TextOnly && g_sound->getSoundStatus(_talkSoundName.c_str()))
posSound = g_sound->getPosIn60HzTicks(_talkSoundName.c_str());
else
posSound = -1;
if (posSound != -1) {
int anim = _lipSync->getAnim(posSound);
if (_talkAnim != anim) {
if (anim != -1) {
if (_talkChore[anim].isValid()) {
stopMumbleChore();
if (_talkAnim != -1) {
_talkChore[_talkAnim].stop();
}
// Run the stop_talk chore so that it resets the components
// to the right visibility.
stopTalking();
_talkAnim = anim;
_talkChore[_talkAnim].play();
} else if (_mumbleChore.isValid() && !_mumbleChore.isPlaying()) {
_mumbleChore.playLooping();
_talkAnim = -1;
}
} else {
stopMumbleChore();
if (_talkAnim != -1)
_talkChore[_talkAnim].stop();
_talkAnim = 0;
stopTalking();
}
}
}
}
frameTime = (uint)(frameTime * _timeScale);
for (Common::List<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
Costume *c = *i;
c->setPosRotate(_pos, _pitch, _yaw, _roll);
int marker = c->update(frameTime);
if (marker > 0) {
costumeMarkerCallback(marker);
}
}
for (Common::List<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
Costume *c = *i;
c->animate();
}
for (Common::List<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
Costume *c = *i;
c->moveHead(_lookingMode, _lookAtVector);
}
}
示例9: getWorldPos
void Actor::draw() {
for (Common::List<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
Costume *c = *i;
c->setupTextures();
}
if (!g_driver->isHardwareAccelerated() && g_grim->getFlagRefreshShadowMask()) {
for (int l = 0; l < MAX_SHADOWS; l++) {
if (!_shadowArray[l].active)
continue;
g_driver->setShadow(&_shadowArray[l]);
g_driver->drawShadowPlanes();
g_driver->setShadow(NULL);
}
}
// FIXME: if isAttached(), factor in the joint & actor rotation as well.
Math::Vector3d absPos = getWorldPos();
if (!_costumeStack.empty()) {
g_grim->getCurrSet()->setupLights(absPos);
Costume *costume = _costumeStack.back();
for (int l = 0; l < MAX_SHADOWS; l++) {
if (!shouldDrawShadow(l))
continue;
g_driver->setShadow(&_shadowArray[l]);
g_driver->setShadowMode();
if (g_driver->isHardwareAccelerated())
g_driver->drawShadowPlanes();
g_driver->startActorDraw(absPos, _scale, _yaw, _pitch, _roll, _inOverworld, _alphaMode != AlphaOff ? _globalAlpha : 1.f);
costume->draw();
g_driver->finishActorDraw();
g_driver->clearShadowMode();
g_driver->setShadow(NULL);
}
bool isShadowCostume = costume->getFilename().equals("fx/dumbshadow.cos");
if (!isShadowCostume || _shadowActive) {
// normal draw actor
g_driver->startActorDraw(absPos, _scale, _yaw, _pitch, _roll, _inOverworld, _alphaMode != AlphaOff ? _globalAlpha : 1.f);
costume->draw();
g_driver->finishActorDraw();
}
}
if (_mustPlaceText) {
int x1, y1, x2, y2;
x1 = y1 = 1000;
x2 = y2 = -1000;
if (!_costumeStack.empty()) {
g_driver->startActorDraw(absPos, _scale, _yaw, _pitch, _roll, _inOverworld, 1.f);
_costumeStack.back()->getBoundingBox(&x1, &y1, &x2, &y2);
g_driver->finishActorDraw();
}
TextObject *textObject = TextObject::getPool().getObject(_sayLineText);
if (textObject) {
if (x1 == 1000 || x2 == -1000 || y2 == -1000) {
textObject->setX(640 / 2);
textObject->setY(463);
} else {
textObject->setX((x1 + x2) / 2);
textObject->setY(y1);
}
textObject->reset();
}
_mustPlaceText = false;
}
}
示例10: while
void Actor::saveState(SaveGame *savedState) const {
// store actor name
savedState->writeString(_name);
savedState->writeString(_setName);
savedState->writeColor(_talkColor);
savedState->writeVector3d(_pos);
savedState->writeFloat(_pitch.getDegrees());
savedState->writeFloat(_yaw.getDegrees());
savedState->writeFloat(_roll.getDegrees());
savedState->writeFloat(_walkRate);
savedState->writeFloat(_turnRate);
savedState->writeBool(_constrain);
savedState->writeFloat(_reflectionAngle);
savedState->writeBool(_visible);
savedState->writeBool(_lookingMode),
savedState->writeFloat(_scale);
savedState->writeFloat(_timeScale);
savedState->writeBool(_puckOrient);
savedState->writeString(_talkSoundName);
savedState->writeBool(_talking);
savedState->writeBool(_backgroundTalk);
savedState->writeLEUint32((uint32)_collisionMode);
savedState->writeFloat(_collisionScale);
if (_lipSync) {
savedState->writeBool(true);
savedState->writeString(_lipSync->getFilename());
} else {
savedState->writeBool(false);
}
savedState->writeLEUint32(_costumeStack.size());
for (Common::List<Costume *>::const_iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) {
Costume *c = *i;
savedState->writeString(c->getFilename());
Costume *pc = c->getPreviousCostume();
int depth = 0;
while (pc) {
++depth;
pc = pc->getPreviousCostume();
}
savedState->writeLESint32(depth);
pc = c->getPreviousCostume();
for (int j = 0; j < depth; ++j) { //save the previousCostume hierarchy
savedState->writeString(pc->getFilename());
pc = pc->getPreviousCostume();
}
c->saveState(savedState);
}
savedState->writeBool(_turning);
savedState->writeFloat(_moveYaw.getDegrees());
savedState->writeBool(_walking);
savedState->writeVector3d(_destPos);
_restChore.saveState(savedState);
_walkChore.saveState(savedState);
savedState->writeBool(_walkedLast);
savedState->writeBool(_walkedCur);
_leftTurnChore.saveState(savedState);
_rightTurnChore.saveState(savedState);
savedState->writeLESint32(_lastTurnDir);
savedState->writeLESint32(_currTurnDir);
for (int i = 0; i < 10; ++i) {
_talkChore[i].saveState(savedState);
}
savedState->writeLESint32(_talkAnim);
_mumbleChore.saveState(savedState);
for (int i = 0; i < MAX_SHADOWS; ++i) {
Shadow &shadow = _shadowArray[i];
savedState->writeString(shadow.name);
savedState->writeVector3d(shadow.pos);
savedState->writeLEUint32(shadow.planeList.size());
// Cannot use g_grim->getCurrSet() here because an actor can have walk planes
// from other scenes. It happens e.g. when Membrillo calls Velasco to tell him
// Naranja is dead.
for (SectorListType::iterator j = shadow.planeList.begin(); j != shadow.planeList.end(); ++j) {
Plane &p = *j;
savedState->writeString(p.setName);
savedState->writeString(p.sector->getName());
}
savedState->writeLESint32(shadow.shadowMaskSize);
savedState->write(shadow.shadowMask, shadow.shadowMaskSize);
savedState->writeBool(shadow.active);
savedState->writeBool(shadow.dontNegate);
}
//.........这里部分代码省略.........
示例11: getCurrentCostume
void Actor::pushCostume(const char *n) {
Costume *newCost = g_resourceloader->loadCostume(n, getCurrentCostume());
newCost->setColormap(NULL);
_costumeStack.push_back(newCost);
}
示例12: venues
//--------------------------------------------------------------
void ofApp::load(){
this->splashScreen.init("splashScreen.jpg");
this->splashScreen.begin();
//populate costumesLib map by going through venues directory recursively
//only works if the names of the files are exactly the same as those inside bonePairs in Costume.cpp
//will skip over missing files and simply not draw them
std::string venuesPath = "venues/";
ofDirectory venues(venuesPath);
venues.listDir();
//open venues dir
for(int i=0; i<venues.numFiles(); i++) {
ofDirectory venue(venues.getPath(i));
if(venue.isDirectory()) {
venue.listDir();
//open each venue dir
for(int j=0;j< venue.numFiles();j++) {
ofDirectory costume(venue.getPath(j));
if(costume.isDirectory()) {
//for each costume:
//costume.allowExt("dae"); //only look at .dae files (ie ignore texture files)
costume.listDir();
std::string cos; //initialize string to name the costume (will get the name late from the absolute path of each file so we have fewer calls to ofSplitString
std::vector<Segment> segs; //create a vector of segments for each costume that we will populate
//open each costume inside each venue
for(int k=0; k<costume.numFiles();k++) {
ofDirectory part(costume.getPath(k));
//initialize model loader for each model
ofxAssimpModelLoader model;
part.allowExt("dae");
part.listDir();
//load each .dae file
model.loadModel(part.getPath(0), true);
//save the meshes and textures for each file into blocks
vector<std::pair<ofMesh, ofTexture>> blocks;
for(int l=0;l<model.getMeshCount();l++) {
ofMesh mesh = model.getMesh(l); //get each mesh
ofTexture tex = model.getTextureForMesh(l); //get each texture
std::pair<ofMesh, ofTexture> block = make_pair(mesh, tex); //associate the two values
blocks.push_back(block); //add it to blocks vector
}
//sort name of each costume out
vector<std::string> splitString = ofSplitString(costume.getPath(k), "\\"); //split path string on "\" to get venue and costume names
cos = splitString[2];
std::vector<std::string> splitPart = ofSplitString(splitString[3], "."); //get the nameof the body part by splitting the string on "." to remove .dae extension
std::string partName = splitPart[0];
std::pair<std::string, std::string> pair = std::make_pair(cos, partName);
//initialize segment with meshes textures and location
Segment seg;
seg.init(blocks, partName);
segs.push_back(seg); //populate segs vector for this costume
segmentsLib[pair] = seg; // populate segments map for random costumes
}
//for each costume create a costume, initialize it with the loaded segments and save it to the costumesLib
Costume costume;
costume.init(cos);
costumesLib[cos] = costume;
preloadedCostumes.push_back(cos);
}
}
}
}
cout<<"List of all "<<costumesLib.size()<<" loaded costumes:"<<endl;
int i=1;
map<std::string, Costume>::iterator cos;
for(cos = costumesLib.begin(); cos != costumesLib.end(); cos++) {
cout<<i<<": "<<cos->first<<endl;
i++;
}
this->splashScreen.end();
loaded = true;
}