Ejemplo n.º 1
0
static void se_setHelperCamera(JNIEnv* env, jobject obj,jfloatArray location, jfloatArray axisZ, jfloatArray up, jfloat fov, jfloat ratio, float near, float far)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if(!scene)
    {
        env->ReleaseStringUTFChars(sceneName, sceneName8);
        return;
    }
    SE_Camera* camera = SE_Application::getInstance()->getHelperCamera(SE_SHADOWCAMERA);
    if(!camera)
    {
        env->ReleaseStringUTFChars(sceneName, sceneName8);
        return;
    }   
 if(_DEBUG)
            LOGD("BORQS## se_setHelperCamera get camera ok!!### \n"); 
    float* cLocation = env->GetFloatArrayElements(location, 0);
    float* cAxisZ = env->GetFloatArrayElements(axisZ, 0);
    float* cUp = env->GetFloatArrayElements(up, 0);
    
    SE_Vector3f mLocation = SE_Vector3f(cLocation[0],cLocation[1],cLocation[2]);
    SE_Vector3f mAxisZ = SE_Vector3f(cAxisZ[0],cAxisZ[1],cAxisZ[2]);
    SE_Vector3f mUp = SE_Vector3f(cUp[0],cUp[1],cUp[2]);

    camera->create(mLocation, mAxisZ, mUp, fov, ratio, near, far);
    
    env->ReleaseFloatArrayElements(location, cLocation, 0);
    env->ReleaseFloatArrayElements(axisZ, cAxisZ, 0);
    env->ReleaseFloatArrayElements(up, cUp, 0);
    env->ReleaseStringUTFChars(sceneName, sceneName8);
    
}
Ejemplo n.º 2
0
static void se_addLightToScene(JNIEnv* env, jobject obj, jstring lightName, jfloatArray lightpos, jfloatArray lightdir,jfloatArray spotdata,jint lighttype)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if(scene)
    {
        float* lpos = env->GetFloatArrayElements(lightpos, 0);
        float* ldir = env->GetFloatArrayElements(lightdir, 0);
        float* lspotdata = env->GetFloatArrayElements(spotdata, 0);
        SE_Vector3f pos = SE_Vector3f(lpos[0],lpos[1],lpos[2]);
        SE_Vector3f dir = SE_Vector3f(ldir[0],ldir[1],ldir[2]);
        SE_Light::LightType lt = (SE_Light::LightType)lighttype;
        SE_Light* light = new SE_Light();
        float att = lpos[3];
        float spot_cutoff = lspotdata[0];
        float spot_exp = lspotdata[1];
        light->setLightType(lt); 
        light->setLightPos(pos);
        light->setAttenuation(att);//point attenuation from 0 to 1.0, 0 means no attenuation
        light->setLightDir(dir);
        const char* lightName8 = env->GetStringUTFChars(lightName, 0);
        light->setLightName(lightName8);
        light->setSpotLightCutOff(spot_cutoff);
        light->setSpotLightExp(spot_exp);
        light->setDirLightStrength(1.0);
        scene->addLightToScene(light);
        env->ReleaseFloatArrayElements(lightpos, lpos, 0);
        env->ReleaseFloatArrayElements(lightdir, ldir, 0);
        env->ReleaseStringUTFChars(lightName, lightName8);
        env->ReleaseFloatArrayElements(spotdata, ldir, 0);
        
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
}
Ejemplo n.º 3
0
SE_Vector3f SE_Quat::map(const SE_Vector3f& v) const
{
    SE_Quat vq(v, 0);
    if(!vq.hasInverse())
    {
        return SE_Vector3f(0, 0, 0);
    }
    SE_Quat ret = mul(vq).mul(inverse());
    return SE_Vector3f(ret.x, ret.y , ret.z);
}
Ejemplo n.º 4
0
static SE_RenderUnit* createSelectedFrame(SE_Geometry* spatial)
{
    SE_RenderUnit* ru = NULL;
    if(spatial)
    {
        SE_BoundingVolume* bv = spatial->getWorldBoundingVolume();
        if(bv)
        {
            SE_AABBBV* aabbBV = NULL;
            SE_SphereBV* sphereBV = NULL;
            SE_OBBBV* obbBV = NULL; 
            switch(bv->getType())
            {
            case AABB:
                {
                    aabbBV = (SE_AABBBV*)bv;
                    SE_AABB aabb = aabbBV->getGeometry();
                    SE_Segment edge[12];
                    aabb.getEdge(edge);
                    std::string renderUnitName = std::string(spatial->getSpatialName()) + "lineedge";
#ifdef USE_RUMANAGER
                    SE_RenderUnitManager* srum = SE_Application::getInstance()->getRenderUnitManager();
                    ru = srum->find(renderUnitName.c_str());
                    if(!ru)
                    {
                    ru = new SE_LineSegRenderUnit(edge, 12, SE_Vector3f(0, 1, 0));
                        srum->insert(renderUnitName.c_str(),ru);
                    }
#else
                    ru = new SE_LineSegRenderUnit(edge, 12, SE_Vector3f(0, 1, 0));
#endif
                    
                }
                break;
            case SPHERE:
                {
                    sphereBV = (SE_SphereBV*)bv;
                }
                break;
            case OBB:
                {
                    obbBV = (SE_OBBBV*)bv;
                }
                break;
            }
        }
    }
    return ru;
}
Ejemplo n.º 5
0
SE_RenderUnit* SE_MeshSimObject::createWireRenderUnit()
{

    //generate world geometry data
    SE_GeometryData data;
    SE_Matrix4f m2w = this->getSpatial()->getWorldTransform();
    SE_GeometryData::transform(mMesh->getGeometryData(),m2w,&data);

    int faceNum = data.getFaceNum();
    int vertexNum = data.getVertexNum();
    SE_Vector3f* vertex = data.getVertexArray();
    SE_Vector3i* faces = data.getFaceArray();

    SE_Segment* seg = new SE_Segment[faceNum * 3];
    int n = 0 ;
    for(int i = 0 ; i < faceNum ; i++)
    {
        SE_Vector3i* f = &faces[i];
        seg[n++].set(vertex[f->x], vertex[f->y]);
        seg[n++].set(vertex[f->y], vertex[f->z]);
        seg[n++].set(vertex[f->z], vertex[f->x]);
    }
    SE_RenderUnit* ru = new SE_LineSegRenderUnit(seg, faceNum * 3, SE_Vector3f(0, 1, 0));
    delete[] seg;
    return ru;
}
Ejemplo n.º 6
0
void SE_Camera::rotateLocal(float angle, SE_AXIS_TYPE axis)
{
    SE_Quat q;
    switch(axis)
    {
    case SE_AXIS_X:
        q.set(angle, SE_Vector3f(1, 0, 0));
        break;
    case SE_AXIS_Y:
        q.set(angle, SE_Vector3f(0, 1, 0));
        break;
    case SE_AXIS_Z:
        q.set(angle, SE_Vector3f(0, 0, 1));
        break;
    }
    return rotateLocal(q);
}
Ejemplo n.º 7
0
SE_Spatial* SE_ElementManager::createSpatial()
{
    if(!mRoot)
        return NULL;
    SE_Spatial* spatial = mRoot->createSpatial(NULL);
    spatial->setLocalTranslate(SE_Vector3f(0, 0, 0));
    spatial->setLocalScale(SE_Vector3f(1, 1, 1));
    SE_Vector4f c1(1, 0, 0, 0);
    SE_Vector4f c2(0, -1, 0, 0);
    SE_Vector4f c3(0, 0, 1, 0);
    SE_Vector4f c4(-mRoot->getWidth() / 2, mRoot->getHeight() / 2, 0, 1);
    SE_Matrix4f localM;
    localM.setColumn(0, c1);
    localM.setColumn(1, c2);
    localM.setColumn(2, c3);
    localM.setColumn(3, c4);
    spatial->setPostMatrix(localM);
    return spatial;
}
Ejemplo n.º 8
0
SE_Vector4f SE_Quat::toRotate() const
{
    SE_Vector3f axis = SE_Vector3f(x, y, z);
    if (axis.isZero())
    {
        return SE_Vector4f();
    }
    SE_Vector3f axisNorm = axis.normalize();

    float cos = w;
    float radian = SE_Acosf(cos);			
    float angle =  SE_RadianToAngle(radian);
			
    SE_Vector4f rotate = SE_Vector4f(angle * 2.0, axisNorm.x, axisNorm.y, axisNorm.z) ;
    return rotate;
}
Ejemplo n.º 9
0
void View::setPosition(float x, float y) {
	mX = x;
	mY = y;
	SE_Matrix3f identity3;
	identity3.identity();

	SE_Matrix4f transform;
	transform.identity();

	transform.set(identity3,SE_Vector3f(mX,mY,0));

	setPrevMatrix(transform);

	//update
	updateWorldTransform();
	updateBoundingVolume();
}
Ejemplo n.º 10
0
/**
 *create a particle object
 *
 *@templateName template of particle, realize a particle effect
 *@particleName the name of particle object, we can find the object through particleName
 *@path the path of the particle texture image
 *@x the x-coordinate of the particle object position
 *@y the y-coordinate of the particle object position
 *@z the z-coordinate of the particle object position
*/
static void se_createParticleObject(JNIEnv* env, jobject clazz, jint effectIndex, jfloatArray cameraPos, jstring mainImagePath,
                                    jstring helpImagePath)
{
    const char* main = env->GetStringUTFChars(mainImagePath, NULL);
    const char* help = env->GetStringUTFChars(helpImagePath, NULL);

    float* camerapos = env->GetFloatArrayElements(cameraPos, 0);

    SE_Vector3f position = SE_Vector3f(camerapos[0], camerapos[1], camerapos[2]);
    ParticleSystemManager* particleSystemManager =  SE_Application::getInstance()->getParticleSystemManager();

    SE_Vector3f boxsize;
    particleSystemManager->createEffect((SE_Effect)effectIndex, position, main,help,boxsize);

    env->ReleaseStringUTFChars(mainImagePath, main);
    env->ReleaseStringUTFChars(helpImagePath, help);
    env->ReleaseFloatArrayElements(cameraPos, camerapos, 0);
}
Ejemplo n.º 11
0
void SE_BipedController::createBoneToWorldMatrix(int frameindex)
{

    //per frame refresh;
    mAfterTransformMatrixToWorld.clear();    

    for(int i = 0; i < oneBipAnimation.size(); ++i)
    {
        SE_Biped * bip = oneBipAnimation[i];

        SE_Matrix4f transform;        

        if(bip->animationInfo.size() == 0)
        {
            transform.identity();            
        }
        else
        {
            SE_Quat worldR = bip->animationInfo[frameindex]->rotateQ;
            SE_Vector3f worldT = bip->animationInfo[frameindex]->translate;
            SE_Vector3f worldS = bip->animationInfo[frameindex]->scale;
            
            //not use scale
            transform.set(worldR.toMatrix3f(),SE_Vector3f(1,1,1),worldT);//myTransform relate parent
        
        }

        SE_Matrix4f parentBoneToWorld;
        parentBoneToWorld.identity();


        if(bip->parent)
        {
            parentBoneToWorld = *(bip->parent->boneToWorldPerFrame[frameindex]);
        }
        else
        {
            //this bip is ROOT,the transform is world relative;
        }

        SE_Matrix4f tranToWorld = parentBoneToWorld.mul(transform);
        mAfterTransformMatrixToWorld.push_back(tranToWorld);
    }    
}
Ejemplo n.º 12
0
static void se_updateSceneLightPos(JNIEnv* env, jobject obj,jstring lightName,jfloatArray lightpos)
{
#if 0
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    const char* sceneLightName8 = env->GetStringUTFChars(lightName, 0);
    if(scene)
    {
        float* lpos = env->GetFloatArrayElements(lightpos, 0);
        SE_Vector3f pos = SE_Vector3f(lpos[0],lpos[1],lpos[2]);
        //scene->updateSceneLightPos(pos,sceneLightName8);

        env->ReleaseFloatArrayElements(lightpos, lpos, 0);
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
    env->ReleaseStringUTFChars(sceneName, sceneLightName8);
#endif
}
Ejemplo n.º 13
0
void SE_BipedController::fillBoneToWorldPerFrame()
{

    int maxFrameIndex = findMaxFrameIndex();

    for(int i = 0; i < oneBipAnimation.size(); ++i)
    {
        //get bip one by one
        SE_Biped *bip = oneBipAnimation[i];
        
        //fill bonetoworld for every frame
        for(int j = 0; j < maxFrameIndex + 1; ++j)
        {
            if(bip->parent)
            {
                SE_Matrix4f * m = new SE_Matrix4f();
                SE_Matrix4f myTrans;
                if(bip->animationInfo.size() > 0)
                {
                    //FIXME: the parent Allways has keyframe when child has keyframe
                    myTrans.set(bip->animationInfo[j]->rotateQ.toMatrix3f(),SE_Vector3f(1,1,1),bip->animationInfo[j]->translate);
                    *m = bip->parent->boneToWorldPerFrame[j]->mul(myTrans);
                }
                else
                {
                    //this bip on this frame has no key.
                    *m = bip->bind_pose;
                }
                bip->boneToWorldPerFrame.push_back(m);
            }
            else
            {
                //this bip is ROOT
                SE_Matrix4f * m = new SE_Matrix4f();
                *m = bip->bind_pose;
                bip->boneToWorldPerFrame.push_back(m);
            }

        }
       
    }

}
Ejemplo n.º 14
0
static void se_updateSceneLightDir(JNIEnv* env, jobject obj, jstring lightName,jfloatArray lightdir)
{
#if 0
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    const char* sceneLightName8 = env->GetStringUTFChars(lightName, 0);
    if(scene)
    {
        float* ldir = env->GetFloatArrayElements(lightdir, 0);
        SE_Vector3f dir = SE_Vector3f(ldir[0],ldir[1],ldir[2]);
        scene->updateSceneLightDir(dir,sceneLightName8);

        env->ReleaseFloatArrayElements(lightdir, ldir, 0);
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
    env->ReleaseStringUTFChars(sceneName, sceneLightName8);
#endif
}
Ejemplo n.º 15
0
static SE_RenderUnit* createSelectedFrame(SE_NewGeometry* spatial)
{
    SE_RenderUnit* ru = NULL;
    if(spatial)
    {
        SE_BoundingVolume* bv = spatial->getWorldBoundingVolume();
        if(bv)
        {
            SE_AABBBV* aabbBV = NULL;
            SE_SphereBV* sphereBV = NULL;
            SE_OBBBV* obbBV = NULL; 
            switch(bv->getType())
            {
            case SE_BoundingVolume::AABB:
                {
                    aabbBV = (SE_AABBBV*)bv;
                    SE_AABB aabb = aabbBV->getGeometry();
                    SE_Segment edge[12];
                    aabb.getEdge(edge);
                    ru = new SE_LineSegRenderUnit(edge, 12, SE_Vector3f(0, 1, 0));
                }
                break;
            case SE_BoundingVolume::SPHERE:
                {
                    sphereBV = (SE_SphereBV*)bv;
                }
                break;
            case SE_BoundingVolume::OBB:
                {
                    obbBV = (SE_OBBBV*)bv;
                }
                break;
            }
        }
    }
    return ru;
}
Ejemplo n.º 16
0
SE_Vector3f SE_BoundingVolume::getCenter()
{
    return SE_Vector3f();
}
Ejemplo n.º 17
0
SE_Vector3f SE_BipedController::convert(int vertexIndex,int frameindex,const char * objname, const SE_Vector3f& v)
{
    SE_Vector4f input;
    input.set(v,1);
    SE_Vector4f result(0,0,0,0);

    SE_SkeletonUnit *su = findSU(objname);

    //bipedIndex.size is number that how many bips effact this vertext.
    int bipNumPerVertex = su->objVertexBlendInfo[vertexIndex]->bipedIndex.size();  

    //how many bips will take effact to one vertex
    for(int i = 0; i < bipNumPerVertex; ++i)
    {
        int bipIndex = su->objVertexBlendInfo[vertexIndex]->bipedIndex[i];//bipIndex is start from 1, not 0.

        int bipindexfromcache = su->bipCache[bipIndex-1]->bipIndexOnBipAnimation;

        SE_Biped *bip = oneBipAnimation[bipindexfromcache];// find bip from all bips

        if(bip->animationInfo.size() == 0)
        {
            continue;
        }

#ifdef _FORDEBUG
        SE_Matrix4f bindpos = bip->bind_pose;
        SE_Matrix4f inversOfbp = bindpos.inverse();

        SE_Quat worldR = bip->animationInfo[frameindex]->rotateQ;
        SE_Vector3f worldT = bip->animationInfo[frameindex]->translate;
        SE_Vector3f worldS = bip->animationInfo[frameindex]->scale;

        SE_Matrix4f transform;
        transform.identity();
        //not use scale
        transform.set(worldR.toMatrix3f(),SE_Vector3f(1,1,1),worldT);//myTransform relate parent        

        SE_Matrix4f parentBoneToWorld;
        parentBoneToWorld.identity();

        if(bip->parent)
        {
            parentBoneToWorld = *(bip->parent->boneToWorldPerFrame[frameindex]);
        }
        else
        {
            //this bip is ROOT,the transform is world relative;
        }        

        SE_Matrix4f m = parentBoneToWorld.mul(transform).mul(inversOfbp);

        SE_Matrix4f m = mAfterTransformMatrixToWorld[bipindexfromcache].mul(mBindposeMatrixInverse[bipindexfromcache]);
#else
        SE_Matrix4f m = AllFrameFinalTransformMatrix[frameindex][bipindexfromcache];
#endif

        result = result + m.map(input) * su->objVertexBlendInfo[vertexIndex]->weight[i];
    }
    return result.xyz();
}
Ejemplo n.º 18
0
SE_Vector3f SE_RenderUnit::getColor()
{
    return SE_Vector3f(0, 0, 0);
}
Ejemplo n.º 19
0
SE_AABBBV::SE_AABBBV() : mAABB(SE_Vector3f(SE_FLT_MAX, SE_FLT_MAX, SE_FLT_MAX), 
                               SE_Vector3f(-SE_FLT_MAX, -SE_FLT_MAX, -SE_FLT_MAX))
{

}
Ejemplo n.º 20
0
SE_Vector3f SE_SphereBV::getCenter()
{
    return SE_Vector3f();
}
Ejemplo n.º 21
0
void ASE_Loader::Write(SE_BufferOutput& output, SE_BufferOutput& outScene, const char* shaderPath)
{
    int materialNum = mSceneObject->mMats.size();
	int numWhichHasSubmaterial = 0;
	int materialRealNum = materialNum;
    int i;
	for(i = 0 ; i < materialNum ; i++)
	{
		ASE_Material* srcm = &mSceneObject->mMats[i];
		materialRealNum += srcm->numsubmaterials;
		if(srcm->numsubmaterials > 0)
		{
			numWhichHasSubmaterial++;
		}
	}
    std::vector<_MaterialData> materialVector(materialRealNum);
    std::vector<int> indexWhichHasSubmaterial(numWhichHasSubmaterial);
	int l = 0;
	int mi = 0;
    for(i = 0 ; i < materialNum ; i++)
    {
        ASE_Material* srcm = &mSceneObject->mMats[i];
        _MaterialData md;
        md.subMaterialNum = srcm->numsubmaterials;
        md.md = srcm->materialData;
        materialVector[mi++] = md;
        if(srcm->numsubmaterials > 0)
        {
            indexWhichHasSubmaterial[l++] = i;
        }
    }
    std::vector<int>::iterator it;
    for(it = indexWhichHasSubmaterial.begin() ; it != indexWhichHasSubmaterial.end() ; it++)
    {
        int index = *it;
        ASE_Material* m = &mSceneObject->mMats[index];
        for(int j = 0 ; j < m->numsubmaterials ; j++)
        {
            _MaterialData md;
            md.subMaterialNum = 0;
            md.md = m->submaterials[j];
            materialVector[mi++] = md;

        }
    }
    std::vector<_MaterialData>::iterator itMaterial;
    output.writeShort(SE_MATERIALDATA_ID);
	output.writeInt(materialVector.size());
	int mmm = materialVector.size();
    //for(itMaterial = materialVector.begin() ; itMaterial != materialVector.end() ; itMaterial++)
    for(i = 0 ; i < materialVector.size() ; i++)
    {
        SE_MaterialDataID mid = SE_Application::getInstance()->createCommonID();
        mid.print();
		SE_Util::sleep(SLEEP_COUNT);
        materialVector[i].mid = mid;
        mid.write(output);
        output.writeVector3f(materialVector[i].md.ambient);
        output.writeVector3f(materialVector[i].md.diffuse);
        output.writeVector3f(materialVector[i].md.specular);
        output.writeVector3f(SE_Vector3f(0, 0, 0));
    }
    /////////////////////////////write texture data ///////////////
    output.writeShort(SE_IMAGEDATA_ID);
    int imageDataNum = 0;
    for(itMaterial = materialVector.begin() ; itMaterial != materialVector.end() ; itMaterial++)
    {
        std::string texStr(itMaterial->md.texName);
        if(texStr != "")
        {
            imageDataNum++;
        }
    }
    output.writeInt(imageDataNum);
    for(itMaterial = materialVector.begin() ; itMaterial != materialVector.end() ; itMaterial++)
    {
        std::string texStr(itMaterial->md.texName);
        if(texStr != "")
        {
            size_t pos = texStr.find('.');
            std::string name = texStr.substr(0, pos);
            name = name + ".raw";
			SE_ImageDataID tid = texStr.c_str();
            itMaterial->tid = tid;
            tid.write(output);
            output.writeInt(0); // image data type
            output.writeString(name.c_str());
        }
    }
    /////////////////////////////write geom data /////////////////////////////////////////////
    output.writeShort(SE_GEOMETRYDATA_ID);
    int geomDataNum = mSceneObject->mGeomObjects.size();
    output.writeInt(geomDataNum);
    std::vector<_GeomTexCoordData> geomTexCoordData(geomDataNum);
    std::list<ASE_GeometryObject*>::iterator itGeomObj;
    int n = 0;
    SE_Matrix4f modelToWorldM, worldToModelM;
    SE_Matrix3f rotateM;
	SE_Quat rotateQ;
    SE_Vector3f rotateAxis, scale, translate;
    for(itGeomObj = mSceneObject->mGeomObjects.begin();
        itGeomObj != mSceneObject->mGeomObjects.end();
        itGeomObj++)
    {
        ASE_GeometryObject* go = *itGeomObj;
        ASE_Mesh* mesh = go->mesh;
        SE_GeometryDataID gid = SE_Application::getInstance()->createCommonID();
        SE_Util::sleep(SLEEP_COUNT);
        rotateAxis.x = go->rotateAxis[0];
        rotateAxis.y = go->rotateAxis[1];
        rotateAxis.z = go->rotateAxis[2];
        scale.x = go->scale[0];
        scale.y = go->scale[1];
        scale.z = go->scale[2];
        translate.x = go->translate[0];
        translate.y = go->translate[1];
        translate.z = go->translate[2];
		rotateQ.set(go->rotateAngle, rotateAxis);
		rotateM = rotateQ.toMatrix3f();//.setRotateFromAxis(go->rotateAngle, rotateAxis);
        modelToWorldM.set(rotateM, scale, translate);
        worldToModelM = modelToWorldM.inverse();
        geomTexCoordData[n++].geomID = gid;
        gid.write(output);
        output.writeInt(mesh->numVertexes);
        output.writeInt(mesh->numFaces);
        output.writeInt(0);
        int i;
        for(i = 0 ; i < mesh->numVertexes ; i++)
        {
            SE_Vector4f p(mesh->vertexes[i].x, mesh->vertexes[i].y, mesh->vertexes[i].z, 1.0f);
            p = worldToModelM.map(p);
            output.writeFloat(p.x);
            output.writeFloat(p.y);
            output.writeFloat(p.z);
        }
        for(i = 0 ; i < mesh->numFaces ; i++)
        {
            output.writeInt(mesh->faces[i].vi[0]);
            output.writeInt(mesh->faces[i].vi[1]);
            output.writeInt(mesh->faces[i].vi[2]);
        }
    }

    ////////////////////////write texture coordinate///////////////////////////////////////////////
    output.writeShort(SE_TEXCOORDDATA_ID);
    output.writeInt(geomDataNum);
    n = 0;
    for(itGeomObj = mSceneObject->mGeomObjects.begin();
    itGeomObj != mSceneObject->mGeomObjects.end();
    itGeomObj++)
    {
        ASE_GeometryObject* go = *itGeomObj;
        ASE_Mesh* mesh = go->mesh;
        SE_TextureCoordDataID tcid = SE_Application::getInstance()->createCommonID();
        SE_Util::sleep(SLEEP_COUNT);
        tcid.write(output);
        geomTexCoordData[n++].texCoordID = tcid;
        output.writeInt(mesh->numTVertexes);
        output.writeInt(mesh->numFaces);
        int i;
        for(i = 0 ; i < mesh->numTVertexes ; i++)
        {
            output.writeFloat(mesh->tvertexes[i].s);
            output.writeFloat(mesh->tvertexes[i].t);
        }
        for(i = 0 ; i < mesh->numFaces ; i++)
        {
            output.writeInt(mesh->tfaces[i].vi[0]);
            output.writeInt(mesh->tfaces[i].vi[1]);
            output.writeInt(mesh->tfaces[i].vi[2]);
        }
    }
///////////////////// write shader program ////
    output.writeShort(SE_SHADERPROGRAMDATA_ID);
    int spNum = 1;
    output.writeInt(spNum);// shader program num;
    std::vector<SE_ProgramDataID> programDataVector(spNum);
    for(i = 0 ; i < spNum ; i++)
    {
        SE_ProgramDataID proID = "main_vertex_shader";
        programDataVector[i] = proID;
        SE_Util::sleep(SLEEP_COUNT);
        proID.write(output);
        std::string str(shaderPath);
        std::string vertexShaderPath = str + SE_SEP + "main_vertex_shader.glsl";
        std::string fragmentShaderPath = str + SE_SEP + "main_fragment_shader.glsl";
        char* vertexShader = NULL;
        int vertexShaderLen = 0;
        char* fragmentShader = NULL;
        int fragmentShaderLen = 0;
        SE_IO::readFileAll(vertexShaderPath.c_str(), vertexShader, vertexShaderLen);
        SE_IO::readFileAll(fragmentShaderPath.c_str(), fragmentShader, fragmentShaderLen);
        output.writeInt(vertexShaderLen);
        output.writeInt(fragmentShaderLen);
        output.writeBytes(vertexShader, vertexShaderLen);
        output.writeBytes(fragmentShader, fragmentShaderLen);
        delete[] vertexShader;
        delete[] fragmentShader;
    }
///////////////////// write mesh //////////////// 
    std::vector<SE_MeshID> meshIDVector(geomDataNum);
    output.writeShort(SE_MESHDATA_ID);
    output.writeInt(geomDataNum);
    n = 0;
    for(itGeomObj = mSceneObject->mGeomObjects.begin();
    itGeomObj != mSceneObject->mGeomObjects.end();
    itGeomObj++)
    {
        ASE_GeometryObject* go = *itGeomObj;
        ASE_Mesh* mesh = go->mesh;
        SE_MeshID meshID = SE_Application::getInstance()->createCommonID();
        SE_Util::sleep(SLEEP_COUNT);
        meshID.write(output);
        meshIDVector[n] = meshID;
        SE_GeometryDataID geomID = geomTexCoordData[n].geomID;
        SE_TextureCoordDataID texCoordID = geomTexCoordData[n].texCoordID;
        n++;
        geomID.write(output);
        output.writeFloat(go->wireframeColor[0]);
        output.writeFloat(go->wireframeColor[1]);
        output.writeFloat(go->wireframeColor[2]);
        int texNum = 0;
        int materialref = go->materialref;
        int startpos = 0;
        int subMaterialStartPos = 0;
        _MaterialData mdData;
        if(materialref == -1)
        {
            output.writeInt(texNum);
            goto WRIET_SURFACE;
        }
        mdData = materialVector[materialref];
        if(mdData.subMaterialNum > 0)
        {
            int j;
            for(j = 0 ; j < (materialref - 1) ; j++)
            {
                _MaterialData d = materialVector[j];
                startpos += d.subMaterialNum;
            }
            int k = startpos;
            for(int j = 0 ; j < mdData.subMaterialNum ; j++)
            {
                _MaterialData subMaterialData = materialVector[materialNum + k];
                k++;
                std::string texStr(subMaterialData.md.texName);
                if(texStr != "")
                {
                    texNum++;
                }
            }
        }
        else
        {
            std::string texStr(mdData.md.texName);
            if(texStr != "")
            {
                texNum = 1;
            }
        }
        output.writeInt(texNum);
        for(i = 0 ; i < texNum ; i++)
        {
            if(mdData.subMaterialNum > 0)
            {
                int j;
                for(j = 0 ; j < (materialref - 1) ; j++)
                {
                    _MaterialData d = materialVector[j];
                    subMaterialStartPos += d.subMaterialNum;
                }
                for(int j = 0 ; j < mdData.subMaterialNum ; j++)
                {
                    _MaterialData subMaterialData = materialVector[materialNum + subMaterialStartPos];
                    subMaterialStartPos++;
                    std::string texStr(subMaterialData.md.texName);
                    if(texStr != "")
                    {
                        output.writeInt(1);//current we just has one texture unit;
                        output.writeInt(0);//texture unit type is TEXTURE0
                        texCoordID.write(output);
                        output.writeInt(1);//image num use in the texture unit. current it is not mipmap. so the num is 1
                        subMaterialData.tid.write(output);

                    }
                }
            }
            else
            {
                std::string texStr(mdData.md.texName);
                if(texStr != "")
                {
                    output.writeInt(1);//current we just has one texture unit;
                    output.writeInt(0);//texture unit type is TEXTURE0
                    texCoordID.write(output);
                    output.writeInt(1);//image num use in the texture unit. current it is not mipmap. so the num is 1
                    mdData.tid.write(output);
                }
            }
            
        }
        ///write surface
WRIET_SURFACE:
        if(mesh->numFaceGroup > 0)
        {
            SE_ASSERT(mesh->numFaceGroup == mesh->faceGroup.size());
            output.writeInt(mesh->numFaceGroup);
            std::vector<std::list<int> >::iterator itFaceGroup;
            int indexM = startpos;
            int texIndex = 0;
            for(itFaceGroup = mesh->faceGroup.begin() ; itFaceGroup != mesh->faceGroup.end(); itFaceGroup++)
            {
                _MaterialData md = materialVector[materialNum + indexM];
                std::string texStr(md.md.texName);
                md.mid.write(output);
                output.writeInt(itFaceGroup->size());
                std::list<int>::iterator itFace;
                for(itFace = itFaceGroup->begin() ; itFace != itFaceGroup->end() ; 
					itFace++)
                {
                    output.writeInt(*itFace);
                }
                programDataVector[0].write(output);
                if(texStr != "")
                {
                    output.writeInt(texIndex);
                }
                else
                {
                    output.writeInt(-1);
                }
                indexM++;
                texIndex++;
            }
        } 
        else
        {
            output.writeInt(1); //just has one surface
            std::string texStr(mdData.md.texName);
            mdData.mid.write(output);
            output.writeInt(mesh->numFaces); // facets num;
            for(int f = 0 ; f < mesh->numFaces ; f++)
                output.writeInt(f);
            programDataVector[0].write(output);
            if(texStr != "")
            {
                output.writeInt(0); // the texture index is 0;
            }
            else
            {
                output.writeInt(-1);
            }
        }
    }
    /////// create scene //////////
    SE_SpatialID spatialID = SE_Application::getInstance()->createCommonID();
    SE_Util::sleep(SLEEP_COUNT);
    SE_CommonNode* rootNode = new SE_CommonNode(spatialID, NULL);
    rootNode->setBVType(SE_BoundingVolume::AABB);
    n = 0;
    for(itGeomObj = mSceneObject->mGeomObjects.begin();
    itGeomObj != mSceneObject->mGeomObjects.end();
    itGeomObj++)
    {
        ASE_GeometryObject* go = *itGeomObj;
        ASE_Mesh* mesh = go->mesh;
        SE_MeshID meshID = meshIDVector[n++];
        SE_SpatialID childID = SE_Application::getInstance()->createCommonID();
        SE_Util::sleep(SLEEP_COUNT);
        SE_Geometry* child = new SE_Geometry(childID, rootNode);
        rootNode->addChild(child);
        SE_Vector3f translate, scale, rotateAxis;
        translate.x = go->translate[0];
        translate.y = go->translate[1];
        translate.z = go->translate[2];
        scale.x = go->scale[0];
        scale.y = go->scale[1];
        scale.z = go->scale[2];
        rotateAxis.x = go->rotateAxis[0];
        rotateAxis.y = go->rotateAxis[1];
        rotateAxis.z = go->rotateAxis[2];
        child->setLocalTranslate(translate);
		//child->setLocalTranslate(SE_Vector3f(0, 0, 0));
        child->setLocalScale(scale);
        //child->setLocalScale(SE_Vector3f(1.0, 1.0, 1.0));
        SE_Quat q;
        q.set(go->rotateAngle, rotateAxis);
        child->setLocalRotate(q);
		//q.set(0, SE_Vector3f(0, 0, 0));
        child->setBVType(SE_BoundingVolume::AABB);
        SE_MeshSimObject* meshObj = new SE_MeshSimObject(meshID);
		meshObj->setName(go->name);
        child->attachSimObject(meshObj);
    }
    SE_SceneID sceneID = SE_Application::getInstance()->createCommonID();
    SE_Util::sleep(SLEEP_COUNT);
    sceneID.write(outScene);
	_WriteSceneTravel wst(outScene);
	rootNode->travel(&wst, true);
    LOGI("write end\n");
}