示例#1
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;
}
示例#2
0
void SE_Camera::rotateLocal(const SE_Quat& rotate)
{
    SE_Vector3f localxAxis(1, 0, 0);
    SE_Vector3f localyAxis(0, 1, 0);
    SE_Vector3f localzAxis(0, 0, 1);
    localxAxis = rotate.map(localxAxis);
    localyAxis = rotate.map(localyAxis);
    //localzAxis = rotate.map(zAxis);
    SE_Matrix4f vtom = getViewToWorldMatrix();
    SE_Vector4f worldxAxis = vtom.map(SE_Vector4f(localxAxis, 0));
    SE_Vector4f worldyAxis = vtom.map(SE_Vector4f(localyAxis, 0));
    //SE_Vector4f worldzAxis = vtom.map(SE_Vector4f(localzAxis, 0));
	SE_Vector4f worldzAxis(worldxAxis.xyz().cross(worldyAxis.xyz()), 0);
    mAxisX = worldxAxis.normalize().xyz();
    mAxisY = worldyAxis.normalize().xyz();
    mAxisZ = worldzAxis.normalize().xyz();
    mChanged = true;
}
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
	{

	}
}
示例#4
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
}