Exemple #1
0
	int TriangleLineRender::Iterate(IterateMode inMode,const Matrix &m)
	{
		ItLine = inMode==itGetExtent ? &LineRender::BuildExtent :
				inMode==itCreateRenderer ? &LineRender::BuildSolid :
						&LineRender::BuildHitTest;
		
	  double perp_len = GetPerpLen(m);
		
	  UserPoint *point = 0;
	  if (inMode==itHitTest)
		 point = &mTriangles->mVertices[0];
	  else
		 point = &mTransformed[0];
		
		int tris = mTriangles->mTriangleCount;
	  for(int i=0;i<tris;i++)
		{
			UserPoint v0 = *point++;
			UserPoint v1 = *point++;
			UserPoint v2 = *point++;
			
			UserPoint perp0 = (v1-v0).Perp(perp_len);
			UserPoint perp1 = (v2-v1).Perp(perp_len);
			UserPoint perp2 = (v0-v2).Perp(perp_len);
			
			AddJoint(v0,perp2,perp0);
		 AddLinePart(v0+perp0,v1+perp0,v1-perp0,v0-perp0);
			AddJoint(v1,perp0,perp1);
		 AddLinePart(v1+perp1,v2+perp1,v2-perp1,v1-perp1);
			AddJoint(v2,perp1,perp2);
		 AddLinePart(v2+perp2,v0+perp2,v0-perp2,v2-perp2);
		}
		
	  return 256;
	}
Exemple #2
0
//== Конструктор.
SH3DBind::SH3DBind(Log* p_Log, UI uiWidth, UI uiHeight, Iterator<Parser::PNode*>* p_PNode, PhysXBind* p_PhysXBindI, UCH *p_uchResult)
{

	// ПЕРЕМЕННЫЕ.

	Iterator<Parser::PNode*>* p_I_NActors = NULL;
	Iterator<Parser::PNode*>* p_I_NJoints = NULL;
	Iterator<Parser::PNode*>* p_I_NActorDetails = NULL;
	Iterator<Parser::PNode*>* p_I_NJointDetails = NULL;
	Iterator<Parser::PNode*>* p_I_N0 = NULL;
	Iterator<Parser::PNode*>* p_I_N1 = NULL;
	Iterator<Parser::PNode*>* p_I_NCameraDetails = NULL;
	//
	PhysXBind::sActor oActor;
	PhysXBind::sJoint oJoint;
	Iterator<Parser::PNode*>* p_I_Categories = NULL;
	PhysXBind::sAssembly* p_oAssembly = NULL;
	Iterator<Parser::PNode*>* p_I_Assemblies = NULL;
	Iterator<PhysXBind::sActor>* p_I_Actors = NULL;
	//
	H3DNode gniLight;
	//
	PxVec3 vPosition;
	PxVec3 vRotation;
	PxVec3 vLinear;
	PxVec3 vAngular;
	PxReal fSqrtScale;
	//
	PxVec3 vScale;

	////////////////
	this->p_Log = p_Log;
	if (!h3dInit())
	{
		LOG_HORDE3D_E("Невозможно инициаизировать Horde3D");
		if (p_uchResult) *p_uchResult = U_H3D_INIT_ERROR;
		return;
	}
	else
	{
		LOG_HORDE3D_I("Horde3D инициализирован");
		if (p_uchResult) *p_uchResult = U_OK;
	}
	p_PhysXBind = p_PhysXBindI;
	griPipe = h3dAddResource(H3DResTypes::Pipeline, "pipelines/forward.pipeline.xml", 0);
	// Инициализация всех ресурсов из итератора.
	ui00 = p_PNode->FindElementByName("Assemblies", 0, &uchResult); // Ищем сборки.
	if (uchResult == U_OK)
	{
		p_PNodeH00 = *p_PNode->GetValuePtr(ui00); // Разъём сборок.
		p_I_Assemblies = p_PNodeH00->p_ChildIterator; // Итератор сборок.
		THRU_ITERATOR(p_I_Assemblies)
		{
			p_PNodeH00 = *p_I_Assemblies->GetValuePtr(i); // Разъём конкретной сборки (имя из p_PNodeH00 в сборки).
			p_oAssembly = p_PhysXBind->p_I_Assemblies->GetValuePtr(AddAssembly(p_PNodeH00->p_NodeName));
			p_I_Categories = p_PNodeH00->p_ChildIterator; // Итератор категорий.
			ui01 = p_I_Categories->FindElementByName("Actors", 0, &uchResult); // Ищем актёров.
			if (uchResult == U_OK)
			{
				p_PNodeH01 = *p_I_Categories->GetValuePtr(ui01); // Разъём актёров.
				p_I_NActors = p_PNodeH01->p_ChildIterator; // Итератор актёров.
				THRU_ITERATOR(p_I_NActors)
				{
					ZeroMemory(&oActor, sizeof(PhysXBind::sActor)); // Начало заполнения объекта актёра.
					p_PNodeH01 = *p_I_NActors->GetValuePtr(i); // Разъём конкретного актёра (имя из p_PNodeH01 в актёры).
					p_I_NActorDetails = p_PNodeH01->p_ChildIterator; // Текущий итератор описания актёра.
					if (p_I_NActorDetails)
					{
						ui02 = p_I_NActorDetails->FindElementByName("Model", 0, &uchResult); // Поиск элемента модели.
						if (uchResult == U_OK)
						{ // Нашли модель для тела.
							p_PNodeH02 = *p_I_NActorDetails->GetValuePtr(ui02); // Взяли разъём описания модели.
							CopyString(p_PNodeH02->p_chData, oActor.mchModelName); // Имя модели из p_PNodeH02 в объект актёра.
						}
						ui02 = p_I_NActorDetails->FindElementByName("Position", 0, &uchResult);
						if (uchResult == U_OK)
						{
							oActor.vPos = AToPxVec3((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData);
						}
						else oActor.vPos = cvIdent;
						ui02 = p_I_NActorDetails->FindElementByName("Rotation", 0, &uchResult);
						if (uchResult == U_OK)
						{
							oActor.vRot = AToPxVec3((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData);
						}
						else oActor.vRot = cvIdent;
						ui02 = p_I_NActorDetails->FindElementByName("Scale", 0, &uchResult);
						if (uchResult == U_OK)
						{
							oActor.fScale = AToPxReal((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData);
						}
						else oActor.fScale = 1.0f;
						fSqrtScale = PxSqrt(oActor.fScale);
						oActor.uchActorType = PX_ACTOR_DYNAMIC;
						ui02 = p_I_NActorDetails->FindElementByName("Static", 0, &uchResult);
						if (uchResult == U_OK)
						{
							oActor.uchActorType = PX_ACTOR_STATIC;
						}
						else
						{
							ui02 = p_I_NActorDetails->FindElementByName("L_Velocity", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oActor.vLVel = AToPxVec3((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData);
							}
							else oActor.vLVel = cvScIdent;
							ui02 = p_I_NActorDetails->FindElementByName("A_Velocity", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oActor.vAVel = AToPxVec3((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData);
							}
							else oActor.vAVel = cvScIdent;
							ui02 = p_I_NActorDetails->FindElementByName("Density_Mult", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oActor.fDensMult = AToPxReal((*p_I_NActorDetails->GetValuePtr(ui02))->p_chData);
							}
							else oActor.fDensMult = 1.0f;
						}
						ui02 = p_I_NActorDetails->FindElementByName("Camera", 0, &uchResult);
						if (uchResult == U_OK)
						{
							p_PNodeH00 = *p_I_NActorDetails->GetValuePtr(ui02);
							p_I_NCameraDetails = p_PNodeH00->p_ChildIterator;
							ui02 = p_I_NCameraDetails->FindElementByName("Position", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oActor.oCamera.vPos = AToPxVec3((*p_I_NCameraDetails->GetValuePtr(ui02))->p_chData);
							}
							else oActor.oCamera.vPos = cvIdent;
							ui02 = p_I_NCameraDetails->FindElementByName("Rotation", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oActor.oCamera.vRot = AToPxVec3((*p_I_NCameraDetails->GetValuePtr(ui02))->p_chData);
							}
							else oActor.oCamera.vRot = cvIdent;
						}
					}
					// Актёр в итератор, создание актёра.
					AddActor(p_oAssembly, &oActor, p_PNodeH01->p_NodeName);
				}
				THRU_ITERATOR_END;
			}
			ui01 = p_I_Categories->FindElementByName("Joints", 0, &uchResult); // Ищем актёров.
			if (uchResult == U_OK)
			{
				p_PNodeH01 = *p_I_Categories->GetValuePtr(ui01); // Разъём суставов.
				p_I_NJoints = p_PNodeH01->p_ChildIterator; // Итератор суставов.
				THRU_ITERATOR(p_I_NJoints)
				{
					ZeroMemory(&oJoint, sizeof(PhysXBind::sJoint)); // Начало заполнения объекта актёра.
					p_PNodeH01 = *p_I_NJoints->GetValuePtr(i); // Разъём конкретного актёра (имя из p_PNodeH01 в актёры).
					p_ch00 = CopyString(p_PNodeH01->p_NodeName, mch0, '/');
					CopyString(p_ch00, mch1);
					oJoint.p_Actor0 = p_oAssembly->p_I_Actors->GetValuePtr(p_oAssembly->p_I_Actors->FindElementByName(mch0));
					oJoint.p_Actor1 = p_oAssembly->p_I_Actors->GetValuePtr(p_oAssembly->p_I_Actors->FindElementByName(mch1));
					if (oJoint.p_Actor0 && oJoint.p_Actor1)
					{
						p_I_NJointDetails = p_PNodeH01->p_ChildIterator; // Текущий итератор описания актёра.
						if (p_I_NJointDetails)
						{
							ui02 = p_I_NJointDetails->FindElementByName("Actor0Initials", 0, &uchResult);
							if (uchResult == U_OK)
							{
								p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator;
								ui02 = p_I_N0->FindElementByName("Position", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.vIPos0 = AToPxVec3((*p_I_N0->GetValuePtr(ui02))->p_chData);
								}
								ui02 = p_I_N0->FindElementByName("Rotation", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.vIRot0 = AToPxVec3((*p_I_N0->GetValuePtr(ui02))->p_chData);
								}
							}
							ui02 = p_I_NJointDetails->FindElementByName("Actor1Initials", 0, &uchResult);
							if (uchResult == U_OK)
							{
								p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator;
								ui02 = p_I_N0->FindElementByName("Position", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.vIPos1 = AToPxVec3((*p_I_N0->GetValuePtr(ui02))->p_chData);
								}
								ui02 = p_I_N0->FindElementByName("Rotation", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.vIRot1 = AToPxVec3((*p_I_N0->GetValuePtr(ui02))->p_chData);
								}
							}
							
							ui02 = p_I_NJointDetails->FindElementByName("Motions", 0, &uchResult);
							if (uchResult == U_OK)
							{
								p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator;
								ui02 = p_I_N0->FindElementByName("AxisX", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mMotions[0] = PxD6Motion::Enum::eFREE;
								}
								ui02 = p_I_N0->FindElementByName("AxisY", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mMotions[1] = PxD6Motion::Enum::eFREE;
								}
								ui02 = p_I_N0->FindElementByName("AxisZ", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mMotions[2] = PxD6Motion::Enum::eFREE;
								}
								ui02 = p_I_N0->FindElementByName("Twist", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mMotions[3] = PxD6Motion::Enum::eFREE;
								}
								ui02 = p_I_N0->FindElementByName("Swing0", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mMotions[4] = PxD6Motion::Enum::eFREE;
								}
								ui02 = p_I_N0->FindElementByName("Swing1", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mMotions[5] = PxD6Motion::Enum::eFREE;
								}
							}
							ui02 = p_I_NJointDetails->FindElementByName("LinearLimit", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oJoint.oLinearLimit.bIsOn = true;
								if (oJoint.mMotions[0] == PxD6Motion::Enum::eFREE)
									oJoint.mMotions[0] = PxD6Motion::Enum::eLIMITED;
								if (oJoint.mMotions[1] == PxD6Motion::Enum::eFREE)
									oJoint.mMotions[1] = PxD6Motion::Enum::eLIMITED;
								if (oJoint.mMotions[2] == PxD6Motion::Enum::eFREE)
									oJoint.mMotions[2] = PxD6Motion::Enum::eLIMITED;
								p_I_N1 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator;
								ui02 = p_I_N1->FindElementByName("Extend", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.oLinearLimit.fExtend = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
								}
								ui02 = p_I_N1->FindElementByName("Spring", 0, &uchResult);
								if (uchResult == U_OK)
								{
									vt00 = AToPxVec2((*p_I_N1->GetValuePtr(ui02))->p_chData);
									oJoint.oLinearLimit.oSpring.bIsOn = true;
									oJoint.oLinearLimit.oSpring.fStiffness = vt00.x;
									oJoint.oLinearLimit.oSpring.fDamping = vt00.y;
								}
							}
							ui02 = p_I_NJointDetails->FindElementByName("TwistLimit", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oJoint.oAngularLimitPair.bIsOn = true;
								oJoint.mMotions[3] = PxD6Motion::Enum::eLIMITED;
								p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator;
								ui02 = p_I_N0->FindElementByName("Bounds", 0, &uchResult);
								if (uchResult == U_OK)
								{
									vt00 = AToPxVec2((*p_I_N0->GetValuePtr(ui02))->p_chData);
									oJoint.oAngularLimitPair.fLowerLimit = vt00.x;
									oJoint.oAngularLimitPair.fLowerLimit = vt00.y;
								}
								ui02 = p_I_N0->FindElementByName("Spring", 0, &uchResult);
								if (uchResult == U_OK)
								{
									vt00 = AToPxVec2((*p_I_N0->GetValuePtr(ui02))->p_chData);
									oJoint.oAngularLimitPair.oSpring.bIsOn = true;
									oJoint.oAngularLimitPair.oSpring.fStiffness = vt00.x;
									oJoint.oAngularLimitPair.oSpring.fDamping = vt00.y;
								}
							}
							ui02 = p_I_NJointDetails->FindElementByName("SwingLimit", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oJoint.oLimitCone.bIsOn = true;
								p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator;
								ui02 = p_I_N0->FindElementByName("ZLimit", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mMotions[4] = PxD6Motion::Enum::eLIMITED;
									oJoint.oLimitCone.fYLimitAngle = AToPxReal((*p_I_N0->GetValuePtr(ui02))->p_chData) /
										p_PhysXBind->cfQuaterCircle;
								}
								ui02 = p_I_N0->FindElementByName("YLimit", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mMotions[5] = PxD6Motion::Enum::eLIMITED;
									oJoint.oLimitCone.fZLimitAngle = AToPxReal((*p_I_N0->GetValuePtr(ui02))->p_chData) /
										p_PhysXBind->cfQuaterCircle;
								}
								ui02 = p_I_N0->FindElementByName("Spring", 0, &uchResult);
								if (uchResult == U_OK)
								{
									vt00 = AToPxVec2((*p_I_N0->GetValuePtr(ui02))->p_chData);
									oJoint.oLimitCone.oSpring.bIsOn = true;
									oJoint.oLimitCone.oSpring.fStiffness = vt00.x;
									oJoint.oLimitCone.oSpring.fDamping = vt00.y;
								}
							}
							ui02 = p_I_NJointDetails->FindElementByName("LinearDriveGoal", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oJoint.vLinearDriveGoal = AToPxVec3((*p_I_NJointDetails->GetValuePtr(ui02))->p_chData);
							}
							ui02 = p_I_NJointDetails->FindElementByName("AngularDriveGoal", 0, &uchResult);
							if (uchResult == U_OK)
							{
								oJoint.vAngularDriveGoal = AToPxVec3((*p_I_NJointDetails->GetValuePtr(ui02))->p_chData);
							}
							ui02 = p_I_NJointDetails->FindElementByName("Drives", 0, &uchResult);
							if (uchResult == U_OK)
							{
								p_I_N0 = (*p_I_NJointDetails->GetValuePtr(ui02))->p_ChildIterator;
								ui02 = p_I_N0->FindElementByName("AxisX", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mDriveInfos[0].bIsOn = true;
									p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator;
									ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[0].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[0].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[0].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
								}
								ui02 = p_I_N0->FindElementByName("AxisY", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mDriveInfos[1].bIsOn = true;
									p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator;
									ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[1].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[1].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[1].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
								}
								ui02 = p_I_N0->FindElementByName("AxisZ", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mDriveInfos[2].bIsOn = true;
									p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator;
									ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[2].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[2].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[2].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
								}
								ui02 = p_I_N0->FindElementByName("Swing", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mDriveInfos[3].bIsOn = true;
									p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator;
									ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[3].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[3].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[3].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
								}
								ui02 = p_I_N0->FindElementByName("Twist", 0, &uchResult);
								if (uchResult == U_OK)
								{
									oJoint.mDriveInfos[4].bIsOn = true;
									p_I_N1 = (*p_I_N0->GetValuePtr(ui02))->p_ChildIterator;
									ui02 = p_I_N1->FindElementByName("Stiffness", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[4].fDriveStiffness = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Сlutch", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[4].fDriveDamping = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
									ui02 = p_I_N1->FindElementByName("Limit", 0, &uchResult);
									if (uchResult == U_OK)
									{
										oJoint.mDriveInfos[4].fForceLimit = AToPxReal((*p_I_N1->GetValuePtr(ui02))->p_chData);
									}
								}
							}
						}
						AddJoint(p_oAssembly, oJoint);
					}
				}
				THRU_ITERATOR_END;
			}
void SimulatedWorld::AddObject(wxWindowID  	id)
{	
	InitialProperties *ini;
	PositionableEntity *obj=NULL;
	NodeTree *newNode=NULL;
	NodeTree *itemData = tree->GetSelection().IsOk() ? (NodeTree *) tree->GetItemData(tree->GetSelection()):NULL;


// Object Selected////

	if(id==ID_ADDSPHERE)
		obj=new SpherePart;
	else if(id==ID_ADDCYL)
		obj=new CylindricalPart;
	else if(id==ID_ADDPRI)
		obj=new PrismaticPart;
    else if(id==ID_ADDIRRPRI)
		obj=new PrismaticPart;
	else if(id==ID_ADDFACESET)
		obj=new FaceSetPart;
	else if(id==ID_ADDNEO)
		obj=new  Pioneer3ATSim;
	else if(id==ID_ADDSCARA)
		obj=new AdeptOneSim;
	else if(id==ID_ADDPUMA)
		obj=new  Puma560Sim;
	else if(id==ID_ADDASEA)
		obj=new AseaIRB2000Sim;
	else if(id==ID_ADDCUSTOM)
		obj=new ComposedEntity;
	else if(id==ID_WHEEL)
		obj=new WheeledBaseSim;
	else if(id==ID_LMS200)
		obj=new LMS200Sim;
	else if(id==ID_PATROL)
		obj=new PatrolbotSim;
	else if(id==ID_LMS100)
		obj=new LMS100Sim;
	else if(id==ID_POWERCUBE)
		obj=new PowerCube70Sim;
	else if(id==ID_CAMERA)
		obj=new CameraSim;
	else if(id==ID_KINECT)
		obj=new KinectSim;
	else if(id==ID_MOBILEROBOT)
		obj=new MobileRobot("");
	else if(id==ID_QUADROTOR)
		obj=new QuadrotorSim;
	else if(id==ID_PERSON)
		obj=new PersonSim;
	else if(id==ID_LASER)
		obj=new LaserSensorSim;
	else if(id==ID_LASER3D)
		obj=new LaserSensor3DSim;
	else if(id==ID_NEMOLASER)
		obj=new NemoLaserSensor3DSim;
	else if(id==ID_EUITIBOT)
		obj=new EUITIbotSim;
	else if(id==ID_ADDJOINT)
	{
		obj=AddJoint();
	}
	else 
		obj=new PositionableEntity;


	
	// Object addition or world addition//
	
	if(tree->GetSelection()!=mainNode)
	{
		newNode=tree->AddNode(obj,tree->GetSelection(),this);
		itemData->pointer.composedentity->addObject(obj);
	}
	else
	{
		(*m_world)+=obj;
		newNode=tree->AddNode(obj,tree->GetSelection(),this);
	}
	
	tree->Expand(tree->GetSelection());




	if(id==ID_ADDIRRPRI)
	{
		newNode->setTipo(N_IrregularPrismaticPart);
		newNode->setName(wxT("Irregular Prism"));
		tree->SetItemText(tree->GetLastChild(tree->GetSelection()),wxT("Irregular Prism"));
	}
	// Initial Properties //
	if(id==ID_ADDCUSTOM)
	{
		CompOption=new wxMessageDialog(NULL, wxT("Use the interface to build it?"),wxT("Composed Design"),wxYES_NO,wxDefaultPosition);
		if(CompOption->ShowModal()==wxID_YES)
		{
			ini= new InitialProperties(mainWin,newNode,wxT("Properties"),id); 
			ini->ShowModal();
		}
		else
		{
			childView->UpdateWorld();
			return;
		}
	}
	else if (id==ID_ADDJOINT)
	{
		return;
	}
	else
	{
		ini= new InitialProperties(mainWin,newNode,wxT("Properties"),id); 
		ini->ShowModal();
	}


	if(ini->GetButtom()==false)
	{
		delete obj;
		tree->Delete(tree->GetLastChild(tree->GetSelection()));
	}
	childView->UpdateWorld();
	delete ini;

}