Пример #1
0
		MetadataTypes() {
			mapType(MetadataElement::FIELD, "FIELD");
			mapType(MetadataElement::ARRAY, "ARRAY");
			mapType(MetadataElement::LIST, "LIST");
			mapType(MetadataElement::MAP, "MAP");
			mapType(MetadataElement::KEY, "KEY");
		}
Пример #2
0
int CMPI_term_el::toStrings (
    CMPIType & typ,
    CMPIPredOp & opr, String & o1,String & o2) const
{

    opr = op;
    o1 = opn1.getTypeValue ();
    o2 = opn2.getTypeValue ();
    if (opn1.getType () == CMPI_QueryOperand::PROPERTY_TYPE)
        typ = mapType (opn2.getType ());
    else
        typ = mapType (opn1.getType ());
    return 0;
}
Пример #3
0
/**
 * @brief Write the variables stored in the object.
 * @param object Object containing the variables.
 * @param pex Binary to decompile.
 */
void Decompiler::PscCoder::writeVariables(const Pex::Object &object, const Pex::Binary &pex)
{
    for (auto& var : object.getVariables())
    {
        auto name = var.getName().asString();
        bool compilerGenerated = (name.size() > 2 && name[0] == ':' && name[1] == ':');
        auto stream = indent(0);

        if (compilerGenerated)
            stream << "; ";

        stream << mapType(var.getTypeName().asString()) << " " << name;
        auto initialValue = var.getDefaultValue();
        if (initialValue.getType() != Pex::ValueType::None)
        {
            stream << " = " << initialValue.toString();
        }
        writeUserFlag(stream, var, pex);
        if (var.getConstFlag())
            stream << " Const";

        if (m_CommentAsm || !compilerGenerated)
        {
            write(stream);
        }
    }
}
Пример #4
0
string& VTDROutPoweredRecord::Dump(string& buf)
{
	stringstream stream;
	stream << VTDRRecord::Dump(buf) << " RecTime:" << ctime(&tTime);
	stream << " RecType:" << decodeType[mapType(cType)];
	return buf = stream.str();
}
Пример #5
0
void bankManager::loadSynth(ofxXmlSettings & XML, ofPtr<triggerZone> z){
    
    vector<synthParam> defSp = synthDictionary::getSynthParams(z->getSynthType());
    
    
    for(int i = 0; i < defSp.size(); i++){
        
        
        synthParam sp = defSp[i];
        
        if(XML.pushTag(defSp[i].name)){
            
            sp.abs_val = XML.getValue("ABS_VAL", defSp[i].abs_val);
            sp.min_val = XML.getValue("MIN_VAL", defSp[i].min_val);
            sp.max_val = XML.getValue("MAX_VAL", defSp[i].max_val);
            sp.map = mapType(XML.getValue("MAP", defSp[i].map));
            
            z->setSynthParam(i, sp);
            
            XML.popTag();
        }
        
    }


}
Пример #6
0
QAbstractButton *Dialog::getButton(ButtonCode button) {
    QDialogButtonBox::StandardButton mapped = mapType(button);
    QAbstractButton *b = QDialogButtonBox::NoButton == mapped ? 0 : buttonBox->button(mapped);
    if (!b && userButtons.contains(button)) {
        b = userButtons[button];
    }
    return b;
}
Пример #7
0
string& VTDRDriverIDRecord::Dump(string& buf)
{
	stringstream stream;
	stream << VTDRRecord::Dump(buf) << " Time:" << Time2String(tStart) << endl;
	stream << "LICIENCE:" << strLicenseNumber.c_str();
	stream << ",Type:" << decodeType[mapType(cType)] << "(" << (int)cType << ")" << endl;
	return buf = stream.str();
}
Пример #8
0
/**
* @brief Map the type name used by the compiler to the form most used by people.
* @param type The type to map.
*/
std::string Decompiler::PscCoder::mapType(std::string type)
{
    if (type.length() > 2 && type[type.length() - 2] == '[' && type[type.length() - 1] == ']')
        return mapType(type.substr(0, type.length() - 2)) + "[]";
    auto lowerType = type;
    boost::algorithm::to_lower(lowerType);
    auto a = prettyTypeNameMap.find(lowerType);
    if (a != prettyTypeNameMap.end())
        return a->second;
    return type;
}
Пример #9
0
double PMTextureMapBase::mapValue( const PMObject* obj ) const
{
   PMObject* o = firstChild( );
   QValueList<double>::ConstIterator it = m_mapValues.begin( );

   while( o && ( o != obj ) )
   {
      if( o->type( ) == mapType( ) )
         ++it;
      o = o->nextSibling( );
   }
   return *it;
}
Пример #10
0
QValueList<double>::Iterator PMTextureMapBase::valueForChild( PMObject* obj )
{
   PMObject* o = firstChild( );
   QValueList<double>::Iterator it = m_mapValues.begin( );

   while( o && ( o != obj ) )
   {
      if( o->type( ) == mapType( ) )
         ++it;
      o = o->nextSibling( );
   }
   return it;
}
Пример #11
0
void testApp::synthEvents(ofxUIEventArgs &e){
    
    string name = e.widget->getName();
    int id = e.widget->getID();
    
    synthParam sp = m_bankManager->getCurrentZone()->getSynthParam(id);
    
    if(name == "abs_val"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        sp.abs_val = slider->getScaledValue();
    }
    
    if(name == "min_val"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        sp.min_val = slider->getScaledValue();
    }
    
    if(name == "max_val"){
        ofxUISlider *slider = (ofxUISlider *) e.widget;
        sp.max_val = slider->getScaledValue();
    }
    
    if(isMouseDown){
        if(name == "MINUS"){
            sp.map = mapType(max(0, sp.map - 1));
            mapTypeLabels[id]->setTextString("MAP_TYPE: " + synthDictionary::getMapString(sp.map));
            
        }
        
        if(name == "PLUS"){
            sp.map = mapType(min((int)MT_COUNT - 1, (int)sp.map + 1));
            mapTypeLabels[id]->setTextString("MAP_TYPE: " + synthDictionary::getMapString(sp.map));
        }
    }
    
    m_bankManager->setCZoneSynthParam(id, sp);
    
}
Пример #12
0
/**
* @brief Write the struct member passed in.
* @param member The member to output.
* @param pex Binary to decompile.
*/
void Decompiler::PscCoder::writeStructMember(const Pex::StructInfo::Member& member, const Pex::Binary& pex)
{
    auto stream = indent(1);
    stream << mapType(member.getTypeName().asString()) << " " << member.getName();

    if (member.getValue().getType() != Pex::ValueType::None) {
        stream << " = " << member.getValue().toString();
    }
    writeUserFlag(stream, member, pex);
    if (member.getConstFlag())
        stream << " Const";
    write(stream);
    writeDocString(1, member);
}
Пример #13
0
PMObject* PMTextureMapBase::nextMapEntry( PMObject* o )
{
   bool stop = false;
   PMObject* result = o;

   do
   {
      if( result == 0 )
         result = firstChild( );
      else
         result = result->nextSibling( );

      if( !result )
         stop = true;
      else if( result->type( ) == mapType( ) )
         stop = true;
   }
   while( !stop );

   return result;
}
Пример #14
0
/**
* @brief Write the property definition.
* @param i The indent level.
* @param prop The property to write.
* @param object Object containing the properties definitions.
* @param pex Binary to decompile.
*/
void Decompiler::PscCoder::writeProperty(int i, const Pex::Property& prop, const Pex::Object &object, const Pex::Binary& pex)
{
    auto stream = indent(i);
    auto isAutoReadOnly = !prop.hasAutoVar() &&
                          prop.isReadable() &&
                          !prop.isWritable() &&
                          prop.getReadFunction().getInstructions().size() == 1 &&
                          prop.getReadFunction().getInstructions()[0].getOpCode() == Pex::OpCode::RETURN &&
                          prop.getReadFunction().getInstructions()[0].getArgs().size() == 1;
    stream << mapType(prop.getTypeName().asString()) << " Property " << prop.getName();
    if (prop.hasAutoVar()) {
        auto var = object.getVariables().findByName(prop.getAutoVarName());
        if (var == nullptr)
            throw std::runtime_error("Auto variable for property not found");

        auto initialValue = var->getDefaultValue();
        if (initialValue.getType() != Pex::ValueType::None)
            stream << " = " << initialValue.toString();
        stream << " Auto";

        // The flags defined on the variable must be set on the property
        writeUserFlag(stream, *var, pex);
        if (var->getConstFlag())
            stream << " Const";
    } else if (isAutoReadOnly) {
        stream << " = " << prop.getReadFunction().getInstructions()[0].getArgs()[0].toString();
        stream << " AutoReadOnly";
    }
    writeUserFlag(stream, prop, pex);
    write(stream);
    writeDocString(i, prop);

    if (!prop.hasAutoVar() && !isAutoReadOnly) {
        if (prop.isReadable())
            writeFunction(i + 1, prop.getReadFunction(), object, pex, "Get");
        if (prop.isWritable())
            writeFunction(i + 1, prop.getWriteFunction(), object, pex, "Set");
        write(indent(i) << "EndProperty");
    }
}
Пример #15
0
void makeCmDir(struct cmChrom *chromList, char *outDir, struct hash *minorityHash)
/* Make directory full of goodies corresponding to chromList. */
{
struct cmChrom *chrom;
struct cmContig *contig;
struct slName *line;
struct cloneInfo *ci;
struct cloneLine *cl;
int isOrdered;
FILE *info;
FILE *geno;
FILE *map;
char *s;
int i;
struct hash *noDupCloneHash = newHash(0);

mustMakeDir(outDir);
mustChangeDir(outDir);
for (chrom = chromList; chrom != NULL; chrom = chrom->next)
    {
    if (sameString(chrom->name, "COMMIT"))
	continue;
    if (isFinChrom(chrom->name))
	{
	printf("Skipping finished %s\n", chrom->name);
        continue;
	}
    printf("Writing chromosome %s", chrom->name);
    fflush(stdout);
    makeDir(chrom->name);
    mustChangeDir(chrom->name);
    for (isOrdered = 1; isOrdered >= 0; --isOrdered)
	{
	contig = (isOrdered ? chrom->orderedList : chrom->randomList);
	for ( ; contig != NULL; contig = contig->next)
	    {
	    printf(".");
	    fflush(stdout);
	    if (makeDir(contig->name))
		{
		mustChangeDir(contig->name);
		info = mustOpen("info.noNt", "w");
		geno = mustOpen("geno.lst.noNt", "w");
		map = mustOpen("map", "w");
		if (contig->ntList != NULL)
		    writeNtList("nt.noNt", contig);
		fprintf(info, "%s %s\n", contig->name, 
		    mapType(chrom->name, isOrdered));

		for (line = contig->lineList; line != NULL; line = line->next)
		    fprintf(map, "%s\n", line->name);
		for (cl = contig->cloneList; cl != NULL; cl = cl->next)
		    {
		    ci = cl->clone;
		    if (!suppressMinority(minorityHash, ci, contig))
			{
			if (!hashLookup(noDupCloneHash, ci->acc))
			    {
			    hashAdd(noDupCloneHash, ci->acc, NULL);
			    if (ci->dir != NULL)
				{
				fprintf(info, "%s %d %d\n", ci->acc, ci->pos, ci->phase);
				fprintf(geno, "%s/%s.fa\n", ci->dir, ci->acc);
				}
			    else if (ci->phase != 0)
				{
			        warn("No sequence file for %s\n", ci->acc);
				fprintf(errLog, "No sequence file for %s\n", ci->acc);
				}
			    }
			}
		    }
		fclose(info);
		fclose(geno);
		fclose(map);
		mustChangeDir("..");
		}
	    }
	}
    mustChangeDir("..");
    printf("\n");
    }
hashFree(&noDupCloneHash);
}
Пример #16
0
u32 Map::timerUpdate(float uptime, float unload_timeout, u32 max_loaded_blocks,
                     unsigned int max_cycle_ms,
                     std::vector<v3POS> *unloaded_blocks) {
	bool save_before_unloading = (mapType() == MAPTYPE_SERVER);

	// Profile modified reasons
	Profiler modprofiler;

	if (/*!m_blocks_update_last && */ m_blocks_delete->size() > 1000) {
		m_blocks_delete = (m_blocks_delete == &m_blocks_delete_1 ? &m_blocks_delete_2 : &m_blocks_delete_1);
		verbosestream << "Deleting blocks=" << m_blocks_delete->size() << std::endl;
		for (auto & ir : *m_blocks_delete)
			delete ir.first;
		m_blocks_delete->clear();
		getBlockCacheFlush();
	}

	u32 deleted_blocks_count = 0;
	u32 saved_blocks_count = 0;
	u32 block_count_all = 0;

	u32 n = 0, calls = 0, end_ms = porting::getTimeMs() + max_cycle_ms;

	std::vector<MapBlockP> blocks_delete;
	int save_started = 0;
	{
		auto lock = m_blocks.try_lock_shared_rec();
		if (!lock->owns_lock())
			return m_blocks_update_last;

#if !ENABLE_THREADS
		auto lock_map = m_nothread_locker.try_lock_unique_rec();
		if (!lock_map->owns_lock())
			return m_blocks_update_last;
#endif

		for(auto ir : m_blocks) {
			if (n++ < m_blocks_update_last) {
				continue;
			} else {
				m_blocks_update_last = 0;
			}
			++calls;

			auto block = ir.second;
			if (!block)
				continue;

			{
				auto lock = block->try_lock_unique_rec();
				if (!lock->owns_lock())
					continue;
				if(block->getUsageTimer() > unload_timeout) { // block->refGet() <= 0 &&
					v3POS p = block->getPos();
					//infostream<<" deleting block p="<<p<<" ustimer="<<block->getUsageTimer() <<" to="<< unload_timeout<<" inc="<<(uptime - block->m_uptime_timer_last)<<" state="<<block->getModified()<<std::endl;
					// Save if modified
					if (block->getModified() != MOD_STATE_CLEAN && save_before_unloading) {
						//modprofiler.add(block->getModifiedReasonString(), 1);
						if(!save_started++)
							beginSave();
						if (!saveBlock(block))
							continue;
						saved_blocks_count++;
					}

					blocks_delete.push_back(block);

					if(unloaded_blocks)
						unloaded_blocks->push_back(p);

					deleted_blocks_count++;
				} else {

#ifndef SERVER
					if (block->mesh_old)
						block->mesh_old = nullptr;
#endif

					if (!block->m_uptime_timer_last)  // not very good place, but minimum modifications
						block->m_uptime_timer_last = uptime - 0.1;
					block->incrementUsageTimer(uptime - block->m_uptime_timer_last);
					block->m_uptime_timer_last = uptime;

					block_count_all++;

					/*#ifndef SERVER
									if(block->refGet() == 0 && block->getUsageTimer() >
											g_settings->getFloat("unload_unused_meshes_timeout"))
									{
										if(block->mesh){
											delete block->mesh;
											block->mesh = NULL;
										}
									}
					#endif*/
				}

			} // block lock

			if (porting::getTimeMs() > end_ms) {
				m_blocks_update_last = n;
				break;
			}

		}
	}
	if(save_started)
		endSave();

	if (!calls)
		m_blocks_update_last = 0;

	for (auto & block : blocks_delete)
		this->deleteBlock(block);

	// Finally delete the empty sectors

	if(deleted_blocks_count != 0) {
		if (m_blocks_update_last)
			infostream << "ServerMap: timerUpdate(): Blocks processed:" << calls << "/" << m_blocks.size() << " to " << m_blocks_update_last << std::endl;
		PrintInfo(infostream); // ServerMap/ClientMap:
		infostream << "Unloaded " << deleted_blocks_count << "/" << (block_count_all + deleted_blocks_count)
		           << " blocks from memory";
		infostream << " (deleteq1=" << m_blocks_delete_1.size() << " deleteq2=" << m_blocks_delete_2.size() << ")";
		if(saved_blocks_count)
			infostream << ", of which " << saved_blocks_count << " were written";
		/*
				infostream<<", "<<block_count_all<<" blocks in memory";
		*/
		infostream << "." << std::endl;
		if(saved_blocks_count != 0) {
			PrintInfo(infostream); // ServerMap/ClientMap:
			//infostream<<"Blocks modified by: "<<std::endl;
			modprofiler.print(infostream);
		}
	}
	return m_blocks_update_last;
}
Пример #17
0
    int GoogleMapView::getMapTile(uint64 p_zoom, uint64 p_row, uint64 p_column, void** p_data, size_t* p_size) {
     
        void *data = NULL;
        size_t datasize = 0;

        String url = "";//cmd->baseUrl;
        
        int zoom = (int)p_zoom;
        
        
        uint64 pow2 = rho_math_pow2(zoom);
        
        double current_width_in_pixels = (double)(pow2 * (TILE_SIZE));
        double current_height_in_pixels = (double)(pow2 * (TILE_SIZE));
        
        double tile_center_x_in_pixels = (double)(p_column*(TILE_SIZE)+((TILE_SIZE)/2));
        double tile_center_y_in_pixels = (double)(p_row*(TILE_SIZE)+((TILE_SIZE)/2));
        
        double center_latitude = pixelsToDegreesY((uint64)tile_center_y_in_pixels, zoom);//((double)-90.0) + ((current_height_in_pixels - tile_center_y_in_pixels)/(current_height_in_pixels))*((double)180.0);
        double center_longitude = pixelsToDegreesX((uint64)tile_center_x_in_pixels, zoom);//((double)-180.0) + ((tile_center_x_in_pixels)/(current_width_in_pixels))*((double)360.0);
        
        
        // Make url
        char buf[1024];
        
        // Open Street Map
        //snprintf(buf, sizeof(buf), "http://a.tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png", zoom, (int)p_column, (int)p_row);
        
        // Google Map
        snprintf(buf, sizeof(buf), "http://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=%d&size=256x280&scale=1&maptype=%s&format=png&sensor=false&mobile=true", center_latitude, center_longitude, zoom, mapType().c_str());
        
        // Google Map on Blackberry
        
        // StringBuffer url = new StringBuffer();
        // url.append("http://maps.google.com/maps/api/staticmap?");
        // url.append("center=" + Double.toString(latitude) + "," + Double.toString(longitude));
        // url.append("&zoom=" + cmd.zoom);
        // url.append("&size=" + cmd.width + "x" + cmd.height);
        // url.append("&maptype=" + cmd.maptype);
        // url.append("&format=png&sensor=false");
        // url.append("&mobile=" + (cmd.maptype.equals("roadmap") ? "true" : "false"));
        // url.append("&key=" + mapkey);
        // String finalUrl = url.toString();
        
        // byte[] data = fetchData(finalUrl);
        
        
        url += buf;
        
        if (!fetchData(url, &data, &datasize))
            return 0;

        *p_data = data;
        *p_size = datasize;
        
        return 1;
        
    }
NS_IMETHODIMP
nsAppletHTMLObject::Initialize(nsIPluginInstancePeer *peer)
{
  nsresult res;
  OJI_LOG("nsAppletHTMLObject::Initialize");
  m_peer = peer;
  NS_ADDREF(m_peer);
  peer->QueryInterface(kIPluginInstancePeer2IID,
                       (void **)&m_peer2);
  m_jobject = new nsJavaHTMLObject(m_factory);
  NS_ADDREF(m_jobject);
  res = nsServiceManager::GetService(kPluginManagerCID, 
				     kIPluginManagerIID,
				     getter_AddRefs(m_mgr));
  if (NS_FAILED(res)) return res;
  m_id = 0;
  if (NS_FAILED(res = m_factory->GetJVM(&m_jvm)))          return res;
  if (NS_FAILED(res = m_jvm->GetJNIEnv(&m_env)))           return res;
  if (NS_FAILED(res = m_jobject->Initialize(peer, m_jvm))) return res;
  // find out applet information from our peer and explain it 
  // to nsJavaHTMLObject
  // in new API nsJavaHTMLObject should get everything needed
  // from peer
  nsJavaObjectInfo* info = 
    new nsJavaObjectInfo((nsIWFInstanceWrapper*)this);
  NS_ADDREF(info);
  nsIPluginTagInfo *tagInfo;
  if (NS_SUCCEEDED(res = peer->QueryInterface(kIPluginTagInfoIID,
					      (void **)&tagInfo)))
    {
      PRUint16 argc = 0, i;
      char **keys, **vals;
      tagInfo->GetAttributes(argc, (const char* const* &)keys, 
			     (const char* const* &) vals);
      for (i=0; i<argc; i++) 
	info->AddParameter(keys[i], vals[i]);
      NS_RELEASE(tagInfo);
    }
  
  nsIPluginTagInfo2 *extTagInfo;
  if (NS_SUCCEEDED(res = peer->QueryInterface(kIPluginTagInfo2IID, 
					      (void **)&extTagInfo)))
    {
      nsPluginTagType tagType = nsPluginTagType_Unknown;
      if (NS_SUCCEEDED(extTagInfo->GetTagType(&tagType)))
        {
          if (tagType == nsPluginTagType_Applet || 
              tagType == nsPluginTagType_Object) 
	    {
	      PRUint16 argc = 0, i;
	      char **keys, **vals;
	      extTagInfo->GetParameters(argc, 
					(const char*const*&)keys,
					(const char*const*&) vals); 
	      for (i=0; i<argc; i++) 
		info->AddParameter(keys[i], vals[i]);
	    }
	  nsJavaObjectType type = mapType(tagType);
	  info->SetType(type);
	  if (NS_FAILED(res = m_jobject->SetType(type)))
	    return res;
        }
      const char *docbase = NULL;
      if (NS_FAILED(res = extTagInfo->GetDocumentBase(&docbase)))
	{
	  OJI_LOG("Failed to obtain doc base");
	}
      if (docbase != NULL) 
	{
	  char *slash = strrchr((char*)docbase, '/');
	  if (slash != NULL) *(slash+1) = 0;
	  OJI_LOG2("real docbase is %s", docbase);
	  info->SetDocBase(docbase);
        }            
      NS_RELEASE(extTagInfo);
    }
  // really it's crucial to call SetType() _before_ passing Java object info
  // otherwise parameters will be passed to wrapper - and silently ignored
  res = m_jobject->SetJavaObjectInfo(info);
  NS_RELEASE(info);
  return res;
}
Пример #19
0
Bool ApplinkExporter::Execute(BaseDocument* document, BaseContainer* bc)
{
	matDefault = BaseMaterial::Alloc(Mmaterial);
	if(!matDefault) return false;

	Filename fileObjPath;
	fileObjPath.SetDirectory(bc->GetString(IDC_TMP_FOLDER));
	fileObjPath.SetFile(document->GetDocumentName());
	fileObjPath.SetSuffix("obj");
	Filename fileObjOutPath;
	fileObjOutPath.SetDirectory(bc->GetString(IDC_TMP_FOLDER));
	fileObjOutPath.SetFile("output.obj");
	Filename fileImport;
	fileImport.SetDirectory(bc->GetString(IDC_EXCH_FOLDER));
	fileImport.SetFile("import.txt");

	GePrint(fileObjPath.GetString());
	GePrint(fileObjOutPath.GetString());
	GePrint(fileImport.GetString());

	const Matrix tM(LVector(0.0f, 0.0f, 0.0f), LVector(1.0f, 0.0f, 0.0f), LVector(0.0f, 1.0f, 0.0f), LVector(0.0f, 0.0f, -1.0f));

	//BaseDocument* doc = document->Polygonize();
	AutoAlloc<AtomArray> oSel;
	document->GetActiveObjects(oSel, GETACTIVEOBJECTFLAGS_0);

	if(oSel->GetCount() > 0)
	{
//Write import.txt//
		AutoAlloc<BaseFile> basefileImport;
		
		if (!basefileImport->Open(fileImport, FILEOPEN_WRITE, FILEDIALOG_NONE, GeGetByteOrder())) return FALSE;
		
		this->WriteString(fileObjPath.GetString() + "\n", basefileImport);
		this->WriteString(fileObjOutPath.GetString() + "\n", basefileImport);
		this->WriteString(mapType(bc->GetLong(IDC_COMBO_MAP_TYPE)) + "\n", basefileImport);

		Bool bSkipImp = bc->GetBool(IDC_CHK_SKIP_IMP_DIALOG);

		if(bSkipImp)
		{
			this->WriteString("[SkipImport]\n", basefileImport);
		}

		Bool bSkipExp = bc->GetBool(IDC_CHK_SKIP_EXP_DIALOG);

		if(bSkipExp)
		{
			this->WriteString("[SkipExport]\n", basefileImport);
		}

		GePrint(mapType(bc->GetLong(IDC_COMBO_MAP_TYPE)));
		basefileImport->Close();

		GePrint("File " + fileImport.GetString() + " write success!");

//Write file.obj//
		AutoAlloc<BaseFile> objfile;

		//if (!objfile) return FALSE;
		if (!objfile->Open(fileObjPath, FILEOPEN_WRITE, FILEDIALOG_NONE, GeGetByteOrder())) return FALSE;

		String str;
		str = "#Wavefront OBJ Export for 3D-Coat\n";
		this->WriteString(str, objfile);
		DateTime t;
		GetDateTimeNow(t);
		str = "#File created: " + FormatTime("%d.%m.%Y  %H:%M:%S", t) + "\n";
		this->WriteString(str, objfile);
		str = "#Cinema4D Version: " + LongToString(GetC4DVersion()) + "\n";
		this->WriteString(str, objfile);
		this->WriteEndLine(objfile);

		Bool expMat = bc->GetBool(IDC_CHK_EXP_MAT);
		vpcnt = vtcnt = 0;

		for(int i = 0; i < oSel->GetCount(); i++)
		{
			StatusSetSpin();
			PolygonObject* ob = (PolygonObject*) oSel->GetIndex(i);
			if (ob->GetType() == Opolygon)
			{
				StatusSetText("Export object " + ob->GetName());
				ExportObject mObject;

				GePrint("Name " + ob->GetName());
				//GePrint("Type " + LongToString(ob->GetType()));

				if(expMat)
				{
					mObject.pmatidxArray.ReSize(ob->GetPolygonCount());
					mObject.tempMats.ReSize(1);
					mObject.pmatidxArray.Fill(0);
					Bool haveMats = false;
	//////////////////////////////////////////
					for(BaseTag* tag = ob->GetFirstTag(); tag != NULL; tag = tag->GetNext())
					{
						LONG typ = tag->GetType();
						if(typ == Ttexture)
						{
							if (!getParameterLink(*tag, TEXTURETAG_MATERIAL, Mbase)) continue;
						
							haveMats = true;
							TextureTag* txttag = (TextureTag*)tag;
							BaseMaterial* material = txttag->GetMaterial();

							if(material == NULL)
							{
								GePrint("Material not found on " + ob->GetName() + "object.");
								return false;
							}
							//GePrint("Mat Name: " + material->GetName());						

							String restrict = getParameterString(*tag, TEXTURETAG_RESTRICTION);
							if (restrict.Content())
							{
								mObject.tempMats.Push(material);
								//GePrint("Selection: " + restrict);
								for(BaseTag* seltag = ob->GetFirstTag(); seltag != NULL; seltag = seltag->GetNext())
								{
									LONG seltyp = seltag->GetType();
									if(seltyp == Tpolygonselection && seltag->GetName() == restrict)
									{
										SelectionTag* selecttag = (SelectionTag*)seltag;
										BaseSelect* sel = selecttag->GetBaseSelect();
										//GePrint("sel data count: " + LongToString(sel->GetCount()));

										LONG seg = 0, a, b, p;
										while (sel->GetRange(seg++, &a, &b))
										{
											for (p = a; p <= b; ++p)
											{
												//GePrint("seltpolygon: " + LongToString(p));
												mObject.pmatidxArray[p] = mObject.tempMats.GetCount()-1;
											}
										}
									}
								}
							}
							else
							{
								mObject.tempMats[0] = material;
								mObject.pmatidxArray.Fill(0);
							}
						}
					}

					if(!mObject.tempMats[0])
					{
						matDefault->SetName("Default");

						BaseChannel* color = matDefault->GetChannel(CHANNEL_COLOR);
						if (!color) return false;	// return some error
						BaseContainer cdata = color->GetData();
						cdata.SetVector(BASECHANNEL_COLOR_EX, Vector(1.0f, 1.0f, 1.0f));
						
						//document->InsertMaterial(matDefault, NULL, FALSE);
						//matDefault->Update(TRUE, TRUE);
						//matDefault->Message(MSG_UPDATE);

						mObject.tempMats[0] = matDefault;
						//GePrint("Global material not found on object " + ob->GetName() + ".");
						//return false;
					}

					if(haveMats)
					{
						//GePrint("mObject.tempMats.GetCount(): " + LongToString(mObject.tempMats.GetCount()));
						for(LONG m = 0; m < mObject.tempMats.GetCount(); m++)
						{
							Bool inMats = false;
							//GePrint("materialArray.GetCount(): " + LongToString(materialArray.GetCount()));
							for(LONG n = 0; n < materialArray.GetCount(); n++)
							{
								if(mObject.tempMats[m]->GetName() == materialArray[n]->GetName())
								{
									inMats = true;
									break;
								}
							}
							if(!inMats)
							{
								materialArray.Push(mObject.tempMats[m]);
							}
						}
					}

					//String str1;
					//for (LONG p = 0; p < ob->GetPolygonCount(); p++)
					//{
					//	str1 += LongToString(mObject.pmatidxArray[p]) + ",";
					//}
					//GePrint(str1);
				}
/////////////////////////////////////////////////
				const Vector* vadr = ob->GetPointR();
				const CPolygon* padr = ob->GetPolygonR();
				LONG vcnt = ob->GetPointCount();
				LONG pcnt = ob->GetPolygonCount();

				mObject.Fpvnb.ReSize(pcnt);// poly counts
				for(LONG p = 0; p < pcnt; p++)
				{
					if(padr[p].c != padr[p].d)
					{
						mObject.Fpvnb[p] = 4;
					}
					else
					{
						mObject.Fpvnb[p] = 3;
					}
				}
				mObject.pVertexCount = PVertexLength(mObject);

				//Vertex positions
				mObject.Vp.ReSize(vcnt);
				Matrix mg = tM * ob->GetMgn();
				for (LONG v = 0; v < vcnt; v++)
				{
					mObject.Vp[v] = vadr[v] * mg;
					//GePrint("Point[" + LongToString(i) + "] " + LongToString(padr[i].x) + ", " + LongToString(padr[i].y) + ", " + LongToString(padr[i].z));
					//str = "v " + LongToString(vadr[p].x) + " " + LongToString(vadr[p].y) + " " + LongToString(vadr[p].z) + "\n";
					//this->WriteString(str, objfile);
				}
				
				mObject.Fv.ReSize(mObject.pVertexCount);
				LONG y=0;
				for (LONG p = 0; p < pcnt; p++)
				{
					if(mObject.Fpvnb[p] == 4)
					{
						mObject.Fv[y] = padr[p].d;
						mObject.Fv[y+1] = padr[p].c;
						mObject.Fv[y+2] = padr[p].b;
						mObject.Fv[y+3] = padr[p].a;
					}
					else
					{
						mObject.Fv[y] = padr[p].c;
						mObject.Fv[y+1] = padr[p].b;
						mObject.Fv[y+2] = padr[p].a;
					}

					y += mObject.Fpvnb[p];
				}
				
				//String str1;
				//for (LONG p = 0; p < mObject.Fv.GetCount(); p++)
				//{
				//	str1 += LongToString(mObject.Fv[p]) + " ";
				//}
				//GePrint(str1);
///////////////////////////////
///////////vertex UV
//////////////////////////////
				if(bc->GetBool(IDC_CHK_EXP_UV))
				{
					// Get first UV tag (if at least one)
					UVWTag* uvw_tag = (UVWTag*)ob->GetTag(Tuvw, 0);
					if(!uvw_tag)
					{
						GePrint("Object \"" + ob->GetName() + "\" has no UVW tag.\nUV coordinates can't be exported.");
						return FALSE;
					}
					else
					{
						mObject.Vt.ReSize(mObject.pVertexCount);
						mObject.Fvt.ReSize(mObject.pVertexCount);						
						const UVWHandle dataptr = uvw_tag->GetDataAddressR();
						UVWStruct res;
						
						for(LONG t=0, y=0; t < pcnt; t++)
						{
							//GePrint("y: " + LongToString(y));
							UVWTag::Get(dataptr, t, res);
							if(mObject.Fpvnb[t] == 4)
							{
								mObject.Vt[y] = res.d;
								mObject.Vt[y + 1] = res.c;
								mObject.Vt[y + 2] = res.b;
								mObject.Vt[y + 3] = res.a;
							
								mObject.Fvt[y] = y;
								mObject.Fvt[y + 1] = y + 1;
								mObject.Fvt[y + 2] = y + 2;
								mObject.Fvt[y + 3] = y + 3;

							}
							else
							{
								mObject.Vt[y] = res.c;
								mObject.Vt[y + 1] = res.b;
								mObject.Vt[y + 2] = res.a;

								mObject.Fvt[y] = y;
								mObject.Fvt[y + 1] = y + 1;
								mObject.Fvt[y + 2] = y + 2;

							}
							y += mObject.Fpvnb[t];
						}
					}
					//String str1;
					//for (LONG p = 0; p < mObject.Fvt.GetCount(); p++)
					//{
					//	str1 += LongToString(mObject.Fvt[p]) + " ";
					//}
					//GePrint(str1);

				}

				WriteExportFile(bc, ob, objfile, mObject, vcnt, pcnt);
				//GePrint("Fvt: " + LongToString(Fvt.GetCount()));
				vpcnt += mObject.Vp.GetCount();
				if(bc->GetBool(IDC_CHK_EXP_UV))
					vtcnt += mObject.Vt.GetCount();
			}
		}
		objfile->Close();

		if(expMat && materialArray.GetCount() > 0)
			WriteMatsFile(document, bc);
	}
	else
	{
		GePrint("No selected objects!");
	}

	BaseMaterial::Free(matDefault);
	return TRUE;
}
Пример #20
0
/**
 * @brief Decompile a function.
 * @param i The indentation level.
 * @param function The function to decompile.
 * @param object The Object containing the function.
 * @param pex Binary to decompile.
 * @param name Name of the function. This parameter override the name stored in the function object.
 */
void Decompiler::PscCoder::writeFunction(int i, const Pex::Function &function, const Pex::Object& object, const Pex::Binary &pex, const std::string &name)
{
    std::string functionName = name;

    if (functionName.empty())
    {
        functionName = function.getName().asString();
    }

    bool isEvent = functionName.size() > 2 && !_stricmp(functionName.substr(0, 2).c_str(), "on");
    if (functionName.size() > 9 && !_stricmp(functionName.substr(0, 9).c_str(), "::remote_")) {
        isEvent = true;
        functionName = functionName.substr(9);
        functionName[function.getParams()[0].getTypeName().asString().size()] = '.';
    }

    if (functionName != "GetState" && functionName != "GotoState")
    {
        auto stream = indent(i);
        if (_stricmp(function.getReturnTypeName().asString().c_str(), "none") != 0)
            stream << mapType(function.getReturnTypeName().asString()) << " ";

        if (isEvent)
            stream << "Event ";
        else
            stream << "Function ";
        stream << functionName << "(";

        auto first = true;
        for (auto& param : function.getParams())
        {
            if (first)
            {
                first = false;
            }
            else
            {
                stream << ", ";
            }
            stream << mapType(param.getTypeName().asString()) << " " << param.getName();
        }
        stream << ")";

        if (function.isGlobal())
        {
            stream << " global";
        }
        if (function.isNative())
        {
            stream << " native";
        }
        writeUserFlag(stream, function, pex);
        write(stream);

        writeDocString(i, function);

        if (! function.isNative())
        {
            for (auto& line : PscDecompiler(function, object, m_CommentAsm))
            {
                write(indent(i+1) << line);
            }
            if (isEvent)
                write(indent(i) << "EndEvent");
            else
                write(indent(i) << "EndFunction");
        }
    }
    else
    {
        write(indent(i) << "; Skipped compiler generated " << functionName);
    }
}