Example #1
0
static void se_setRoot(JNIEnv* env, jobject obj, jstring rootName, jint index)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if (scene)
    {
        const char* rootName8 = env->GetStringUTFChars(rootName, 0);
        SE_Spatial* spatial = SE_Application::getInstance()->getSceneManager()->findSpatialByName(rootName8, index);
        if (!spatial) {
            spatial = new SE_CommonNode(SE_ID::createSpatialID());
            spatial->setIsEntirety(true);
            spatial->setSpatialName(rootName8);
            spatial->setCloneIndex(index);
            //save spatial name to map
            /*SE_SpatialManager* sm = SE_Application::getInstance()->getSpatialManager();
            sm->set(spatial->getSpatialName(),spatial);*/
            spatial->updateWorldLayer();
            spatial->updateWorldTransform();
            spatial->updateBoundingVolume();
        } 
        scene->setRoot(spatial);
        env->ReleaseStringUTFChars(rootName, rootName8);
        
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
}
Example #2
0
SE_Spatial *SE_Geometry::clone(SE_SimObject *srcobj, int index)
{
#if 0
    SE_Geometry * dest = new SE_Geometry();

    SE_SimObject* destobj = srcobj->clone(index);
    
    std::string srcobjname = srcobj->getName();

    //attach obj
    SE_SimObjectManager* simObjectManager = SE_Application::getInstance()->getSimObjectManager();

    SE_SimObjectID id = SE_ID::createSimObjectID();
    destobj->setID(id);
    simObjectManager->set(id, destobj);

    

    //set spatial property
    SE_Spatial *srcSpatial = srcobj->getSpatial();

    SE_SpatialID destSpatialID = SE_ID::createSpatialID();

    dest->setSpatialID(destSpatialID);

    dest->setBVType(srcSpatial->getBVType());

    SE_Vector3f a = srcSpatial->getLocalTranslate();
    dest->setLocalTranslate(a);

    dest->setLocalRotate(srcSpatial->getLocalRotate());

    dest->setLocalScale(srcSpatial->getLocalScale());

    dest->setPrevMatrix(srcSpatial->getPrevMatrix());

    dest->setPostMatrix(srcSpatial->getPostMatrix());

    dest->setParent(srcSpatial->getParent());


    dest->setLocalLayer(srcSpatial->getLocalLayer());

    //set render state
    dest->setRenderState(DEPTHTESTSTATE ,this->getRenderState(DEPTHTESTSTATE));


    dest->attachSimObject(destobj);
    //SE_Application::getInstance()->getSceneManager()->updateSpatialIDMap();
    SE_Scene* scene = srcSpatial->getScene();
    scene->addSpatial(srcSpatial->getParent(), dest);
    srcSpatial->getParent()->updateWorldTransform();
    srcSpatial->getParent()->updateBoundingVolume();
    srcSpatial->getParent()->updateRenderState();
    srcSpatial->getParent()->updateWorldLayer();
    //return clone object
    return dest;
#endif
    return NULL;
}
Example #3
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);
}
SE_SceneManager::_PointedData SE_SceneManager::getPointedData(float x, float y)
{
    std::list<SE_Scene*> sceneMotionEvent = getMotionEventScene();
	std::list<SE_Scene*>::iterator itScene;
	SE_SceneRenderSeq sceneRenderSeq = -1;
	SE_Element* pointedElement = NULL;
	SE_Scene* pointedScene = NULL;
	SE_ElementManager* elementManager = SE_Application::getInstance()->getElementManager();
	for(itScene = sceneMotionEvent.begin() ; itScene != sceneMotionEvent.end(); itScene++)
	{
		SE_Scene* scene = *itScene;
		SE_Element* e = scene->getPointedElement(x, y);
		if(e)
		{
			LOGI("### pointed element = %s ## \n", e->getName().getStr());
            if(e->getSceneRenderSeq() > sceneRenderSeq)
			{
				pointedElement = e;
				pointedScene = scene;
				sceneRenderSeq = e->getSceneRenderSeq();
			}
		}
	}
	return _PointedData(pointedScene, pointedElement);
}
Example #5
0
SE_Camera* SE_Application::getUICamera()
{
	SE_Scene* scene = mSceneManager->getScene(SE_FRAMEBUFFER_SCENE,"GUI");
    if (scene)
    {
        return scene->getCamera();
    }
    return NULL;

}
Example #6
0
/*
void SE_Application::setCamera(int index, SE_Camera* camera)
{
	if(index < 0 || index >= MAX_CAMERA_NUM)
		return;
    SE_Camera* c = mCameraArray[index];
	if(c)
		delete c;
	mCameraArray[index] = camera;
}
SE_Camera* SE_Application::getCamera(int index)
{
	if(index < 0 || index >= MAX_CAMERA_NUM)
		return NULL;
	return mCameraArray[index];
}
void SE_Application::setCurrentCamera(int index)
{
	if(index < 0 || index >= MAX_CAMERA_NUM)
		return;
	mCurrentCamera = mCameraArray[index];
}
*/
SE_Camera* SE_Application::getCurrentCamera()
{
	//return mCurrentCamera;
	SE_Scene* scene = mSceneManager->getMainScene();
    if (scene)
    {
        return scene->getCamera();
    }
    return NULL;
}
Example #7
0
/**
 *set scene manager
 *
 *@type the type of scene manager
*/
static void se_setSceneType(JNIEnv* env, jobject obj, jint type)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if(scene)
    {      
        scene->setSceneManagerType(type);
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);    
}
Example #8
0
static void se_refreshSceneLightStatus(JNIEnv* env, jobject obj)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if(scene)
    {
        scene->refreshSceneLightStatus();
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
}
Example #9
0
static void se_setLowestBrightness(JNIEnv* env, jobject obj, jfloat lowestBrightnesss)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if(scene)
    {
        scene->setLowestEnvBrightness(lowestBrightnesss);        
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
}
Example #10
0
static void se_removeAllLight(JNIEnv* env, jobject obj, jint lighttype)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if(scene)
    {
        scene->removeAllLights();
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
}
void SE_NetDataCommand::handle(SE_TimeMS realDelta, SE_TimeMS simulateDelta)
{
	SE_ASSERT(mMsg->len >= 3);
	int id = mMsg->data[0];
	unsigned short dataLen = 0;
	memcpy(&dataLen, mMsg->data + 1, 2);
    dataLen = SE_Util::net2HostInt16(dataLen);
	int realDataLen = dataLen - 3;
	std::string str;
	if(realDataLen > 0)
	{
		str.assign((char*)mMsg->data + 3, realDataLen);
	}
	for(int i = 0 ; i < mMsg->len ; i++)
	{
		LOGI("%d\n", mMsg->data[i]);
	}
	LOGI("### msg len = %d , str = %s ###\n", mMsg->len, str.c_str());
	if(id == 0 && str.size() > 0)
	{
		SE_ImageUnit iu;
		SE_ResourceManager* resourceManager = SE_GET_RESOURCEMANAGER();
		SE_ImageData* imageData = resourceManager->loadImageWithFullPath(str.c_str());
		if(!imageData)
		{
			LOGI("can not load image\n");
			return;
		}
		iu.imageDataID = str.c_str();
		iu.imageRect.x = 0;
		iu.imageRect.y = 0;
		iu.imageRect.width = imageData->getWidth();
		iu.imageRect.height = imageData->getHeight();
		SE_ImageElement* imageElement = new SE_ImageElement("");
		imageElement->setBaseColor(iu);
		SE_SceneManager* sceneManager = SE_Application::getInstance()->getSceneManager();
		SE_Scene* scene = new SE_2DScene;
		scene->setBackground(SE_Vector4f(1.0f, 1.0f, 1.0f, 1.0f));
		scene->setBound(480, 800);
		scene->setRootElement(imageElement);
		SE_SceneID sceneID = sceneManager->add(scene);
		//create camera
		SE_Camera* camera = SE_Camera::create2DSceneCamera(480, 800);
		SE_CameraManager* cameraManager = SE_Application::getInstance()->getCameraManager();
		SE_CameraID cameraID = cameraManager->add(camera);
		scene->setCamera(cameraID);
		//end
		sceneManager->show(sceneID);
	}
	else
	{

	}
}
Example #12
0
static void se_setIsTranslucent(JNIEnv* env, jobject obj, jboolean translucent)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if (scene)
    {
        scene->setIsTranslucent(translucent);
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);

}
Example #13
0
static void se_removeLightFromScene(JNIEnv* env, jobject obj, jstring lightName) {
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if(scene)
    {
        const char* lightName8 = env->GetStringUTFChars(lightName, 0);
        scene->removeLight(lightName8);
        env->ReleaseStringUTFChars(lightName, lightName8);
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
}
Example #14
0
static void se_inflateResource(JNIEnv* env, jobject obj, jint resource, jstring objName, jint objIndex, jstring nodeName, jint nodeIndex, jboolean removeTopNode)
{
    //Invoke by gl thread
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    const char* nodeName8 = env->GetStringUTFChars(nodeName, NULL);
    const char* objName8 = env->GetStringUTFChars(objName, NULL);
    SE_Scene* scene =  SE_Application::getInstance()->getSceneManager()->getScene(SE_FRAMEBUFFER_SCENE, SE_StringID(sceneName8));
    SE_Spatial* node = SE_Application::getInstance()->getSceneManager()->findSpatialByName(nodeName8, nodeIndex);
    SE_Spatial* s = (SE_Spatial*)resource;
    if (!node)
    {
        env->ReleaseStringUTFChars(sceneName, sceneName8);
        env->ReleaseStringUTFChars(nodeName, nodeName8);
        env->ReleaseStringUTFChars(objName, objName8);
        return;
    }
    if (s) {
        SE_ResourceManager* m = SE_Application::getInstance()->getResourceManager();
        SE_ResourceManager* loader = s->getCBFLoader();
        m->copy(loader);
        s->deleteCBFLoader();

        if (removeTopNode) {
            s->getChildByIndex(0)->setSpatialName(objName8);
            s->getChildByIndex(0)->setCloneIndex(objIndex);
            s->replaceChildParent(node);
            node->setCloneIndex(objIndex);
            scene->inflate();
            node->updateWorldTransform();
            node->updateBoundingVolume();
            node->updateWorldLayer();
            delete s;
        } else {
            s->setSpatialName(objName8);
            s->setCloneIndex(objIndex);
            std::string modelName = objName8;
            modelName = modelName + "_model";
            s->getChildByIndex(0)->setSpatialName(modelName.c_str());
            s->getChildByIndex(0)->setCloneIndex(objIndex);
            scene->addSpatial(node, s);
            scene->inflate();
            node = scene->getRoot();
            node->updateWorldTransform();
            node->updateBoundingVolume();
            node->updateWorldLayer();
        }

    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
    env->ReleaseStringUTFChars(nodeName, nodeName8);
    env->ReleaseStringUTFChars(objName, objName8);
}
Example #15
0
static void se_setRoot_II(JNIEnv* env, jobject obj, jint object)
{
    if (object > 0)
    {
        jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
        const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
        SE_Scene* scene = findScene(sceneName8);
        if (scene)
        {
            scene->setRoot((SE_Spatial*)object);
        }
        env->ReleaseStringUTFChars(sceneName, sceneName8);
    }
}
Example #16
0
static void se_createScene(JNIEnv* env, jobject obj)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);

    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if (!scene) {
       scene = new SE_Scene(sceneName8);
       SE_Application::getInstance()->getSceneManager()->pushBack(SE_FRAMEBUFFER_SCENE, scene);
       SE_Camera* camera = new SE_Camera();
       scene->inflate("assets/base/scene_resource.xml");
       scene->setCamera(camera);
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
}
Example #17
0
static void se_setVisibility(JNIEnv* env, jobject obj, jboolean visibility)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if (scene)
    {
        if (visibility) {
            scene->setVisibility(SE_VISIBLE);
        } else {
            scene->setVisibility(SE_NOVISIBLE);
        }
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);

}
Example #18
0
static void se_changeSceneShader(JNIEnv* env, jobject obj,jstring shaderName,jstring renderName)
{
    jstring sceneName = (jstring)env->GetObjectField(obj, sceneNameID);
    const char* sceneName8 = env->GetStringUTFChars(sceneName, 0);
    SE_Scene* scene = findScene(sceneName8);
    if(scene)
    {
        const char* shadername = env->GetStringUTFChars(shaderName, 0);
        const char* rendername = env->GetStringUTFChars(renderName, 0);
        scene->changeSceneShader(shadername,rendername);

        env->ReleaseStringUTFChars(shaderName, shadername);
        env->ReleaseStringUTFChars(renderName, rendername);
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
}
void SE_SceneManager::show(const SE_SceneID& id)
{
    SE_Scene* scene = get(id);
    if(scene == NULL)
        return;
    if(id == top())
        return;
    _SceneStack::iterator it;
    for(it = mStack.begin() ; it != mStack.end() ; it++)
    {
        if(id == *it)
            break;
    }
    if(it != mStack.end())
        mStack.erase(it);
    mStack.push_front(id);
    scene->show();
}
Example #20
0
static void se_updateSceneLightSpotData(JNIEnv* env, jobject obj, jstring lightName,jfloatArray spotlightdata)
{
#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* lspotdata = env->GetFloatArrayElements(spotlightdata, 0);
        SE_Vector4f spotdata = SE_Vector4f(lspotdata[0],lspotdata[1],lspotdata[2],lspotdata[3]);
        scene->updateSceneLightSpotData(spotdata,sceneLightName8);

        env->ReleaseFloatArrayElements(spotlightdata, lspotdata, 0);
    }
    env->ReleaseStringUTFChars(sceneName, sceneName8);
    env->ReleaseStringUTFChars(sceneName, sceneLightName8);
#endif
}
Example #21
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
}
void SE_SceneManager::render(SE_RenderManager& renderManager)
{
    std::list<SE_Scene*> sceneNeedRender;
    _SceneStack::iterator it;
    for(it = mStack.begin() ; it != mStack.end() ; it++)
    {
        SE_SceneID sid = *it;
        SE_Scene* scene = get(sid);
        if(scene)
        {
            if(scene->isTranslucent())
            {
                sceneNeedRender.push_front(scene);
            }
            else
            {
                sceneNeedRender.push_front(scene);
                break;
            }
        }
    }    
    if(sceneNeedRender.size() >= SE_MAX_RENDERSCENE_SIZE)
    {
        LOGE("scene size exceed the max size\n");
        return;
    }
    int seq = sceneNeedRender.size() - 1;
    std::list<SE_Scene*>::iterator itScene;
    SE_CameraManager* cameraManager = SE_Application::getInstance()->getCameraManager();
    for(itScene = sceneNeedRender.begin() ; itScene != sceneNeedRender.end() ; itScene++)
    {
        SE_Scene* scene = *itScene;
        scene->render(seq, renderManager);
        seq--;
    }
	if(mCursor)
	{
	    seq = sceneNeedRender.size();
		mCursor->render(seq, renderManager);
	}
    
}
/*
void SE_SceneManager::handleMotionEvent(SE_Element* pointedElement, const SE_MotionEvent& motionEvent)
{
	SE_ElementManager* elementManager = SE_Application::getInstance()->getElementManager();
	if(mPrevMotionEventType == SE_MotionEvent::UP && motionEvent.getType() == SE_MotionEvent::DOWN)
	{
		mPrevMotionEventType = SE_MotionEvent::DOWN;
		mPrevX = motionEvent.getX();
		mPrevY = motionEvent.getY();
		if(pointedElement)
		{
	        mMotionDownElementID = pointedElement->getID();
	        pointedElement->setState(SE_Element::HIGHLIGHTED, true);
		}
		LOGI("#### motion event down ###\n");
	}
	else if((mPrevMotionEventType == SE_MotionEvent::DOWN || mPrevMotionEventType == SE_MotionEvent::MOVE)&& 
		    motionEvent.getType() == SE_MotionEvent::DOWN)
	{
        float deltaX = motionEvent.getX() - mPrevX;
		float deltaY = motionEvent.getY() - mPrevY;
		if(mPrevMotionEventType == SE_MotionEvent::DOWN && 
			(SE_Fabs(deltaX) > SE_MotionEvent::MOVE_SLOPE || SE_Fabs(deltaY) > SE_MotionEvent::MOVE_SLOPE))
		{
			mPrevMotionEventType = SE_MotionEvent::MOVE;
		}
		if(mPrevMotionEventType == SE_MotionEvent::MOVE)
		{
			LOGI("#### motion event move ###\n");
			if(pointedElement)
			    mMotionMoveElementID = pointedElement->getID();
			if(mMotionMoveElementID != mMotionDownElementID)
			{
				SE_Element* e = elementManager->get(mMotionDownElementID);
				if(e)
				{
					e->setState(SE_Element::NORMAL, true);
				}
			}
			mPrevX = motionEvent.getX();
			mPrevY = motionEvent.getY();
		}
 	}
	else if(motionEvent.getType() == SE_MotionEvent::UP && mPrevMotionEventType == SE_MotionEvent::MOVE)
	{
		if(pointedElement)
		    mMotionMoveElementID = pointedElement->getID();
		mPrevMotionEventType = SE_MotionEvent::UP;
	    if(mMotionMoveElementID != mMotionDownElementID)
		{
			SE_Element* e = elementManager->get(mMotionDownElementID);
			if(e)
			{
				e->setState(SE_Element::NORMAL, true);
			}
		}
	}
	else if(motionEvent.getType() == SE_MotionEvent::UP && mPrevMotionEventType == SE_MotionEvent::DOWN)
	{
		LOGI("#### motion event up ###\n");
		if(pointedElement)
            mMotionUpElementID = pointedElement->getID();
		mPrevMotionEventType = SE_MotionEvent::UP;
		if(mMotionDownElementID == mMotionUpElementID && pointedElement)
		{
			LOGI("#### motion event click ###\n");
			pointedElement->setState(SE_Element::NORMAL, true);
			pointedElement->click();
		}
		else
		{
			SE_Element* e = elementManager->get(mMotionDownElementID);
			if(e)
			{
				e->setState(SE_Element::NORMAL, true);
			}
		}
	}   
}
*/
std::list<SE_Scene*> SE_SceneManager::getMotionEventScene()
{
    std::list<SE_Scene*> sceneMotionEvent;
    _SceneStack::iterator it;
    for(it = mStack.begin() ; it != mStack.end() ; it++)
    {
        SE_SceneID sid = *it;
        SE_Scene* scene = get(sid);
        if(scene)
        {
			if(!scene->isModel())
            {
                sceneMotionEvent.push_back(scene);
            }
            else
            {
                sceneMotionEvent.push_back(scene);
                break;
            }
        }
    } 
	return sceneMotionEvent;
}
Example #24
0
void SE_Geometry::inflate()
{
    if(this->isInflate())
    {
        return;
    }
    //send light to scene
    SE_Scene* scene = this->getScene();
    if(!scene)
    {
        if(SE_Application::getInstance()->SEHomeDebug)
        LOGI("Error!! geometry inflate fail,scene not found!!!\n\n");
        return;
    }
    this->setHasInflate(true);
    //add all light into scene
    std::vector<SE_Light*>::iterator it;
    for(it = mLightsForInflate.begin(); it != mLightsForInflate.end();)
    {
        SE_Light* l = *it;
        bool result = scene->_gatherLight(l);//scene will collect all light info
        if(!result)
        {
            //light has been in scene
            it = mLightsForInflate.erase(it);
            delete l;

        }
        else
        {
            it++;
        }
    }
    mLightsForInflate.clear();

}
Example #25
0
SE_Spatial *SE_Geometry::clone(SE_Spatial* parent,  int index,bool createNewMesh,const char* statuslist)
{
    if(!parent)
    {
        if(SE_Application::getInstance()->SEHomeDebug)
        LOGI("No parent,clone fail.!!!!");
        return NULL;
    }

    SE_Geometry * dest = new SE_Geometry();

    SE_SimObject* destobj = getCurrentAttachedSimObj()->clone(index,createNewMesh);

    dest->setSpatialName(this->getSpatialName());
    dest->setCloneIndex(index);
    
    
    //attach obj
    dest->attachSimObject(destobj);    

    //set spatial property

    dest->setBVType(getBVType());

    SE_Vector3f a = getLocalTranslate();
    dest->setLocalTranslate(a);

    dest->setLocalRotate(getLocalRotate());

    dest->setLocalScale(getLocalScale());

    dest->setPrevMatrix(getPrevMatrix());

    dest->setPostMatrix(getPostMatrix());

    dest->setParent(parent);

    SE_Layer* l = this->getWorldLayer();
    SE_Layer* destL = dest->getWorldLayer();
    destL->setLayer(l->getLayer());    

    //set render state
    dest->setRenderState(DEPTHTESTSTATE ,this->getRenderState(DEPTHTESTSTATE));
    

    //SE_Application::getInstance()->getSceneManager()->updateSpatialIDMap();
    SE_Scene* scene = getScene();
    scene->addSpatial(parent, dest);

    parent->updateWorldTransform();
    parent->updateBoundingVolume();
    parent->updateRenderState();
    //parent->updateWorldLayer();

    //copy geometry para
    dest->setHasInflate(true);
    
    dest->setAlpha(this->getAlpha());
    

    unsigned int status = 0;
    if(statuslist)
    {
        status = SE_Util::stringToInt(statuslist);
    }
    dest->setEffectState(status);

    dest->setSpatialState(this->getSpatialState());

    dest->setSpatialEffectData(this->getSpatialEffectData());

    std::vector<std::string> lights;
    this->getLightsNameList(lights);
    for(int i = 0; i < lights.size(); ++i)
    {
        dest->addLightNameToList(lights[i].c_str());
    }

    scene->sceneApplyLight();
    
    //return clone object
    return dest;
}