Ticket #243: static-prop.patch

File static-prop.patch, 1.6 KB (added by Philip Taylor, 14 years ago)
  • source/collada/PMDConvert.cpp

    diff -r 5d3003fbea5e source/collada/PMDConvert.cpp
    a b  
    7171        return FMVector3(1.0f, 0.0f, 0.0f);
    7272}
    7373
     74static void AddStaticPropPoints(std::vector<PropPoint> &propPoints, FCDSceneNode* node)
     75{
     76    if (node->GetName().find("prop-") == 0)
     77    {
     78        // Strip off the "prop-" from the name
     79        std::string propPointName (node->GetName().substr(5));
     80
     81        Log(LOG_INFO, "Adding prop point %s", propPointName.c_str());
     82
     83        // Get translation and orientation of local transform
     84
     85        FMMatrix44 localTransform = node->CalculateWorldTransform();
     86
     87        HMatrix matrix;
     88        memcpy(matrix, localTransform.Transposed().m, sizeof(matrix));
     89
     90        AffineParts parts;
     91        decomp_affine(matrix, &parts);
     92
     93        // Add prop point to list
     94
     95        PropPoint p = {
     96            propPointName,
     97            { parts.t.x, parts.t.y, parts.t.z },
     98            { parts.q.x, parts.q.y, parts.q.z, parts.q.w },
     99            0xff
     100        };
     101        propPoints.push_back(p);
     102    }
     103
     104    for (size_t i = 0; i < node->GetChildrenCount(); ++i)
     105        AddStaticPropPoints(propPoints, node->GetChild(i));
     106}
     107
    74108class PMDConvert
    75109{
    76110public:
     
    123157            std::vector<PropPoint> propPoints;
    124158            AddDefaultPropPoints(propPoints);
    125159
     160            AddStaticPropPoints(propPoints, converter.GetInstance().GetParent());
     161
    126162            WritePMD(output, indicesCombined, indicesCombinedCount, dataPosition, dataNormal, dataTexcoord, vertexCount, boneWeights, boneTransforms, propPoints);
    127163        }
    128164        else if (converter.GetInstance().GetType() == FCDEntityInstance::CONTROLLER)