Beispiel #1
0
void SE_NewGeometry::read(SE_BufferInput& input)
{
    int attachObjNum = input.readInt();
    SE_SimObjectManager* simObjectManager = SE_Application::getInstance()->getSimObjectManager();
    for(int i = 0 ; i < attachObjNum ; i++)
    {
        std::string str = input.readString();
        SE_SimObject* obj = (SE_SimObject*)SE_ObjectFactory::create(str.c_str());
        obj->read(input);
        attachSimObject(obj);
        SE_SimObjectID id = SE_ID::createSimObjectID();
        if(!simObjectManager->set(id, obj))
        {
            LOGI("obj has exist!!!\n");
            delete obj;
        }
    }
    SE_Spatial::read(input);
}
Beispiel #2
0
void SE_TreeStructID::read(SE_BufferInput& input)
{
    id[0] = input.readInt();
    id[1] = input.readInt();
}
void SE_SimObject::read(SE_BufferInput& input)
{
	mName = input.readString();
}
Beispiel #4
0
void SE_Layer::read(SE_BufferInput& input)
{
	mLayer = input.readString();
}
Beispiel #5
0
void SE_Geometry::readEffect(SE_BufferInput& input)
{
    SE_Spatial::readEffect(input);
    //get lighting status
    int need = input.readInt();
    if(need == 1)
    {
        this->setNeedLighting(true);
        int dirlightcount = input.readInt();//dirlight count
        for(int i = 0; i < dirlightcount; ++i)
        {
            SE_Light* l = new SE_Light();
            SE_Vector3f dir = input.readVector3f();//read dir
            std::string name = input.readString();
            SE_Vector3f color = input.readVector3f();
            float dirlightstrength = input.readFloat();

            l->setLightDir(dir);
            l->setLightName(name.c_str());
            l->setLightType(SE_Light::SE_DIRECTION_LIGHT);
            l->setLightColor(color);
            l->setDirLightStrength(dirlightstrength);
            mLightsForInflate.push_back(l);
            this->addLightNameToList(name.c_str());

        }

        int pointlightcount = input.readInt();//pointlight count
        for(int i = 0; i < pointlightcount; ++i)
        {
            SE_Light* l = new SE_Light();
            SE_Vector3f pos = input.readVector3f();//read pos
            float constAttr = input.readFloat();
            float linearAttr = input.readFloat();
            float quatAttr = input.readFloat();
            std::string name = input.readString();
            SE_Vector3f color = input.readVector3f();

            l->setLightPos(pos);
            l->setConstantAttenuation(constAttr);
            l->setLinearAttenuation(linearAttr);
            l->setQuadraticAttenuation(quatAttr);
            l->setLightName(name.c_str());
            l->setLightType(SE_Light::SE_POINT_LIGHT);
            l->setLightColor(color);
            mLightsForInflate.push_back(l);
            this->addLightNameToList(name.c_str());
        }

        int spotlightcount = input.readInt();//spotlight count
        for(int i = 0; i < spotlightcount; ++i)
        {
            SE_Light* l = new SE_Light();
            SE_Vector3f pos = input.readVector3f();//read pos
            SE_Vector3f spotdir = input.readVector3f();//read spotdir

            float constAttr = input.readFloat();
            float linearAttr = input.readFloat();
            float quatAttr = input.readFloat();

            float cutoff = input.readFloat();
            float spotexp = input.readFloat();
            std::string name = input.readString();
            SE_Vector3f color = input.readVector3f();

            l->setLightPos(pos);
            l->setLightDir(spotdir);

            l->setConstantAttenuation(constAttr);
            l->setLinearAttenuation(linearAttr);
            l->setQuadraticAttenuation(quatAttr);
            l->setSpotLightCutOff(cutoff);
            l->setSpotLightExp(spotexp);
            l->setLightName(name.c_str());
            l->setLightColor(color);

            l->setLightType(SE_Light::SE_SPOT_LIGHT);
            mLightsForInflate.push_back(l);
            this->addLightNameToList(name.c_str());
        }        
    }
    else
    {
        this->setNeedLighting(false);
    }

    //read shadow generator
    int shadowGenerator = input.readInt();
    if(shadowGenerator == 1)
    {
        if(SE_Application::getInstance()->SEHomeDebug)
        LOGI("spatial[%s] is shadow generator!\n",getSpatialName());
        this->setNeedGenerateShadow(true);
        SE_Camera* s = SE_Application::getInstance()->getHelperCamera(SE_SHADOWCAMERA);
        SE_Vector3f loc = input.readVector3f();
        SE_Vector3f target = input.readVector3f();
        SE_Vector3f up = input.readVector3f();
        float neara = input.readFloat();
        float fara = input.readFloat();
        float fov = input.readFloat();
        s->create(loc, target, up, fov,1.0, neara, fara);
    }
    else
    {
        this->setNeedGenerateShadow(false);
    }

    //read shadow render
    int shadowRender = input.readInt();
    if(shadowRender == 1)
    {
        if(SE_Application::getInstance()->SEHomeDebug)
        LOGI("spatial[%s] is shadow render!\n",getSpatialName());
        this->setNeedRenderShadow(true);
    }
    else
    {
        this->setNeedRenderShadow(false);
    }

    //read mirror generator
    int mirrorGenerator = input.readInt();
    if(mirrorGenerator == 1)
    {
        this->setNeedGenerateMirror(true);
        mMirrorInfo = input.readString();
        mMirrorPlane = (SE_MirrorPlane)input.readInt();

    }
    else
    {
        this->setNeedGenerateMirror(false);
    }

    //read mirror 
    int mirrorRender = input.readInt();
    if(mirrorRender == 1)
    {
        this->setNeedRenderMirror(true);
        float alpha = input.readFloat();
        this->setAlpha(alpha);
    }
    else
    {
        this->setNeedRenderMirror(false);
    }

    int needGenerateMipMap = input.readInt();
    if(needGenerateMipMap == 0)
    {
        mGenerateMipMap = false;
    }
    else
    {
        mGenerateMipMap = true;
    }

    float alpha = input.readFloat();
    this->setAlpha(alpha);

    SE_Vector4f effectData = input.readVector4f();   
    this->setEffectData(effectData);
    
#if 1
    unsigned int effectstate = input.readInt();
    this->setEffectState(effectstate);
#endif
    
}