void zz_bone::apply_channel_by_frame (int frame, zz_motion * motion, float blend_weight) { assert(motion && "apply_channel_by_frame"); assert(blend_weight >= 0.0f && blend_weight <= 1.0f && "apply_channel_by_frame"); // the pelvis bone may use both the position and rotation channel. if (position_channel_index >= 0) { zz_assertf(position_channel_index < motion->get_num_channels(), "[%s]-[%s]-[%d]-[%f]pos", get_name(), motion->get_path(), position_channel_index, blend_weight); if (blend_weight < 1.0f) { // if use blend_weight vec3 last_position = position; motion->get_channel_data(position_channel_index, frame, &position); position = znzin->motion_tool.blend_position(last_position, position, blend_weight); } else { // no blend motion->get_channel_data(position_channel_index, frame, &position); } } if (rotation_channel_index >= 0) { // CAUTION: DO NOT INSERT *else* zz_assertf(position_channel_index < motion->get_num_channels(), "[%s]-[%s]-[%d]-[%f]rot", get_name(), motion->get_path(), position_channel_index, blend_weight); if (blend_weight < 1.0f) { // if use blend_weight quat last_rotation = rotation; motion->get_channel_data(rotation_channel_index, frame, &rotation); rotation = znzin->motion_tool.blend_rotation(last_rotation, rotation, blend_weight); } else { motion->get_channel_data(rotation_channel_index, frame, &rotation); } } }
bool zz_texture::set_path (const char * path_in) { const char * last_path = file_name.get(); zz_assert(path_in); zz_assertf(znzin->file_system.exist(path_in), "[%s] file not found\n", path_in); // not to rename old zz_assertf(file_name.get() == 0, "rename [%s] failed", file_name.get()); // set path file_name.set(path_in); //file_name.set("etc/shadowover.dds"); // request to open and delayed-load. autu-closed in renderer_d3d->download_texture() #ifdef USE_VFS_THREAD_TEXTURE_LOADING file_handle = znzin->vfs_thread->open(path_in); // will be closed in destructor or download_texture() #endif // set weight by file size // CAUTION: only for vfs_local or vfs_pkg const int average_filesize = 100000; // 100 KB const int load_byte_per_msec = 1000; // 1 KB #if (1) int filesize = znzin->file_system.get_size(path_in); load_weight = 1 + filesize/load_byte_per_msec; // 1(minimum size) + 1ms/10000byte #endif res.make_ready(); // Just setting path is enough to be loaded. return true; }
bool zz_vfs_pkg::open (const char * filename_in, const zz_vfs_mode mode) { if(mode==ZZ_VFS_WRITE) return false; //ZZ_LOG("vfs_pkg:open(%s)\n", filename); //ZZ_PROFILER_INSTALL(vfs_pkg_open); zz_assert(filename_in); zz_assert(filename_in[0]); zz_slash_converter filename(filename_in); if (fp_) { close(); } assert(!fp_); if (!pkg_system_) { ZZ_LOG("vfs_pkg: open(%s) failed. invalid pkg_system_.\n", filename.get()); return false; } //ZZ_LOG("vfs_pkg: open(%s)\n", filename); VHANDLE fsystem = pkg_system_->get_filesystem(); // switch (mode) { // case zz_vfs::ZZ_VFS_READ: fp_ = VOpenFile(filename, fsystem); zz_assertf( fp_, "vfs_pkg: open(%s) failed.", filename.get() ); filename_.set(filename); //check if it is encrypted fp_->btEncrypted=0; //if(fp_->btFileType==0){ size_t spt; spt = fp_->sFileName.find_last_of("/\\"); std::string hashstring1 = fp_->sFileName.substr(spt+1, (fp_->sFileName.length()-spt)); //OutputDebugString(hashstring1.c_str()); unsigned long key = StrToHashKey(hashstring1.c_str()); char crypttable[16]; DWORD *EAX=reinterpret_cast<DWORD*>(crypttable); DWORD EDI=0; DWORD ECX = key; DWORD EDX = key+1; ECX = ECX*4+1; for(int i = 0; i < 4; i++) { EDI=ECX*EDX; *((DWORD*)EAX) = EDI; EAX++; ECX+=4; EDX++; } vfseek(fp_, 0, VFSEEK_END); long off_set = vftell(fp_); if(off_set>16) { off_set-=16; vfseek(fp_,off_set, VFSEEK_SET); char buffer[16]; vfread(&buffer,1,16,fp_); if(buffer[0]==crypttable[0]){ if(buffer[1]==crypttable[1]){ if(buffer[2]==crypttable[2]){ if(buffer[3]==crypttable[3]){ if(buffer[4]==crypttable[4]){ if(buffer[5]==crypttable[5]){ if(buffer[6]==crypttable[6]){ if(buffer[7]==crypttable[7]){ if(buffer[8]==crypttable[8]){ if(buffer[9]==crypttable[9]){ if(buffer[10]==crypttable[10]){ if(buffer[11]==crypttable[11]){ if(buffer[12]==crypttable[12]){ if(buffer[13]==crypttable[13]){ if(buffer[14]==crypttable[14]){ if(buffer[15]==crypttable[15]){ fp_->btEncrypted=0x90; fp_->lEndOff-=16; //MessageBox(0,fp_->sFileName.c_str()," is encrypted",0); } } } } } } } } } } } } } } } } } vfseek(fp_,0, VFSEEK_SET); // break; // case zz_vfs::ZZ_VFS_WRITE: // not implemented yet!!! // break; // } if (!fp_) { return false; } return true; }