const std::string&
SipccSdpAttributeList::GetMid() const
{
  if (!HasAttribute(SdpAttribute::kMidAttribute)) {
    return kEmptyString;
  }
  const SdpAttribute* attr = GetAttribute(SdpAttribute::kMidAttribute);
  return static_cast<const SdpStringAttribute*>(attr)->mValue;
}
const SdpSimulcastAttribute&
SipccSdpAttributeList::GetSimulcast() const
{
  if (!HasAttribute(SdpAttribute::kSimulcastAttribute)) {
    MOZ_CRASH();
  }
  const SdpAttribute* attr = GetAttribute(SdpAttribute::kSimulcastAttribute);
  return *static_cast<const SdpSimulcastAttribute*>(attr);
}
const SdpMsidSemanticAttributeList&
SipccSdpAttributeList::GetMsidSemantic() const
{
  if (!HasAttribute(SdpAttribute::kMsidSemanticAttribute)) {
    MOZ_CRASH();
  }
  const SdpAttribute* attr = GetAttribute(SdpAttribute::kMsidSemanticAttribute);
  return *static_cast<const SdpMsidSemanticAttributeList*>(attr);
}
const SdpRidAttributeList&
SipccSdpAttributeList::GetRid() const
{
  if (!HasAttribute(SdpAttribute::kRidAttribute)) {
    MOZ_CRASH();
  }
  const SdpAttribute* attr = GetAttribute(SdpAttribute::kRidAttribute);
  return *static_cast<const SdpRidAttributeList*>(attr);
}
uint32_t
SipccSdpAttributeList::GetPtime() const
{
  if (!HasAttribute(SdpAttribute::kPtimeAttribute)) {
    MOZ_CRASH();
  }
  const SdpAttribute* attr = GetAttribute(SdpAttribute::kPtimeAttribute);
  return static_cast<const SdpNumberAttribute*>(attr)->mValue;
}
const SdpFingerprintAttributeList&
SipccSdpAttributeList::GetFingerprint() const
{
  if (!HasAttribute(SdpAttribute::kFingerprintAttribute)) {
    MOZ_CRASH();
  }
  const SdpAttribute* attr = GetAttribute(SdpAttribute::kFingerprintAttribute);
  return *static_cast<const SdpFingerprintAttributeList*>(attr);
}
const std::vector<std::string>&
SipccSdpAttributeList::GetCandidate() const
{
  if (!HasAttribute(SdpAttribute::kCandidateAttribute)) {
    MOZ_CRASH();
  }

  return static_cast<const SdpMultiStringAttribute*>(
             GetAttribute(SdpAttribute::kCandidateAttribute))->mValues;
}
const SdpConnectionAttribute&
SipccSdpAttributeList::GetConnection() const
{
  if (!HasAttribute(SdpAttribute::kConnectionAttribute)) {
    MOZ_CRASH();
  }

  return *static_cast<const SdpConnectionAttribute*>(
             GetAttribute(SdpAttribute::kConnectionAttribute));
}
SdpDirectionAttribute::Direction
SipccSdpAttributeList::GetDirection() const
{
  if (!HasAttribute(SdpAttribute::kDirectionAttribute)) {
    MOZ_CRASH();
  }

  const SdpAttribute* attr = GetAttribute(SdpAttribute::kDirectionAttribute);
  return static_cast<const SdpDirectionAttribute*>(attr)->mValue;
}
Example #10
0
char * BaseObj::AttributeValue(char *referenceName)
{
   Attribute *dummy;

   ReadAttributes();
   if (HasAttribute(referenceName, &dummy))
      return dummy->Value;
   else
      return NULL;
}
const SdpOptionsAttribute&
SipccSdpAttributeList::GetIceOptions() const
{
  if (!HasAttribute(SdpAttribute::kIceOptionsAttribute)) {
    MOZ_CRASH();
  }

  const SdpAttribute* attr = GetAttribute(SdpAttribute::kIceOptionsAttribute);
  return *static_cast<const SdpOptionsAttribute*>(attr);
}
const SdpGroupAttributeList&
SipccSdpAttributeList::GetGroup() const
{
  if (!HasAttribute(SdpAttribute::kGroupAttribute)) {
    MOZ_CRASH();
  }

  return *static_cast<const SdpGroupAttributeList*>(
             GetAttribute(SdpAttribute::kGroupAttribute));
}
Example #13
0
int32_t OgreXmlSerializer::ReadAttribute<int32_t>(const std::string &name) const
{
    if (HasAttribute(name.c_str()))
    {
        return static_cast<int32_t>(m_reader->getAttributeValueAsInt(name.c_str()));
    }
    else
    {
        ThrowAttibuteError(m_reader, name);
        return 0;
    }
}
Example #14
0
float OgreXmlSerializer::ReadAttribute<float>(const std::string &name) const
{
    if (HasAttribute(name.c_str()))
    {
        return m_reader->getAttributeValueAsFloat(name.c_str());
    }
    else
    {
        ThrowAttibuteError(m_reader, name);
        return 0;
    }
}
Example #15
0
uint16_t OgreXmlSerializer::ReadAttribute<uint16_t>(const std::string &name) const
{
    if (HasAttribute(name.c_str()))
    {
        return static_cast<uint16_t>(ReadAttribute<uint32_t>(name));
    }
    else
    {
        ThrowAttibuteError(m_reader, name);
    }
    return 0;
}
Example #16
0
uint32_t OgreXmlSerializer::ReadAttribute<uint32_t>(const std::string &name) const
{
    if (HasAttribute(name.c_str()))
    {
        /** @note This is hackish. But we are never expecting unsigned values that go outside the
            int32_t range. Just monitor for negative numbers and kill the import. */
        int32_t temp = ReadAttribute<int32_t>(name);
        if (temp >= 0)
        {
            return static_cast<uint32_t>(temp);
        }
        else
        {
            ThrowAttibuteError(m_reader, name, "Found a negative number value where expecting a uint32_t value");
        }
    }
    else
    {
        ThrowAttibuteError(m_reader, name);
    }
    return 0;
}
Example #17
0
int CTopologyNode::CalcMatchStrength (const CAttributeCriteria &Criteria)

//	CalcMatchStrength
//
//	Calculates the match strength of topology node and the criteria.

	{
	int i;

	int iStrength = 1000;
	for (i = 0; i < Criteria.GetCount(); i++)
		{
		DWORD dwMatchStrength;
		bool bIsSpecial;
		const CString &sAttrib = Criteria.GetAttribAndWeight(i, &dwMatchStrength, &bIsSpecial);

		bool bHasAttrib = (bIsSpecial ? HasSpecialAttribute(sAttrib) : HasAttribute(sAttrib));
		int iAdj = CAttributeCriteria::CalcWeightAdj(bHasAttrib, dwMatchStrength);

		iStrength = iStrength * iAdj / 1000;
		}

	return iStrength;
	}
// -----------------------------------------------------------------------------
// CNATFWUNSAFMessage::EncodeL
// 1. Encode the UNSAF message normally.
// 2. Create a MESSAGE-INTEGRITY attribute. This updates also the header's
//    length field to include the MESSAGE-INTEGRITY before computing the hash.
// 3. Encode it to the last attribute of the UNSAF message.
// 4. Create a FINGERPRINT attribute. This updates also the header's
//    length field to include the FINGERPRINT before computing the hash.
// 5. Encode it to the last attribute of the UNSAF message.
// -----------------------------------------------------------------------------
//
EXPORT_C CBufBase* CNATFWUNSAFMessage::EncodeL(
    const TDesC8& aSharedSecret,
    TBool aUseFingerprint) const
{
    CBufBase* msg = EncodeL();
    CleanupStack::PushL(msg);
    if ( aSharedSecret.Length() )
    {
        //Long term credentials need be used if there's a REALM attribute
        CNATFWUNSAFMessageIntegrityAttribute* msgIntegrity =
            CNATFWUNSAFMessageIntegrityAttribute::NewLC(aSharedSecret, *msg,
                    HasAttribute( CNATFWUNSAFAttribute::ERealm ));

        HBufC8* encodedMsgIntegrity = msgIntegrity->EncodeL();
        CleanupStack::PushL(encodedMsgIntegrity);
        msg->InsertL(msg->Size(), *encodedMsgIntegrity);
        CleanupStack::PopAndDestroy(encodedMsgIntegrity);
        CleanupStack::PopAndDestroy(msgIntegrity);
    }
    if ( aUseFingerprint )
    {
        CNATFWUNSAFFingerprintAttribute* fingerprint =
            CNATFWUNSAFFingerprintAttribute::NewLC(*msg);

        HBufC8* encodedFingerprint = fingerprint->EncodeL();
        CleanupStack::PushL(encodedFingerprint);
        msg->InsertL(msg->Size(), *encodedFingerprint);
        CleanupStack::PopAndDestroy(encodedFingerprint);
        CleanupStack::PopAndDestroy(fingerprint);
    }

    CleanupStack::Pop(msg);
    msg->Compress();

    return msg;
}
Example #19
0
// Called when attributes on the element are changed.
void ElementImage::OnAttributeChange(const Rocket::Core::AttributeNameList& changed_attributes)
{
	// Call through to the base element's OnAttributeChange().
	Rocket::Core::Element::OnAttributeChange(changed_attributes);

	float dirty_layout = false;

	// Check for a changed 'src' attribute. If this changes, the old texture handle is released,
	// forcing a reload when the layout is regenerated.
	if (changed_attributes.find("src") != changed_attributes.end())
	{
		texture_dirty = true;
		dirty_layout = true;
	}

	// Check for a changed 'width' attribute. If this changes, a layout is forced which will
	// recalculate the dimensions.
	if (changed_attributes.find("width") != changed_attributes.end() ||
		changed_attributes.find("height") != changed_attributes.end())
	{
		dirty_layout = true;
	}

	// Check for a change to the 'coords' attribute. If this changes, the coordinates are
	// recomputed and a layout forced.
	if (changed_attributes.find("coords") != changed_attributes.end())
	{
		if (HasAttribute("coords"))
		{
			StringList coords_list;
			StringUtilities::ExpandString(coords_list, GetAttribute< String >("coords", ""));

			if (coords_list.size() != 4)
			{
				Rocket::Core::Log::Message(Log::LT_WARNING, "Element '%s' has an invalid 'coords' attribute; coords requires 4 values, found %d.", GetAddress().CString(), coords_list.size());
				ResetCoords();
			}
			else
			{
				for (size_t i = 0; i < 4; ++i)
					coords[i] = atoi(coords_list[i].CString());

				// Check for the validity of the coordinates.
				if (coords[0] < 0 || coords[2] < coords[0] ||
					coords[1] < 0 || coords[3] < coords[1])
				{
					Rocket::Core::Log::Message(Log::LT_WARNING, "Element '%s' has an invalid 'coords' attribute; invalid coordinate values specified.", GetAddress().CString());
					ResetCoords();
				}
				else
				{
					// We have new, valid coordinates; force the geometry to be regenerated.
					geometry_dirty = true;
					using_coords = true;
				}
			}
		}
		else
			ResetCoords();

		// Coordinates have changes; this will most likely result in a size change, so we need to force a layout.
		dirty_layout = true;
	}

	if (dirty_layout)
		DirtyLayout();
}
Example #20
0
bool XMLElement::HasAttribute(const String& name) const
{
    return HasAttribute(name.CString());
}
Example #21
0
boolean BaseObj::HasAttribute(Attribute *attribute)
{
   Attribute *dummy;

   return HasAttribute(attribute->ReferenceName, &dummy);
}
Example #22
0
boolean BaseObj::HasAttribute(const char *attributeName)
{
   Attribute *dummy;

   return HasAttribute(attributeName, &dummy);
}
Example #23
0
string Element::GetAttributeValue(const string& attr)
{
  if (HasAttribute(attr))  return attributes[attr];
  else                     return ("");
}
Example #24
0
bool CMission::MatchesCriteria (CSpaceObject *pSource, const SCriteria &Criteria)

//	MatchesCriteria
//
//	Returns TRUE if the given mission matches the criteria

{
    int i;

    //	By status

    if (Criteria.bIncludeActive && !IsActive())
        return false;

    if (Criteria.bIncludeOpen && m_iStatus != statusOpen)
        return false;

    if (Criteria.bIncludeRecorded && !IsRecorded())
        return false;

    if (Criteria.bIncludeUnavailable && !IsUnavailable())
        return false;

    //	Owned by source

    if (Criteria.bOnlySourceOwner)
    {
        if (pSource)
        {
            if (pSource->GetID() != m_pOwner.GetID())
                return false;
        }
        else
        {
            if (m_pOwner.GetID() != OBJID_NULL)
                return false;
        }
    }

    //	Check required attributes

    for (i = 0; i < Criteria.AttribsRequired.GetCount(); i++)
        if (!HasAttribute(Criteria.AttribsRequired[i]))
            return false;

    //	Check attributes not allowed

    for (i = 0; i < Criteria.AttribsNotAllowed.GetCount(); i++)
        if (HasAttribute(Criteria.AttribsNotAllowed[i]))
            return false;

    //	Check special attribs required

    for (i = 0; i < Criteria.SpecialRequired.GetCount(); i++)
        if (!HasSpecialAttribute(Criteria.SpecialRequired[i]))
            return false;

    //	Check special attribs not allowed

    for (i = 0; i < Criteria.SpecialNotAllowed.GetCount(); i++)
        if (HasSpecialAttribute(Criteria.SpecialNotAllowed[i]))
            return false;

    //	Match

    return true;
}
Example #25
0
Info API::DeleteFrom(SqlCommandDeleteFrom* command){
  CatalogManager catalog_manager;
  IndexManager index_manager;
  RecordManager record_manager;

  bool delete_all_records = command->delete_all_records();
  std::string table_name = command->table_name();
  std::vector<WhereClause> where_clause = command->where_clause();
  if (!catalog_manager.HasTable(table_name)){
    std::string error_info;
    error_info = "Table \"" + table_name + "\" not exists.";
    return Info(error_info);
  }

  auto table = catalog_manager.GetTableInfo(table_name);

  for (auto it: where_clause){
    if(!table.HasAttribute(it.kColumnName)){
      std::string error_info;
      error_info = "attribute \"" + it.kColumnName + "\"in where clause \""+ it.kColumnName + it.kOperator + it.kCondition +"\" not exists.";
      return Info(error_info);
    }
  }

  if (delete_all_records){
    if(record_manager.DeleteAllRecords(table)){
      //update index
      for (auto it : table.index_names()){
        IndexInfo index_info = catalog_manager.GetIndexInfo(it);
        index_manager.EmptyIndex(index_info);
      }
      return Info();
    }
    else{
      return Info("Delete records failed");
    }
  }
  else{
    std::vector<WhereClause> where_clause_with_index;
    std::vector<WhereClause> where_clause_without_index;

    for (auto it : where_clause){
      if (!table.attribute(it.kColumnName).index_names().empty() && it.kOperator != "!="){
        where_clause_with_index.push_back(it);
      }
      else{
        where_clause_without_index.push_back(it);
      }
    }

    std::vector<std::pair<int,int>> results;

    if (!where_clause_with_index.empty()) //条件里有属性有 index
    {

      for (auto it : where_clause_with_index){
        std::string index_name = table.attribute(it.kColumnName).index_names().at(0);
        IndexInfo index = catalog_manager.GetIndexInfo(index_name);
        std::vector<int> offsets_of_a_clause = index_manager.FindRecords(table,index, it);
        if(offsets_of_a_clause.empty()){
          std::string error_info;
          error_info = "record not found with index, deletion failed";
          return Info(error_info);
        }
        std::sort(offsets_of_a_clause.begin(), offsets_of_a_clause.end());
        offsets_of_a_clause.erase(std::unique(offsets_of_a_clause.begin(), offsets_of_a_clause.end()), offsets_of_a_clause.end());

        std::vector<std::pair<int,int>> results_of_a_clause = record_manager.FindRecordsWithIndex(offsets_of_a_clause, table, it);

        if (results.empty()){
          results = results_of_a_clause;
        }
        else{
          std::vector<std::pair<int,int> > results_temp;
          std::set_intersection(results.begin(),results.end(),
                                results_of_a_clause.begin(),results_of_a_clause.end(),
                                std::back_inserter(results_temp));
          results = results_temp;

        }
      }
      for(auto it : where_clause_without_index){
        if(results.empty()){
          std::string error_info;
          error_info = "record not found with index, deletion failed";
          return Info(error_info);
        }
        results = record_manager.RecordsFilter(results, table, it);
      }
    }
    else{ //条件里属性都没有 index
      for (auto it: where_clause_without_index){
        if (results.empty()){
          results = record_manager.FindRecordsWithNoIndex(table, it);
        }
        else{
          results = record_manager.RecordsFilter(results,table, it);
        }
      }
      if(results.empty()){
        std::string error_info;
        error_info = "record not found with no index, deletion failed";
        return Info(error_info);
      }

    }
    if(results.empty()){
        std::string error_info;
        error_info = "record not found, deletion failed";
        return Info(error_info);
    }
    auto records = record_manager.SelectRecords(results, table);
    int ret = record_manager.DeleteRecords(results, table);
    if(!ret){
      return Info("Delete records failed.");
    }
    else{
      auto index_names = table.index_names();
      int pair_index = 0;
      for (auto it : records){
        for (auto i : index_names){
          IndexInfo index_info = catalog_manager.GetIndexInfo(i);
          auto index = table.attribute_index(index_info.attribute_name());
          std::string value = it.at(index);
          int offset_i = results.at(pair_index).first;
          bool ret = index_manager.DeleteRecord(table, index_info, value, offset_i);
          if(!ret){
            return Info("Delete record in index \"" + index_info.name() + "on attribute \"" + index_info.attribute_name()
                        +"\" of table \"" + index_info.table_name() + "\"failed.");
          }
        }
        pair_index++;
      }
      return Info();
    }
  }
}
Example #26
0
void OgreXmlSerializer::ReadSubMesh(MeshXml *mesh)
{
    static const std::string anMaterial          = "material";
    static const std::string anUseSharedVertices = "usesharedvertices";
    static const std::string anCount             = "count";
    static const std::string anV1                = "v1";
    static const std::string anV2                = "v2";
    static const std::string anV3                = "v3";
    static const std::string anV4                = "v4";

    SubMeshXml* submesh = new SubMeshXml();

    if (HasAttribute(anMaterial)) {
        submesh->materialRef = ReadAttribute<std::string>(anMaterial);
    }
    if (HasAttribute(anUseSharedVertices)) {
        submesh->usesSharedVertexData = ReadAttribute<bool>(anUseSharedVertices);
    }

    DefaultLogger::get()->debug(Formatter::format() << "Reading SubMesh " << mesh->subMeshes.size());
    DefaultLogger::get()->debug(Formatter::format() << "  - Material: '" << submesh->materialRef << "'");
    DefaultLogger::get()->debug(Formatter::format() << "  - Uses shared geometry: " << (submesh->usesSharedVertexData ? "true" : "false"));

    // TODO: maybe we have always just 1 faces and 1 geometry and always in this order. this loop will only work correct, when the order
    // of faces and geometry changed, and not if we have more than one of one
    /// @todo Fix above comment with better read logic below

    bool quadWarned = false;

    NextNode();
    while(m_currentNodeName == nnFaces     ||
          m_currentNodeName == nnGeometry  ||
          m_currentNodeName == nnTextures  ||
          m_currentNodeName == nnBoneAssignments)
    {
        if (m_currentNodeName == nnFaces)
        {
            submesh->indexData->faceCount = ReadAttribute<uint32_t>(anCount);
            submesh->indexData->faces.reserve(submesh->indexData->faceCount);

            NextNode();
            while(m_currentNodeName == nnFace)
            {
                aiFace face;
                face.mNumIndices = 3;
                face.mIndices = new unsigned int[3];
                face.mIndices[0] = ReadAttribute<uint32_t>(anV1);
                face.mIndices[1] = ReadAttribute<uint32_t>(anV2);
                face.mIndices[2] = ReadAttribute<uint32_t>(anV3);

                /// @todo Support quads if Ogre even supports them in XML (I'm not sure but I doubt it)
                if (!quadWarned && HasAttribute(anV4)) {
                    DefaultLogger::get()->warn("Submesh <face> has quads with <v4>, only triangles are supported at the moment!");
                    quadWarned = true;
                }

                submesh->indexData->faces.push_back(face);

                // Advance
                NextNode();
            }

            if (submesh->indexData->faces.size() == submesh->indexData->faceCount)
            {
                DefaultLogger::get()->debug(Formatter::format() << "  - Faces " << submesh->indexData->faceCount);
            }
            else
            {
                throw DeadlyImportError(Formatter::format() << "Read only " << submesh->indexData->faces.size() << " faces when should have read " << submesh->indexData->faceCount);
            }
        }
        else if (m_currentNodeName == nnGeometry)
        {
            if (submesh->usesSharedVertexData) {
                throw DeadlyImportError("Found <geometry> in <submesh> when use shared geometry is true. Invalid mesh file.");
            }

            submesh->vertexData = new VertexDataXml();
            ReadGeometry(submesh->vertexData);
        }
        else if (m_currentNodeName == nnBoneAssignments)
        {
            ReadBoneAssignments(submesh->vertexData);
        }
        // Assimp incompatible/ignored nodes
        else
            SkipCurrentNode();
    }

    submesh->index = mesh->subMeshes.size();
    mesh->subMeshes.push_back(submesh);
}
Example #27
0
void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest)
{
    bool positions = (HasAttribute("positions") && ReadAttribute<bool>("positions"));
    bool normals   = (HasAttribute("normals") && ReadAttribute<bool>("normals"));
    bool tangents  = (HasAttribute("tangents") && ReadAttribute<bool>("tangents"));
    uint32_t uvs   = (HasAttribute("texture_coords") ? ReadAttribute<uint32_t>("texture_coords") : 0);

    // Not having positions is a error only if a previous vertex buffer did not have them.
    if (!positions && !dest->HasPositions()) {
        throw DeadlyImportError("Vertex buffer does not contain positions!");
    }

    if (positions)
    {
        DefaultLogger::get()->debug("    - Contains positions");
        dest->positions.reserve(dest->count);
    }
    if (normals)
    {
        DefaultLogger::get()->debug("    - Contains normals");
        dest->normals.reserve(dest->count);
    }
    if (tangents)
    {
        DefaultLogger::get()->debug("    - Contains tangents");
        dest->tangents.reserve(dest->count);
    }
    if (uvs > 0)
    {
        DefaultLogger::get()->debug(Formatter::format() << "    - Contains " << uvs << " texture coords");
        dest->uvs.resize(uvs);
        for(size_t i=0, len=dest->uvs.size(); i<len; ++i) {
            dest->uvs[i].reserve(dest->count);
        }
    }

    bool warnBinormal = true;
    bool warnColorDiffuse = true;
    bool warnColorSpecular = true;

    NextNode();

    while(m_currentNodeName == nnVertex       ||
          m_currentNodeName == nnPosition     ||
          m_currentNodeName == nnNormal       ||
          m_currentNodeName == nnTangent      ||
          m_currentNodeName == nnBinormal     ||
          m_currentNodeName == nnTexCoord     ||
          m_currentNodeName == nnColorDiffuse ||
          m_currentNodeName == nnColorSpecular)
    {
        if (m_currentNodeName == nnVertex) {
            NextNode();
        }

        /// @todo Implement nnBinormal, nnColorDiffuse and nnColorSpecular

        if (positions && m_currentNodeName == nnPosition)
        {
            aiVector3D pos;
            pos.x = ReadAttribute<float>(anX);
            pos.y = ReadAttribute<float>(anY);
            pos.z = ReadAttribute<float>(anZ);
            dest->positions.push_back(pos);
        }
        else if (normals && m_currentNodeName == nnNormal)
        {
            aiVector3D normal;
            normal.x = ReadAttribute<float>(anX);
            normal.y = ReadAttribute<float>(anY);
            normal.z = ReadAttribute<float>(anZ);
            dest->normals.push_back(normal);
        }
        else if (tangents && m_currentNodeName == nnTangent)
        {
            aiVector3D tangent;
            tangent.x = ReadAttribute<float>(anX);
            tangent.y = ReadAttribute<float>(anY);
            tangent.z = ReadAttribute<float>(anZ);
            dest->tangents.push_back(tangent);
        }
        else if (uvs > 0 && m_currentNodeName == nnTexCoord)
        {
            for(size_t i=0, len=dest->uvs.size(); i<len; ++i)
            {
                if (m_currentNodeName != nnTexCoord) {
                    throw DeadlyImportError("Vertex buffer declared more UVs than can be found in a vertex");
                }

                aiVector3D uv;
                uv.x = ReadAttribute<float>("u");
                uv.y = (ReadAttribute<float>("v") * -1) + 1; // Flip UV from Ogre to Assimp form
                dest->uvs[i].push_back(uv);

                NextNode();
            }
            // Continue main loop as above already read next node
            continue;
        }
        else
        {
            /// @todo Remove this stuff once implemented. We only want to log warnings once per element.
            bool warn = true;
            if (m_currentNodeName == nnBinormal)
            {
                if (warnBinormal)
                {
                    warnBinormal = false;
                }
                else
                {
                    warn = false;
                }
            }
            else if (m_currentNodeName == nnColorDiffuse)
            {
                if (warnColorDiffuse)
                {
                    warnColorDiffuse = false;
                }
                else
                {
                    warn = false;
                }
            }
            else if (m_currentNodeName == nnColorSpecular)
            {
                if (warnColorSpecular)
                {
                    warnColorSpecular = false;
                }
                else
                {
                    warn = false;
                }
            }
            if (warn) {
                DefaultLogger::get()->warn("Vertex buffer attribute read not implemented for element: " + m_currentNodeName);
            }
        }

        // Advance
        NextNode();
    }

    // Sanity checks
    if (dest->positions.size() != dest->count) {
      throw DeadlyImportError(Formatter::format() << "Read only " << dest->positions.size() << " positions when should have read " << dest->count);
    }
    if (normals && dest->normals.size() != dest->count) {
        throw DeadlyImportError(Formatter::format() << "Read only " << dest->normals.size() << " normals when should have read " << dest->count);
    }
    if (tangents && dest->tangents.size() != dest->count) {
        throw DeadlyImportError(Formatter::format() << "Read only " << dest->tangents.size() << " tangents when should have read " << dest->count);
    }
    for(unsigned int i=0; i<dest->uvs.size(); ++i)
    {
        if (dest->uvs[i].size() != dest->count) {
            throw DeadlyImportError(Formatter::format() << "Read only " << dest->uvs[i].size()
                << " uvs for uv index " << i << " when should have read " << dest->count);
        }
    }
}
Example #28
0
void OgreXmlSerializer::ReadBones(Skeleton *skeleton)
{
    DefaultLogger::get()->debug("  - Bones");

    NextNode();
    while(m_currentNodeName == nnBone)
    {
        Bone *bone = new Bone();
        bone->id = ReadAttribute<uint16_t>("id");
        bone->name = ReadAttribute<std::string>("name");

        NextNode();
        while(m_currentNodeName == nnPosition ||
              m_currentNodeName == nnRotation ||
              m_currentNodeName == nnScale)
        {
            if (m_currentNodeName == nnPosition)
            {
                bone->position.x = ReadAttribute<float>(anX);
                bone->position.y = ReadAttribute<float>(anY);
                bone->position.z = ReadAttribute<float>(anZ);
            }
            else if (m_currentNodeName == nnRotation)
            {
                float angle = ReadAttribute<float>("angle");

                if (NextNode() != nnAxis) {
                    throw DeadlyImportError(Formatter::format() << "No axis specified for bone rotation in bone " << bone->id);
                }

                aiVector3D axis;
                axis.x = ReadAttribute<float>(anX);
                axis.y = ReadAttribute<float>(anY);
                axis.z = ReadAttribute<float>(anZ);

                bone->rotation = aiQuaternion(axis, angle);
            }
            else if (m_currentNodeName == nnScale)
            {
                /// @todo Implement taking scale into account in matrix/pose calculations!
                if (HasAttribute("factor"))
                {
                    float factor = ReadAttribute<float>("factor");
                    bone->scale.Set(factor, factor, factor);
                }
                else
                {
                    if (HasAttribute(anX))
                        bone->scale.x = ReadAttribute<float>(anX);
                    if (HasAttribute(anY))
                        bone->scale.y = ReadAttribute<float>(anY);
                    if (HasAttribute(anZ))
                        bone->scale.z = ReadAttribute<float>(anZ);
                }
            }

            NextNode();
        }

        skeleton->bones.push_back(bone);
    }

    // Order bones by Id
    std::sort(skeleton->bones.begin(), skeleton->bones.end(), BoneCompare);

    // Validate that bone indexes are not skipped.
    /** @note Left this from original authors code, but not sure if this is strictly necessary
        as per the Ogre skeleton spec. It might be more that other (later) code in this imported does not break. */
    for (size_t i=0, len=skeleton->bones.size(); i<len; ++i)
    {
        Bone *b = skeleton->bones[i];
        DefaultLogger::get()->debug(Formatter::format() << "    " << b->id << " " << b->name);

        if (b->id != static_cast<uint16_t>(i)) {
            throw DeadlyImportError(Formatter::format() << "Bone ids are not in sequence starting from 0. Missing index " << i);
        }
    }
}
Example #29
0
bool XMLElement::HasAttribute(const ea::string& name) const
{
    return HasAttribute(name.c_str());
}
// -----------------------------------------------------------------------------
// CNATFWUNSAFSetActiveDestinationErrorResponse::Validate
// -----------------------------------------------------------------------------
//
TBool CNATFWUNSAFSetActiveDestinationErrorResponse::Validate() const
    {
    return HasAttribute(CNATFWUNSAFAttribute::EErrorCode);
    }