Пример #1
0
static float AsFloat(const Util::String &v){
    if (v.IsValidFloat()) {
        return v.AsFloat();
    }
    
    if (v == Util::String("MAX")) {
        return FLT_MAX;
    }else if(v == Util::String("MIN")){
        return FLT_MIN;
    }
    
    return 0;
}
Пример #2
0
void TemplateLoader::LoadType<Record::SBaseRange>(Ptr<IO::XmlReader> &xmlReader, Record::SBaseRange &ref, const Util::StringAtom &attr, Component::TemplateContainer &container){
    Util::String value = xmlReader->GetString(attr.Value());
    Util::Array<Util::String> vectors;
    value.Tokenize(Util::String(","), vectors);
    switch (vectors.Size()) {
        case 2:
            ref.range = vectors[1].AsInt();
        case 1:
            ref.base = vectors[0].AsInt();
        default:
            break;
    }
}
Пример #3
0
void TemplateLoader::LoadType<Record::SActorTerm>(Ptr<IO::XmlReader> &xmlReader, Record::SActorTerm &ref, const Util::StringAtom &attr, Component::TemplateContainer &container){
    Util::String value = xmlReader->GetString(attr.Value());
    Util::Array<Util::String> vectors;
    value.Tokenize(Util::String(" "), vectors);
    switch (vectors.Size()) {
        case 2:
            ref.value = vectors[1];
        case 1:
            ref.type = EEActorTermType::Value(vectors[0]);
        default:
            break;
    }
}
Пример #4
0
void TemplateLoader::LoadType<Record::SFloatRangeMirror>(Ptr<IO::XmlReader> &xmlReader, Record::SFloatRangeMirror &ref, const Util::StringAtom &attr, Component::TemplateContainer &container){
    Util::String value = xmlReader->GetString(attr.Value());
    Util::Array<Util::String> vectors;
    value.Tokenize(Util::String(","), vectors);
    switch (vectors.Size()) {
        case 4:
            ref.positiveMin = AsFloat(vectors[3]);
        case 3:
            ref.positiveMax = AsFloat(vectors[2]);
        case 2:
            ref.negtiveMin = AsFloat(vectors[1]);
        case 1:
            ref.negtiveMax = AsFloat(vectors[0]);
        default:
            break;
    }
}
Пример #5
0
void TemplateLoader::LoadType<Record::SColor>(Ptr<IO::XmlReader> &xmlReader, Record::SColor &ref, const Util::StringAtom &attr, Component::TemplateContainer &container){
    Util::String value = xmlReader->GetString(attr.Value());
    Util::Array<Util::String> colors;
    value.Tokenize(Util::String(","), colors);
    switch (colors.Size()) {
        case 4:
            ref.a = colors[3].AsInt();
        case 3:
            ref.b = colors[2].AsInt();
        case 2:
            ref.g = colors[1].AsInt();
        case 1:
            ref.r = colors[0].AsInt();
        default:
            break;
    }
}
Пример #6
0
void TemplateLoader::LoadType<Record::STargetFilters>(Ptr<IO::XmlReader> &xmlReader, Record::STargetFilters &ref,
                                                          const Util::StringAtom &attr, Component::TemplateContainer &container){
    
    Util::String value = xmlReader->GetString(attr.Value());
    Util::Array<Util::String> filterGroups;
    value.Tokenize(Util::String(";"), filterGroups);
    for (IndexT gpIdx = 0; gpIdx < filterGroups.Size(); ++gpIdx) {
        const Util::String& filters = filterGroups[gpIdx];
        if (filters != "-" && filters.Length() > 0) {
            Record::ETargetFilterState state = (Record::ETargetFilterState)(gpIdx);
            Util::Array<Util::String> filtersToTarget;
            filters.Tokenize(Util::String(","), filtersToTarget);
            for (IndexT filterIdx = 0; filterIdx < filtersToTarget.Size(); ++filterIdx) {
                Record::ETargetFilter filter = Record::EETargetFilter::Value(filtersToTarget[filterIdx]);
                ref.Filters.Add(filter, state);
            }
        }
    }
}
	//--------------------------------------------------------------------
	Util::String Nebula3Writer::generaterNodeName(const COLLADAFW::Node* node)
	{
		static int nodeCount = 0;
		static Util::String nodeName = "DEFAULT_NODENAME_";
		Util::String nodeNameStr;
		if( !node->getName().empty() ) 
		{
			nodeNameStr = node->getName().c_str();			
		}
		else if( !node->getOriginalId().empty())
		{
			nodeNameStr = node->getOriginalId().c_str();
		}
		else
		{
			nodeNameStr = nodeName;
			nodeNameStr.AppendInt(++nodeCount);
		}
		return nodeNameStr;
	}
Пример #8
0
void TemplateLoader::LoadType<Record::SRotator>(Ptr<IO::XmlReader> &xmlReader, Record::SRotator &ref, const Util::StringAtom &attr, Component::TemplateContainer &container){
    Util::String value = xmlReader->GetString(attr.Value());
    Util::Array<Util::String> vectors;
    value.Tokenize(Util::String(","), vectors);
    switch (vectors.Size()) {
        case 3:
            ref.pitch = AsFloat(vectors[2]);
            ref.roll = AsFloat(vectors[1]);
            ref.yaw = AsFloat(vectors[0]);
            break;
        case 2:
            ref.roll = AsFloat(vectors[1]);
            ref.yaw = AsFloat(vectors[0]);
            break;
        case 1:
            float vf = AsFloat(vectors[0]);
            ref.roll = ref.yaw = ref.pitch = vf;
            break;
    }
}
        ResponseCode OpenSSLConnection::WriteInternal(const util::String &buf, size_t &size_written_bytes_out) {
            int error_code = 0;
            int select_retCode = -1;
            int cur_written_length = 0;
            size_t total_written_length = 0;
            ResponseCode rc = ResponseCode::SUCCESS;
            fd_set write_fds;
            size_t bytes_to_write = buf.length();
            struct timeval timeout = {tls_write_timeout_.tv_sec, tls_write_timeout_.tv_usec};

            do {
                cur_written_length = SSL_write(p_ssl_handle_, buf.c_str(), bytes_to_write);
                error_code = SSL_get_error(p_ssl_handle_, cur_written_length);
                if (0 < cur_written_length) {
                    total_written_length += (size_t) cur_written_length;
                } else if (SSL_ERROR_WANT_WRITE == error_code) {
                    FD_ZERO(&write_fds);
                    FD_SET(server_tcp_socket_fd_, &write_fds);
                    select_retCode = select(server_tcp_socket_fd_ + 1, NULL, &write_fds, NULL, &timeout);
                    if (0 == select_retCode) { //0 == SELECT_TIMEOUT
                        rc = ResponseCode::NETWORK_SSL_WRITE_TIMEOUT_ERROR;
                    } else if (-1 == select_retCode) { //-1 == SELECT_TIMEOUT
                        rc = ResponseCode::NETWORK_SSL_WRITE_ERROR;
                    }
                } else {
                    rc = ResponseCode::NETWORK_SSL_WRITE_ERROR;
                }

            } while (is_connected_ && ResponseCode::NETWORK_SSL_WRITE_ERROR != rc &&
                ResponseCode::NETWORK_SSL_WRITE_TIMEOUT_ERROR != rc &&
                total_written_length < bytes_to_write);

            if (ResponseCode::SUCCESS == rc) {
                size_written_bytes_out = total_written_length;
            }

            return rc;
        }
 bool hasLazyBaseSpecArg (BaseSpecPtr const & base_spec, util::String const & arg)
 {
   bool result = false;
   if (base_spec->isLazy ())
   {
     LazyBaseSpec const & lazy_base_spec = static_cast <LazyBaseSpec const &> (* base_spec);
     gram::BlockVector const & arg_set = lazy_base_spec.getArgSet ();
     for (gram::BlockVectorConstIter beg = arg_set.begin (), end = arg_set.end (); beg != end; ++ beg)
     {
       if (beg->toString () == arg.c_str ())
       {
         result = true;
         break;
       }
     }
   }
   return result;
 }
	//--------------------------------------------------------------------
	Ptr<TransformNode> Nebula3Writer::writeSkinGeometryData( const NodeData& instanceNodeData,const SkinData& skinData,GeometryData& geometryData )
	{
		Ptr<TransformNode> transformNode = TransformNode::Create();
		MeshBuilder meshBuilder;
		Util::String meshFilename ="msh:" + geometryData.mGeometryName;meshFilename.Append(".nvx2");
		for (int groupIndex=0;groupIndex<geometryData.mMeshDatas.Size();groupIndex++)
		{
			/// 设置基本信息
			GeometryData::MeshData& meshData = geometryData.mMeshDatas[groupIndex];
			Ptr<CharacterSkinNode> shapeNode = CharacterSkinNode::Create();
			Util::String shapeName(geometryData.mGeometryName);
			shapeName.Append("_s_");
			shapeName.AppendInt(groupIndex);
			shapeNode->SetName(shapeName);
			shapeNode->SetPrimitiveGroupIndex(groupIndex);
			shapeNode->SetMeshResourceId(meshFilename);	
			this->writeMaterialData(instanceNodeData,geometryData,groupIndex,shapeNode.upcast<ModelNode>());

			for (int j=0;j< meshData.positionIndices.Size();j+=3 )
			{
				MeshBuilderVertex vertex01,vertex02,vertex03;
				vertex01.SetComponent(MeshBuilderVertex::CoordIndex,geometryData.mPositions[meshData.positionIndices[j]]);
				vertex02.SetComponent(MeshBuilderVertex::CoordIndex,geometryData.mPositions[meshData.positionIndices[j+1]]);
				vertex03.SetComponent(MeshBuilderVertex::CoordIndex,geometryData.mPositions[meshData.positionIndices[j+2]]);

				if( !meshData.normalIndices.IsEmpty())
				{
					vertex01.SetComponent(MeshBuilderVertex::NormalIndex,geometryData.mNormals[meshData.normalIndices[j]]);
					vertex02.SetComponent(MeshBuilderVertex::NormalIndex,geometryData.mNormals[meshData.normalIndices[j+1]]);
					vertex03.SetComponent(MeshBuilderVertex::NormalIndex,geometryData.mNormals[meshData.normalIndices[j+2]]);
				}
				if( !meshData.mDiffMapUVs.IsEmpty())
				{
					vertex01.SetComponent(MeshBuilderVertex::Uv0Index,meshData.mDiffMapUVs[meshData.mDiffMapIndices[j]]);
					vertex02.SetComponent(MeshBuilderVertex::Uv0Index,meshData.mDiffMapUVs[meshData.mDiffMapIndices[j+1]]);
					vertex03.SetComponent(MeshBuilderVertex::Uv0Index,meshData.mDiffMapUVs[meshData.mDiffMapIndices[j+2]]);
				}

				if( !geometryData.mJointIndices.IsEmpty())
				{
					vertex01.SetComponent(MeshBuilderVertex::JIndicesIndex,geometryData.mJointIndices[meshData.positionIndices[j]]);
					vertex01.SetComponent(MeshBuilderVertex::WeightsIndex,geometryData.mWeights[meshData.positionIndices[j]]);
					vertex02.SetComponent(MeshBuilderVertex::JIndicesIndex,geometryData.mJointIndices[meshData.positionIndices[j+1]]);
					vertex02.SetComponent(MeshBuilderVertex::WeightsIndex,geometryData.mWeights[meshData.positionIndices[j+1]]);
					vertex03.SetComponent(MeshBuilderVertex::JIndicesIndex,geometryData.mJointIndices[meshData.positionIndices[j+2]]);
					vertex03.SetComponent(MeshBuilderVertex::WeightsIndex,geometryData.mWeights[meshData.positionIndices[j+2]]);
				}				

				meshBuilder.AddVertex(vertex01);
				size_t indices01 = meshBuilder.GetNumVertices() -1;
				meshBuilder.AddVertex(vertex02);
				size_t indices02 = meshBuilder.GetNumVertices() -1;
				meshBuilder.AddVertex(vertex03);
				size_t indices03 = meshBuilder.GetNumVertices() -1;

				MeshBuilderTriangle triangle;
				triangle.SetGroupId(groupIndex);
				triangle.SetVertexIndices(indices01,indices02,indices03);
				meshBuilder.AddTriangle(triangle);				
			}///end for	
			transformNode->AddChild(shapeNode.upcast<ModelNode>());
		}///end for

		/// 保存模型文件		
		if( !MeshBuilderSaver::SaveNvx2(meshFilename,meshBuilder,Platform::Win32) )
		{
			n_error("Save [%s] Failed!\n",meshFilename);
		}///end if	

		Math::bbox boundingbox = meshBuilder.ComputeBoundingBox();
		transformNode->SetName(geometryData.mGeometryName);
		transformNode->SetBoundingBox(boundingbox);
		Util::Array<Ptr<ModelNode>> shapeNodes = transformNode->GetChildren();
		for (int i=0;i<shapeNodes.Size();i++)
		{
			shapeNodes[i]->SetBoundingBox(boundingbox);
		}///end for

		/// 设置位置信息
		//Math::vector outTranslate;Math::quaternion outRotate;Math::vector outScale;		
		//Math::matrix44 matTemp = this->getGeometryMatrix(instanceNodeData.nodeUniqueId);
		//matTemp.decompose(outScale,outRotate,outTranslate);	
		//transformNode->SetPosition(outTranslate);
		//transformNode->SetRotation(outRotate);
		//transformNode->SetScale(outScale);	
		return transformNode;
	}
Пример #12
0
void FullContainerKey::toString(util::StackAllocator &alloc, util::String &str) const {
	try {
		FullContainerKeyComponents components;
		BitArray upperCaseBit(DEFAULT_UPPER_CASE_BIT_LENGTH);

		deserialize(alloc, components, upperCaseBit, true);

		str.clear();
		if (components.baseNameSize_ > 0) {
			str.append(components.baseName_, components.baseNameSize_);
		}

		if (components.systemPartId_ != UNDEF_SYSTEM_PART_ID) {
			util::NormalOStringStream oss;
			oss << components.systemPartId_;
			str.append("#");
			str.append(oss.str().c_str());
		}
		else if (components.systemPart_ != NULL && components.systemPartSize_ > 0) {
			str.append("#");
			str.append(components.systemPart_, components.systemPartSize_);
		}

		if (components.largeContainerId_ != UNDEF_LARGE_CONTAINERID) {
			util::NormalOStringStream oss;
			oss << components.largeContainerId_;
			str.append("@");
			str.append(oss.str().c_str());
		}

		if (components.affinityNumber_ != UNDEF_NODE_AFFINITY_NUMBER) {
			util::NormalOStringStream oss;
			oss << components.affinityNumber_;
			str.append("@");
			str.append(oss.str().c_str());
		}
		else if (components.affinityString_ != NULL && components.affinityStringSize_ > 0) {
			str.append("@");
			str.append(components.affinityString_, components.affinityStringSize_);
		}

	}
	catch (std::exception &e) {
		GS_RETHROW_USER_ERROR_CODED(GS_ERROR_DS_DS_CONTAINER_NAME_INVALID, e,
			"failed to get container/table name");
	}
}