示例#1
0
    void DiMotionSerializerImpl::ReadAttachClips( DiDataStreamPtr& stream, DiAnimation* motion )
    {
        DiString strName = ReadString(stream);

        DiNodeClip* nodeClip = motion->CreateAttachClip(strName);

        uint16 keyFrameNum = 0;
        ReadShorts(stream,&keyFrameNum,1);

        for (uint16 i = 0; i < keyFrameNum; ++i)
        {
            float time = 0;
            ReadFloats(stream,&time, 1);

            DiVec3 pos;
            ReadObject(stream,pos);

            DiQuat quat;
            ReadObject(stream,quat);

            bool hasScale = false;
            ReadBools(stream,&hasScale,1);

            DiVec3 scale = DiVec3::UNIT_SCALE;
            if (hasScale)
            {
                ReadObject(stream,scale);
            }

            DiTransformKeyFrame* key = nodeClip->CreateNodeKeyFrame(time);
            key->SetTranslate(pos);
            key->SetRotation(quat);
            key->SetScale(scale);
        }
    }
示例#2
0
 void DiSerializer::ReadObject( DiDataStreamPtr& stream, DiQuat& pDest )
 {
     float tmp[4];
     ReadFloats(stream, tmp, 4);
     pDest.x = tmp[0];
     pDest.y = tmp[1];
     pDest.z = tmp[2];
     pDest.w = tmp[3];
 }
示例#3
0
void ColladaParser::Scene::ReadNode(XmlElement* e)
{
	if (e->HasAttribute("type", "JOINT"))
		return;

	Scene::Node n;
	n.id = e->Attribute("id");
	n.name = e->Attribute("name");
	n.matrix = ReadFloats(e->Child("matrix")->content, 16);
	n.geometryId = ReadId(e->Child("instance_geometry")->Attribute("url"));
	this->nodes.emplace(n.id, n);
}
示例#4
0
	static int Menu_Forecolor( lua_State *L ){
		menuDef_t *menu = CheckMenu( L, 1 );
		ReadFloats( menu->window.foreColor.raw, 4, L, 2 );
		qboolean plycolour = lua_toboolean( L, 3 );
		if ( plycolour ) {
			menu->window.flags |= WINDOW_PLAYERCOLOR;
		}
		else {
			menu->window.flags |= ~WINDOW_FORECOLORSET;
		}
		return 0;
	}
示例#5
0
void ColladaParser::Animation::ReadSource(XmlElement* e)
{
	Source s;
	s.id = e->Attribute("id");

	if (e->HasChild("float_array"))
	{
		auto fa = e->Child("float_array");
		auto count = ReadInt(fa->Attribute("count"));
		s.floats = ReadFloats(fa->content, count);
	}

	this->sources.emplace(s.id, s);
}
示例#6
0
void ColladaParser::Geometry::ReadSource(XmlElement* e)
{
	Geometry::Source s;
	s.id = e->Attribute("id");
	auto v = e->Childs("float_array");

	for (int ia = 0; ia < v.size(); ia++)
	{
		auto& f = v[ia];
		auto count = ReadInt(f->Attribute("count"));
		s.floats = ReadFloats(f->content, count);
	}

	this->sources.emplace(s.id, s);
}
示例#7
0
    void DiMotionSerializerImpl::ReadAnimations( DiDataStreamPtr& stream, DiMotion* motion )
    {
        // name
        DiString name = ReadString(stream);

        // length
        float len = 0;
        ReadFloats(stream,&len, 1);

        DiAnimation* anim = motion->CreateAnimation(name,len);

        if (!stream->Eof())
        {
            uint16 streamID = ReadChunk(stream);
            while(!stream->Eof() &&
                (streamID == DI_CLIPS_NODE ||
                streamID == DI_CLIPS_ATTACH ||
                streamID == DI_CLIPS_POSE))
            {
                switch(streamID)
                {
                case DI_CLIPS_NODE:
                    ReadNodeClips(stream,anim);
                    break;

                case DI_CLIPS_POSE:
                    ReadPoseClips(stream,anim);
                    break;

                case DI_CLIPS_ATTACH:
                    ReadAttachClips(stream,anim);
                    break;
                }

                if (!stream->Eof())
                {
                    streamID = ReadChunk(stream);
                }

            }
            if (!stream->Eof())
            {
                stream->Skip(-MSTREAM_OVERHEAD_SIZE);
            }
        }
    }
示例#8
0
    void DiMeshSerializerImpl::ReadSubMeshBoneWeights( DiDataStreamPtr& stream, DiSubMesh* pMesh )
    {
        DI_SERIAL_LOG("Reading bone weights...");

        uint32 size = 0;
        ReadInts(stream,&size,1);
        DI_SERIAL_LOG("Size: %d",size);

        for (uint16 i=0; i<size; i++)
        {
            DiBoneWeight weight;
            ReadInts(stream,&weight.vertexIndex,1);
            ReadShorts(stream,&weight.boneIndex,1);
            ReadFloats(stream,&weight.weight,1);
            pMesh->mBoneWeights.insert(DiSubMesh::BoneWeightList::value_type(weight.vertexIndex, weight));
        }

        pMesh->SetupBoneWeights();
    }
示例#9
0
    void DiMeshSerializerImpl::ReadBoundsInfo( DiDataStreamPtr& stream, DiMesh* pMesh )
    {
        DiVec3 min, max;
        ReadFloats(stream, &min.x, 1);
        ReadFloats(stream, &min.y, 1);
        ReadFloats(stream, &min.z, 1);
        ReadFloats(stream, &max.x, 1);
        ReadFloats(stream, &max.y, 1);
        ReadFloats(stream, &max.z, 1);
        DiAABB box(min, max);
        pMesh->SetBounds(box);

        DI_SERIAL_LOG("AABB: min(%.3f,%.3f,%.3f), max(%.3f,%.3f,%.3f)", min.x, min.y, min.z,max.x,max.y,max.z);
    }
示例#10
0
std::vector<float> ColladaParser::ReadFloats(const std::string& s, int n)
{
	return ReadFloats(s.c_str(), n);
}
示例#11
0
 void DiSerializer::ReadObject( DiDataStreamPtr& stream, DiVec3& pDest )
 {
     ReadFloats(stream, pDest.ptr(), 3);
 }
示例#12
0
	static int Menu_OutlineColor( lua_State *L ) {
		menuDef_t *menu = CheckMenu( L, 1 );
		ReadFloats( menu->window.outlineColor.raw, 4, L, 2 );
		return 0;
	}
示例#13
0
	static int Menu_FocusColor( lua_State *L ) {
		menuDef_t *menu = CheckMenu( L, 1 );
		ReadFloats( menu->focusColor.raw, 4, L, 2 );
		return 0;
	}