Example #1
0
SCENEGRAPHPLUGINEXP void dllLoadGamePlugin(void)
{
	GameModules::componentRegistry()->registerComponent( "Horde3D", SceneGraphComponent::createComponent );	
	GameModules::componentRegistry()->registerManager( SceneGraphManager::instance() );	
	if ( !h3dInit() )
		GameLog::errorMessage(" Initialization of Horde3D failed! ");
}
Example #2
0
AGENTPLUGINEXP void dllLoadGamePlugin(void)
{
	GameModules::componentRegistry()->registerComponent( "Agent", AgentComponent::createComponent );
	GameModules::componentRegistry()->registerManager( AgentManager::instance() );

	h3dInit();
}
Example #3
0
ANIMATIONSPLUGINEXP void dllLoadGamePlugin(void)
{
	GameModules::componentRegistry()->registerComponent( "KeyframeAnimation", KeyframeAnimComponent::createComponent );	
	GameModules::componentRegistry()->registerComponent( "MoveAnimation", MoveAnimComponent::createComponent );	
	GameModules::componentRegistry()->registerComponent( "MorphtargetAnimation", MorphtargetAnimComponent::createComponent );

	GameModules::componentRegistry()->registerManager( MoveAnimManager::instance() );	
	GameModules::componentRegistry()->registerManager( KeyframeAnimManager::instance() );	
	GameModules::componentRegistry()->registerManager( MorphtargetAnimManager::instance() );

	h3dInit();
}
Example #4
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;
			}
Example #5
0
bool Application::init()
{	
	// Initialize engine and open default sound device
	if( !h3dInit() || !h3dOpenDevice( 0x0 ) )
	{	
		h3dutDumpMessages();
		return false;
	}

	// Set options
	h3dSetOption( H3DOptions::LoadTextures, 1 );
	h3dSetOption( H3DOptions::TexCompression, 0 );
	h3dSetOption( H3DOptions::FastAnimation, 0 );
	h3dSetOption( H3DOptions::MaxAnisotropy, 4 );
	h3dSetOption( H3DOptions::ShadowMapSize, 2048 );

	// Add resources
	// Pipelines
	_hdrPipeRes = h3dAddResource( H3DResTypes::Pipeline, "pipelines/hdr.pipeline.xml", 0 );
	_forwardPipeRes = h3dAddResource( H3DResTypes::Pipeline, "pipelines/forward.pipeline.xml", 0 );
	// Overlays
	_fontMatRes = h3dAddResource( H3DResTypes::Material, "overlays/font.material.xml", 0 );
	_panelMatRes = h3dAddResource( H3DResTypes::Material, "overlays/panel.material.xml", 0 );
	_logoMatRes = h3dAddResource( H3DResTypes::Material, "overlays/logo.material.xml", 0 );
	// Environment
	H3DRes floorRes = h3dAddResource( H3DResTypes::SceneGraph, "models/tiles/tiles.scene.xml", 0 );
	// Knight
	H3DRes speakerRes = h3dAddResource( H3DResTypes::SceneGraph, "models/speaker/speaker.scene.xml", 0 );
	// Music
	_soundRes = h3dAddResource( RST_SoundResource, "sounds/stringed_disco.ogg", 0 );

	// Load resources
	h3dutLoadResourcesFromDisk( _contentDir.c_str() );

	// Add scene nodes
	// Add camera
	_cam = h3dAddCameraNode( H3DRootNode, "Camera", _hdrPipeRes );
	//h3dSetNodeParamI( _cam, CameraNodeParams::OcclusionCulling, 1 );
	// Add listener to the camera
	H3DNode listener = h3dAddListenerNode( _cam, "Listener" );
	h3dSetActiveListener( listener );
	// Add floor
	H3DNode floor = h3dAddNodes( H3DRootNode, floorRes );
	h3dSetNodeTransform( floor, 0, -0.125, 0, 0, 0, 0, 1, 1, 1 );
	// Add the speakers
	H3DNode speaker1 = h3dAddNodes( H3DRootNode, speakerRes );
	h3dSetNodeTransform( speaker1, -2, 0, -2, 0, 215.0f, 0, 1, 1, 1 );
	H3DNode speaker2 = h3dAddNodes( H3DRootNode, speakerRes );
	h3dSetNodeTransform( speaker2, 2, 0, -2, 0, 145.0f, 0, 1, 1, 1 );
	// Add music to the speakers
	_sound1 = h3dAddSoundNode( speaker1, "Sound1", _soundRes );
	_sound2 = h3dAddSoundNode( speaker2, "Sound2", _soundRes );
	// Add light source
	_light = h3dAddLightNode( H3DRootNode, "Light1", 0, "LIGHTING", "SHADOWMAP" );
	h3dSetNodeTransform( _light, 0, 7, 0, -90, 0, 0, 1, 1, 1 );
	h3dSetNodeParamF( _light, H3DLight::RadiusF, 0, 30 );
	h3dSetNodeParamF( _light, H3DLight::FovF, 0, 90 );
	h3dSetNodeParamI( _light, H3DLight::ShadowMapCountI, 1 );
	h3dSetNodeParamF( _light, H3DLight::ShadowMapBiasF, 0, 0.01f );

	// Set the distance model
	h3dSetDistanceModel( _distanceModel );
	// Set the timer so the light immediately gets a random color
	_lightTimer = 1.0f;

	// Customize post processing effects
	H3DRes matRes = h3dFindResource( H3DResTypes::Material, "pipelines/postHDR.material.xml" );
	// hdrParams: exposure, brightpass threshold, brightpass offset (see shader for description)
	h3dSetMaterialUniform( matRes, "hdrParams", 2.0f, 0.6f, 0.08f, 0 );

	// Play the music
	h3dPlaySound( _sound1 );
	h3dPlaySound( _sound2 );

	return true;
}
Example #6
0
bool TentacleApplication::init()
{
  // Initialize engine
  if( !h3dInit() )
  {
    h3dutDumpMessages();
    return false;
  }

	// Set options
	h3dSetOption( H3DOptions::LoadTextures, 1 );
	h3dSetOption( H3DOptions::TexCompression, 0 );
	h3dSetOption( H3DOptions::MaxAnisotropy, 4 );
	h3dSetOption( H3DOptions::ShadowMapSize, 2048 );
	h3dSetOption( H3DOptions::FastAnimation, 1 );

  // Add resources
  // Pipelines
  _hdrPipeRes = h3dAddResource( H3DResTypes::Pipeline, "pipelines/hdr.pipeline.xml", 0 );
  _forwardPipeRes = h3dAddResource( H3DResTypes::Pipeline, "pipelines/forward.pipeline.xml", 0 );
  // Font
  _fontMatRes = h3dAddResource( H3DResTypes::Material, "overlays/font.material.xml", 0 );
  // Logo
  _logoMatRes = h3dAddResource( H3DResTypes::Material, "overlays/logo.material.xml", 0 );
  // invJacXpl
  //_invJacMatRes = h3dAddResource( H3DResTypes::Material, "materials/invJac.material.xml", 0 );
  // Environment
  H3DRes envRes = h3dAddResource( H3DResTypes::SceneGraph, "models/sphere/sphere.scene.xml", 0 );
  // Tentacle
  H3DRes tentacleRes = h3dAddResource( H3DResTypes::SceneGraph, "models/tentacle.scene.xml", 0 );
  // Fly
  H3DRes flyRes = h3dAddResource( H3DResTypes::SceneGraph, "models/fly.scene.xml", 0 );

  _dx = _dy = _dz = 0;

  // Load resources
  h3dutLoadResourcesFromDisk( _contentDir.c_str() );

  // Add scene nodes
  // Add camera
  _cam = h3dAddCameraNode( H3DRootNode, "Camera", _forwardPipeRes );
  // Add environment
  H3DNode env = h3dAddNodes( H3DRootNode, envRes );
  h3dSetNodeTransform( env, 0, -20, 0, 0, 0, 0, 20, 20, 20 );

  // Add tentacle node
  _tentacle = h3dAddNodes( H3DRootNode, tentacleRes );
  h3dSetNodeTransform( _tentacle, 0, 0, 0, 0, 0, 0.0, 1.0f, 1.0f, 1.0f );

  // Create tentacle kinematic chain
  _tentacleIK = setUpKinematikChain(_tentacle);
  //cout << _tentacleIK->getEndPosition(_tentacleIK->getNumJoints()-1);
  //_ikCCDSolver = new SmrCCDSolver(_tentacleIK);
  //_ikCCDSolver->addConstraintPtr(_ikConstraint);

  _ikGSMMSolver = new SMRGSMMSolver(_tentacleIK);
  _ikGSMMSolver->addConstraintPtr(_ikConstraint);

  _ikInvJacSolver = new SMRInvJacSolver(_tentacleIK);
  _ikInvJacSolver->addConstraintPtr(_ikConstraint);

  //delete(_tentacleIK);

  _currentSolver = _ikInvJacSolver;
  _ikMethodString = "J pseudo-inverse";

  // Add fly node
  _fly = h3dAddNodes( H3DRootNode, flyRes );
  h3dSetNodeTransform( _fly, 0, 4, 0, 0, 0, 0, 0.2f, 0.2f, 0.2f );

  // Add light source
  H3DNode light = h3dAddLightNode( H3DRootNode, "Light1", 0, "LIGHTING", "SHADOWMAP" );
  h3dSetNodeTransform( light, 0, 15, 10, -60, 0, 0, 1, 1, 1 );
  h3dSetNodeParamF( light, H3DLight::RadiusF,0, 30 );
  h3dSetNodeParamF( light, H3DLight::FovF,0, 90 );
  h3dSetNodeParamI( light, H3DLight::ShadowMapCountI, 0 );
  h3dSetNodeParamF( light, H3DLight::ShadowMapBiasF,0, 0.01f );
  h3dSetNodeParamF( light, H3DLight::ColorF3,0, 1.0f );
  h3dSetNodeParamF( light, H3DLight::ColorF3,1, 0.8f );
  h3dSetNodeParamF( light, H3DLight::ColorF3,2, 0.7f );

  // Customize post processing effects
	H3DNode matRes = h3dFindResource( H3DResTypes::Material, "pipelines/postHDR.material.xml" );

  //hdrParams: exposure, brightpass threshold, brightpass offset (see shader for description)
	h3dSetMaterialUniform( matRes, "hdrParams", 2.5f, 0.5f, 0.08f, 0 );

  return true;
}
	H3DView(int winWidth, int winHeight) :
			BulletEngineTest(),
			//model(0),
			cam(0),
			frameNum(0),
			text(NULL), textLen(32),
			_rx(15), _ry(-50),
			//_rx(0), _ry(0),
			_prev_x(0), _prev_y(0),
			_mouseEnteredThisFrame(false)
	{
		assert(view == NULL);
		view = this;

		text = new char[textLen];
		memset(text, 0, textLen);

		LOG("Initializing Horde3D...");
		h3dInit();

		h3dSetOption(H3DOptions::MaxAnisotropy, 8);
		h3dSetOption(H3DOptions::SampleCount, 16);

		//h3dSetOption(H3DOptions::WireframeMode, 1);
		//h3dSetOption(H3DOptions::DebugViewMode, 1);
		h3dSetOption(H3DOptions::GatherTimeStats, 1);

		LOG("Declaring resources...");

		pipeRes = h3dAddResource(H3DResTypes::Pipeline, "pipelines/forward.pipeline.xml", 0);

		H3DRes skyBoxRes = h3dAddResource(H3DResTypes::SceneGraph, "models/skybox/skybox.scene.xml", 0);

		//modelRes = h3dAddResource(H3DResTypes::SceneGraph, "models/AssJacket/AssJacket.scene.xml", 0);
		//modelRes = h3dAddResource(H3DResTypes::SceneGraph, "models/ares/ares.scene.xml", 0);
		modelRes = h3dAddResource(H3DResTypes::SceneGraph, "models/man/man.scene.xml", 0);

		fontMatRes = h3dAddResource(H3DResTypes::Material, "overlays/font.material.xml", 0);
		panelMatRes = h3dAddResource(H3DResTypes::Material, "overlays/panel.material.xml", 0);

		LOG("Loading resources from disk...");
		h3dutLoadResourcesFromDisk("/home/whitelynx/devel/other/Horde3D/build-make/Binaries/Content"
				"|/home/whitelynx/devel/skewedaspect/precursors-client/resources/content");

		LOG("Building scene...");
		/*
		// Add model to scene
		model = h3dAddNodes(H3DRootNode, modelRes);
		h3dSetNodeTransform(model,
				0, 0, -500,  // Translation
				0, 0, 0,     // Rotation
				1, 1, 1      // Scale
				);
		*/

		// Add light source
		H3DNode light = h3dAddLightNode(H3DRootNode, "Light1", 0, "LIGHTING", "SHADOWMAP");
		// Set light position and radius
		h3dSetNodeTransform(light,
				0, 20, 0,
				0, 0, 0,
				10, 10, 10
				);
		h3dSetNodeParamF(light, H3DLight::RadiusF, 0, 50.0f);

		LOG("Setting up camera...");
		cam = h3dAddCameraNode(H3DRootNode, "Camera", pipeRes);

		resizeViewport(winWidth, winHeight);

#if 1
		H3DNode sky = h3dAddNodes(H3DRootNode, skyBoxRes);
		h3dSetNodeTransform(sky,
				0, 0, 0,      // Translation
				0, 0, 0,      // Rotation
				210, 50, 210  // Scale
				);
		h3dSetNodeFlags(sky, H3DNodeFlags::NoCastShadow, true);
#endif

		LOG("Setting BulletEngine callbacks...");
		setMakeModelCallback(&makeModelCB);
		setUpdateModelCallback(&updateModelCB);

		LOG("Initializing physics...");
		initPhysics();

		LOG("Ready.");
	} // end H3DView