コード例 #1
0
void SMeshWidget::Construct(const FArguments& Args)
{
	if (Args._MeshData != nullptr)
	{
		AddMesh(*Args._MeshData);
	}
}
コード例 #2
0
ファイル: Atlantis_SRB.cpp プロジェクト: Artoria2e5/obtr
// Set SRB class specs
void Atlantis_SRB::clbkSetClassCaps (FILEHANDLE cfg)
{
	extern PARTICLESTREAMSPEC srb_contrail, srb_exhaust;
	PARTICLESTREAMSPEC srb_bolt = {
		0, 8.0, 20, 0.0, 0.1, 0.3, 16, 3.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_LIN, 0, 1,
		PARTICLESTREAMSPEC::ATM_FLAT, 1, 1
	};

	SetEnableFocus (false);
	// SRB cannot receive input focus

	// *********************** physical parameters *********************************

	SetSize (23.0);
	SetEmptyMass (SRB_EMPTY_MASS);
	SetCW (0.1, 0.3, 1.4, 1.4);
	SetCrossSections (_V(162.1,162.1,26.6));
	SetRotDrag (_V(0.7,0.7,0.1));
	SetPMI (_V(154.3,154.3,1.83));
	//SetGravityGradientDamping (10.0);
	SetTouchdownPoints (tdvtx, ntdvtx);
	SetLiftCoeffFunc (0);

	// ************************* docking port **************************************

	CreateDock (_V(1.95,0,5),_V(1,0,0),_V(0,0,1)); // ET attachment

	// ************************* propellant specs **********************************

	ph_main = CreatePropellantResource (SRB_MAX_PROPELLANT_MASS);

	// *********************** thruster definitions ********************************

	// main engine
	th_main = CreateThruster (_V(0,0,-21), THRUSTGIMBAL_LAUNCH, SRB_THRUST_MAX, ph_main, SRB_ISP0, SRB_ISP1);
	SURFHANDLE tex = oapiRegisterExhaustTexture ("Exhaust2");
	srb_exhaust.tex = oapiRegisterParticleTexture ("Contrail2");
	AddExhaust (th_main, 16.0, 2.0, tex);
	AddExhaustStream (th_main, _V(0,0,-30), &srb_contrail);
	AddExhaustStream (th_main, _V(0,0,-25), &srb_exhaust);

	// separation bolts
	th_bolt = CreateThruster (_V(0,0,3.0), _V(-1,0,0), 3e6, ph_main, 1e7);
	// for simplicity, the separation bolts directly use SRB propellant. We give
	// them an insanely high ISP to avoid significant propellant drainage

	AddExhaust (th_bolt, 0.7, 0.1, _V(2.1,0,-8), _V(-1,0,0));
	AddExhaust (th_bolt, 0.7, 0.1, _V(2.1,0,11), _V(-1,0,0));
	AddExhaustStream (th_bolt, _V(2.1,0,0), &srb_bolt);

	// ************************ visual parameters **********************************

	AddMesh (hSRBMesh);

	bMainEngine = false;
	bSeparationEngine = false;
	bGimbalCmd = false;
	srbpos = SRB_UNDEFINED;
}
コード例 #3
0
//! Loads the  model from a file.[TODO]
void SkinnedModel::Load(string filename)
{
	ifstream fin(filename, ios::binary | ios::in);

	string ignore;
	int numMeshes;
	fin >> ignore >> numMeshes;

	for(int i =  0; i < numMeshes; i++)
	{
		SkinnedMesh* mesh = new SkinnedMesh();
		mesh->Load(fin);
		AddMesh(mesh);
	}

	// The space after the last index.
	fin >> ignore;	

	// Make sure to start loading animation data from the right place.
	// [NOTE] After some investigation it seems like it should be at the first '\f' character.
	char x = fin.peek(); 
	while(x != '\f') {
		fin >> ignore;	
		x = fin.peek(); 
	}

	mAnimator = new SceneAnimator();
	mAnimator->Load(fin);

	fin.close();
}
コード例 #4
0
ファイル: dModel.cpp プロジェクト: Zarius/pseudoform
void dModel::InitFromModel (const dModel& source)
{
	while (m_skeleton.GetCount()) {
		RemoveSkeleton(m_skeleton.GetFirst()->GetInfo());
	}
	while (m_meshList.GetCount()) {
		RemoveMesh(m_meshList.GetFirst()->GetInfo().m_mesh);
	}

	while (m_animations.GetCount()) {
		RemoveAnimation(m_animations.GetFirst()->GetInfo());
	}


	for (dList<dBone*>::dListNode* node = source.m_skeleton.GetFirst(); node; node = node->GetNext()) {
		int stack = 1;
		dBone* pool[64];
		dBone* parentBones[64];

		parentBones[0] = NULL;
		dBone* rootBone = NULL;
		pool[0] = node->GetInfo();
		
		while (stack) {
			stack --;
			dBone* parent = parentBones[stack];
			dBone* sourceBone = pool[stack];
			dBone* bone = new dBone (*sourceBone, parent);
			if (!rootBone) {
				rootBone = bone;
			}

			for (sourceBone = sourceBone->GetChild(); sourceBone; sourceBone = sourceBone->GetSibling()) {
				pool[stack] = sourceBone;
				parentBones[stack] = bone;
				stack ++;
			}
		}
	
		AddSkeleton(rootBone);
		rootBone->Release();
	}



	for (dList<dAnimationClip*>::dListNode* node = source.m_animations.GetFirst(); node; node = node->GetNext()) {
		AddAnimation(node->GetInfo());
	}


	for (dList<dMeshInstance>::dListNode* node = source.m_meshList.GetFirst(); node; node = node->GetNext()) { 
		AddMesh(node->GetInfo().m_mesh);
		dMeshInstance& instance = m_meshList.GetLast()->GetInfo();
		instance.m_boneID = node->GetInfo().m_boneID;
		if (node->GetInfo().GetModifier()) {
			instance.SetModifier(node->GetInfo().GetModifier()->CreateCopy (instance, *this));
		}
	}
}
コード例 #5
0
ファイル: renderercommon.cpp プロジェクト: ptitSeb/Eldritch
void RendererCommon::DEBUGPrint(const SimpleString& UTF8String,
                                const Font* const pFont, const SRect& Bounds,
                                const Vector4& Color) {
  Mesh* const pPrintMesh = Print(UTF8String, pFont, Bounds, 0);
  pPrintMesh->m_IsDebugMesh = true;
  pPrintMesh->m_ConstantColor = Color;
  pPrintMesh->SetMaterialFlags(MAT_DEBUG_HUD);
  AddMesh(pPrintMesh);
}
コード例 #6
0
ファイル: lemmesh.cpp プロジェクト: dseagrav/NASSP
void LEM::SetLmLandedMesh() {

	ClearMeshes();
	VECTOR3 mesh_dir=_V(-0.003,-0.03,0.004);	
	UINT meshidx = AddMesh (hLMLanded, &mesh_dir);
	SetMeshVisibilityMode (meshidx, MESHVIS_VCEXTERNAL);

	Landed = true;
}
コード例 #7
0
ファイル: ModelLoader.cpp プロジェクト: BillyKim/jello-man
//*********************
//  ASCII
//******************
void ModelLoader::ReadASCIIObj(const tstring& assetName)
{
    ifstream stream;
    stream.open(assetName.c_str());
    if (stream.fail())
    {
        wcout << "File open fail: '" << assetName << "'\n";
        return;
    }

    string line;
    
    vector<vector<int>> faceData;
    for (int i = 0; i < 3; ++i)
    {
        faceData.push_back(vector<int>(3));
    }
    while (stream.eof() == false)
    {
        getline(stream, line);
        if (line.find("vn", 0) == 0)
        {
            Vector3 v;
            sscanf_s(line.c_str(), "vn %f %f %f", &v.X, &v.Y, &v.Z);
            AddNormal(v);
        }
        else if (line.find("vt", 0) == 0)
        {
            Vector2 v;
            sscanf_s(line.c_str(), "vt %f %f ", &v.X, &v.Y);
            AddTexCoord(v);
        }
        else if (line.find("f", 0) == 0)
        {
            sscanf_s(line.c_str(), "f %d/%d/%d %d/%d/%d %d/%d/%d", 
                                          &faceData[0][0], &faceData[0][1], &faceData[0][2],
                                          &faceData[1][0], &faceData[1][1], &faceData[1][2],
                                          &faceData[2][0], &faceData[2][1], &faceData[2][2]);
            AddTri(faceData);
        }
        else if (line.find("g", 0) == 0)
        {
            wchar_t s[40];
            sscanf_s(line.c_str(), "g %s40", s, _countof(s));
            AddMesh(s);
        }
        else if (line.find("v", 0) == 0) //v is 0'd char
        {
            Vector3 v;
            sscanf_s(line.c_str(), "v %f %f %f", &v.X, &v.Y, &v.Z);
            AddVertex(v);
        }
    }
    FlushMesh(); //apply last mesh

    stream.close();
}
コード例 #8
0
ファイル: renderercommon.cpp プロジェクト: ptitSeb/Eldritch
void RendererCommon::DEBUGDrawLine2D(const Vector& Start, const Vector& End,
                                     unsigned int Color) {
  Mesh* LineMesh = GetMeshFactory()->CreateDebugLine(Start, End, Color);
  LineMesh->m_IsDebugMesh = true;
  LineMesh->SetMaterialDefinition(DEFAULT_NEWMATERIAL, this);
  LineMesh->SetTexture(0, GetTextureManager()->GetTexture(
                              DEFAULT_TEXTURE, TextureManager::ETL_Permanent));
  LineMesh->SetMaterialFlags(MAT_DEBUG_HUD);
  AddMesh(LineMesh);
}
コード例 #9
0
ファイル: renderercommon.cpp プロジェクト: ptitSeb/Eldritch
void RendererCommon::DEBUGDrawFrustum(const View& rView, unsigned int Color) {
  Mesh* FrustumMesh = GetMeshFactory()->CreateDebugFrustum(rView, Color);
  FrustumMesh->m_IsDebugMesh = true;
  FrustumMesh->SetMaterialDefinition(DEFAULT_NEWMATERIAL, this);
  FrustumMesh->SetTexture(
      0, GetTextureManager()->GetTexture(DEFAULT_TEXTURE,
                                         TextureManager::ETL_Permanent));
  FrustumMesh->SetMaterialFlags(MAT_DEBUG_WORLD);
  AddMesh(FrustumMesh);
}
コード例 #10
0
ファイル: renderercommon.cpp プロジェクト: ptitSeb/Eldritch
void RendererCommon::DEBUGDrawTriangle(const Vector& V1, const Vector& V2,
                                       const Vector& V3, unsigned int Color) {
  Mesh* TriMesh = GetMeshFactory()->CreateDebugTriangle(V1, V2, V3, Color);
  TriMesh->m_IsDebugMesh = true;
  TriMesh->SetMaterialDefinition(DEFAULT_NEWMATERIAL, this);
  TriMesh->SetTexture(0, GetTextureManager()->GetTexture(
                             DEFAULT_TEXTURE, TextureManager::ETL_Permanent));
  TriMesh->SetMaterialFlags(MAT_DEBUG_WORLD);
  AddMesh(TriMesh);
}
コード例 #11
0
ファイル: renderercommon.cpp プロジェクト: ptitSeb/Eldritch
void RendererCommon::DEBUGDrawBox2D(const Vector& Min, const Vector& Max,
                                    unsigned int Color) {
  Mesh* BoxMesh = GetMeshFactory()->CreateDebugBox(Min, Max, Color);
  BoxMesh->m_IsDebugMesh = true;
  BoxMesh->SetMaterialDefinition(DEFAULT_NEWMATERIAL, this);
  BoxMesh->SetTexture(0, GetTextureManager()->GetTexture(
                             DEFAULT_TEXTURE, TextureManager::ETL_Permanent));
  BoxMesh->SetMaterialFlags(MAT_DEBUG_HUD);
  AddMesh(BoxMesh);
}
コード例 #12
0
ファイル: renderercommon.cpp プロジェクト: ptitSeb/Eldritch
void RendererCommon::DEBUGDrawCross(const Vector& Center, const float Length,
                                    unsigned int Color) {
  Mesh* CrossMesh = GetMeshFactory()->CreateDebugCross(Center, Length, Color);
  CrossMesh->m_IsDebugMesh = true;
  CrossMesh->SetMaterialDefinition(DEFAULT_NEWMATERIAL, this);
  CrossMesh->SetTexture(0, GetTextureManager()->GetTexture(
                               DEFAULT_TEXTURE, TextureManager::ETL_Permanent));
  CrossMesh->SetMaterialFlags(MAT_DEBUG_WORLD);
  AddMesh(CrossMesh);
}
コード例 #13
0
ファイル: Sat5Abort2.cpp プロジェクト: dseagrav/NASSP
void Sat5Abort2::init()

{
	SetSize (15);
	SetCOG_elev (15.225);
	SetEmptyMass (233000);
	SetMaxFuelMass (471000);
	SetFuelMass(444760);
	//SetISP (ISP_SECOND_VAC);
	SetISP (4780);
	//slThrust = CalcSeaLevelThrust(THRUST_SECOND_VAC,ISP_SECOND_VAC,ISP_SECOND_SL, 106000);
	//vacThrust = THRUST_SECOND_VAC;
	//vessel->SetMaxThrust (ENGINE_MAIN, slThrust);
	SetMaxThrust (ENGINE_MAIN, 6008625);
	SetMaxThrust (ENGINE_RETRO, 0);
	SetMaxThrust (ENGINE_HOVER, 0);
	SetMaxThrust (ENGINE_ATTITUDE, 5e4);
	SetEngineLevel(ENGINE_MAIN, 0.0);
	SetPMI (_V(374,374,80));
	SetCrossSections (_V(524,524,97));
	SetCW (0.1, 0.3, 1.4, 1.4);
	SetRotDrag (_V(0.7,0.7,1.2));
	SetPitchMomentScale (0);
	SetBankMomentScale (0);
	SetLiftCoeffFunc (0);
    ClearMeshes();
    ClearExhaustRefs();
    ClearAttExhaustRefs();
	//vessel->ShiftCentreOfMass (_V(0,0,12.25));
	VECTOR3 mesh_dir=_V(0,0,-17.2-STG1O);
	AddMesh (hsat5stg2, &mesh_dir);
	mesh_dir=_V(0,0,2.-STG1O);
	AddMesh (hsat5stg3, &mesh_dir);
	mesh_dir=_V(-1.48,-1.48,14.55-STG1O);
	AddMesh (hsat5stg31, &mesh_dir);
	mesh_dir=_V(1.48,-1.48,14.55-STG1O);
	AddMesh (hsat5stg32, &mesh_dir);
	mesh_dir=_V(1.48,1.48,14.55-STG1O);
    AddMesh (hsat5stg33, &mesh_dir);
	mesh_dir=_V(-1.48,1.48,14.55-STG1O);
    AddMesh (hsat5stg34, &mesh_dir);
	mesh_dir=_V(0,SMVO,19.1-STG1O);
	AddMesh (hSM, &mesh_dir);
	VECTOR3 m_exhaust_ref = {0,0,-1};
	VECTOR3 m_exhaust_pos1= {0,0,-28.25-STG1O};
	VECTOR3 m_exhaust_pos2= {2,2,-28.25-STG1O};
	VECTOR3 m_exhaust_pos3= {-2,2,-28.25-STG1O};
	VECTOR3 m_exhaust_pos4 = {2,-2.0,-28.25-STG1O};
	VECTOR3 m_exhaust_pos5 = {-2,-2,-28.25-STG1O};
	AddExhaustRef (EXHAUST_MAIN, m_exhaust_pos1, 25.0, 1.5, &m_exhaust_ref);
	AddExhaustRef (EXHAUST_MAIN, m_exhaust_pos2, 25.0, 1.5, &m_exhaust_ref);
	AddExhaustRef (EXHAUST_MAIN, m_exhaust_pos3, 25.0, 1.5, &m_exhaust_ref);
	AddExhaustRef (EXHAUST_MAIN, m_exhaust_pos4, 25.0, 1.5, &m_exhaust_ref);
	AddExhaustRef (EXHAUST_MAIN, m_exhaust_pos5, 25.0, 1.5, &m_exhaust_ref);
	status = 3;
	SetCameraOffset (_V(-1,1.0,32.4-STG1O));
}
コード例 #14
0
ファイル: renderercommon.cpp プロジェクト: ptitSeb/Eldritch
void RendererCommon::DEBUGDrawSphere(const Vector& Center, float Radius,
                                     unsigned int Color) {
  Mesh* SphereMesh = GetMeshFactory()->CreateDebugSphere(Center, Radius, Color);
  SphereMesh->m_IsDebugMesh = true;
  SphereMesh->SetMaterialDefinition(DEFAULT_NEWMATERIAL, this);
  SphereMesh->SetTexture(
      0, GetTextureManager()->GetTexture(DEFAULT_TEXTURE,
                                         TextureManager::ETL_Permanent));
  SphereMesh->SetMaterialFlags(MAT_DEBUG_WORLD);
  AddMesh(SphereMesh);
}
コード例 #15
0
ファイル: renderercommon.cpp プロジェクト: ptitSeb/Eldritch
void RendererCommon::DEBUGDrawArrow(const Vector& Root, const Angles& Direction,
                                    const float Length, unsigned int Color) {
  Mesh* ArrowMesh =
      GetMeshFactory()->CreateDebugArrow(Root, Direction, Length, Color);
  ArrowMesh->m_IsDebugMesh = true;
  ArrowMesh->SetMaterialDefinition(DEFAULT_NEWMATERIAL, this);
  ArrowMesh->SetTexture(0, GetTextureManager()->GetTexture(
                               DEFAULT_TEXTURE, TextureManager::ETL_Permanent));
  ArrowMesh->SetMaterialFlags(MAT_DEBUG_WORLD);
  AddMesh(ArrowMesh);
}
コード例 #16
0
osg::Node *VsMeshMgr::LoadMesh(std::string strFilename)
{
	std::pair<std::string, osg::ref_ptr<osg::Node>> MeshPair;
	
	//If not found then load it.
	if(!FindMesh(strFilename, MeshPair, false))
		return AddMesh(strFilename);
	else
	{
		std::string strCreateDate = FileCreateTime(strFilename);

		//If the create dates match then use this one.
		//If they do not then lets reload it.
		if(strCreateDate == MeshPair.first)
			return MeshPair.second.get();
		else
		{
			ReleaseMesh(strFilename);
			return AddMesh(strFilename);
		}
	}
}
コード例 #17
0
ファイル: renderercommon.cpp プロジェクト: ptitSeb/Eldritch
void RendererCommon::DEBUGDrawEllipsoid(const Vector& Center,
                                        const Vector& Extents,
                                        unsigned int Color) {
  Mesh* EllipsoidMesh =
      GetMeshFactory()->CreateDebugEllipsoid(Center, Extents, Color);
  EllipsoidMesh->m_IsDebugMesh = true;
  EllipsoidMesh->SetMaterialDefinition(DEFAULT_NEWMATERIAL, this);
  EllipsoidMesh->SetTexture(
      0, GetTextureManager()->GetTexture(DEFAULT_TEXTURE,
                                         TextureManager::ETL_Permanent));
  EllipsoidMesh->SetMaterialFlags(MAT_DEBUG_WORLD);
  AddMesh(EllipsoidMesh);
}
コード例 #18
0
void InterplanetarySC::clbkSetClassCaps(FILEHANDLE cfg)
{
	MESHHANDLE mesh;
	mesh = oapiLoadMeshGlobal("ThermalFissionCraft"); 
	
	UINT idx;
	idx = AddMesh(mesh);

	SetMeshVisibilityMode(idx,MESHVIS_EXTERNAL);
		
	SetSize(350.0); 
	SetEmptyMass(400000.0);
	createSubSystems();

}
コード例 #19
0
ファイル: eva.cpp プロジェクト: dseagrav/NASSP
void EVA::init ()
{
	GoDock1 = false;
	SetSize (3.5);
	SetEmptyMass (115);
	SetMaxFuelMass (10);
	SetFuelMass (10);
	SetISP(10000);
	SetMaxThrust (ENGINE_ATTITUDE, 5);
	SetEngineLevel(ENGINE_MAIN, 0.0);
	SetPMI (_V(5,5,5));
	SetRotDrag (_V(0.7,0.7,1.2));
	SetPitchMomentScale (0);
	SetBankMomentScale (0);
	SetLiftCoeffFunc (0);
    ClearMeshes();
    ClearExhaustRefs();
    ClearAttExhaustRefs();
    VECTOR3 mesh_dir=_V(0,0,0);
    AddMesh (hCMPEVA, &mesh_dir);
}
コード例 #20
0
HRESULT CModelContent::AddMeshPart(LPCSTR name, UINT vertexBufferId, UINT indexBufferId, UINT materialId)
{
    HRESULT hr = S_OK;

    MeshInfo meshInfo;
    hr = GetMesh(name, meshInfo);
    if (SUCCEEDED(hr))
    {
        // Find the next available mesh part id to use
        UINT meshPartId = GetNextMeshPartId();

        // Add a new mesh using the MESHPART_PREFIX + mesh part id
        std::string meshPartName = MESHPART_PREFIX + ConvertToA<std::string>(meshPartId);

        // Update parent meshInfo 
        m_meshMap[name].numSubMeshIds++;
        m_meshMap[name].subMeshIds[meshInfo.numSubMeshIds] = meshPartId;

        // Add the mesh part
        hr = AddMesh(meshPartName.c_str(), vertexBufferId, indexBufferId, materialId);
    }

    return hr;
}
コード例 #21
0
// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
void SolarSail::clbkSetClassCaps (FILEHANDLE cfg)
{
	// physical specs
	SetSize (SAIL_RADIUS*2.0);
	SetEmptyMass (100.0);
	SetCW (0.3, 0.3, 0.6, 0.9);
	SetWingAspect (0.7);
	SetWingEffectiveness (2.5);
	SetCrossSections (_V(10.5,15.0,5.8));
	SetRotDrag (_V(0.6,0.6,0.35));
	if (GetFlightModel() >= 1) {
		SetPitchMomentScale (1e-4);
		SetYawMomentScale (1e-4);
	}
	SetPMI (_V(3e3,3e3,6e3));
	SetTrimScale (0.05);
	SetCameraOffset (_V(0,0.8,0));
	SetLiftCoeffFunc (LiftCoeff);
	SetDockParams (_V(0,1.3,-1), _V(0,1,0), _V(0,0,-1));
	SetTouchdownPoints (_V(0,-1.5,2), _V(-1,-1.5,-1.5), _V(1,-1.5,-1.5));

	// visual specs
	AddMesh (hMeshTpl);
}
コード例 #22
0
uint32 SMeshWidget::AddMeshWithInstancing(USlateVectorArtData& InMeshData, int32 InitialBufferSize)
{
	const uint32 NewMeshId = AddMesh(InMeshData);
	EnableInstancing(NewMeshId, InitialBufferSize);
	return NewMeshId;
}
コード例 #23
0
// Set vessel class parameters
void Dragonfly::SetClassCaps (FILEHANDLE cfg)
{
	
	int i;

	SetSize (4.0);
	SetEmptyMass (EMPTY_MASS);
	SetCrossSections (_V(23.7,22.5,17.3));
	SetPMI (_V(5.4,5.4,2.5));
	SetCameraOffset (_V(0,1.5,0));

	// ************************* propellant specs **********************************

	ph_main = CreatePropellantResource (MAX_MAIN_FUEL);

	// *********************** thruster definitions ********************************

	// thrusters in left pod
	th_lp[0] = CreateThruster (_V(-3.5,0,0), _V(1,0,0), 2*MAX_RCS_THRUST, ph_main, ISP);
	th_lp[1] = CreateThruster (_V(-2.98,0,-0.8), _V(0,0,1), MAX_RCS_THRUST, ph_main, ISP);
	th_lp[2] = CreateThruster (_V(-2.98,0,0.8), _V(0,0,-1), MAX_RCS_THRUST, ph_main, ISP);
	th_lp[3] = CreateThruster (_V(-2.98,-0.8,0), _V(0,1,0), MAX_RCS_THRUST, ph_main, ISP);
	th_lp[4] = CreateThruster (_V(-2.98,0.8,0), _V(0,-1,0), MAX_RCS_THRUST, ph_main, ISP);

	// thrusters in right pod
	th_rp[0] = CreateThruster (_V(3.5,0,0), _V(-1,0,0), 2*MAX_RCS_THRUST, ph_main, ISP);
	th_rp[1] = CreateThruster (_V(2.98,0,-0.8), _V(0,0,1), MAX_RCS_THRUST, ph_main, ISP);
	th_rp[2] = CreateThruster (_V(2.98,0,0.8), _V(0,0,-1), MAX_RCS_THRUST, ph_main, ISP);
	th_rp[3] = CreateThruster (_V(2.98,-0.8,0), _V(0,1,0), MAX_RCS_THRUST, ph_main, ISP);
	th_rp[4] = CreateThruster (_V(2.98,0.8,0), _V(0,-1,0), MAX_RCS_THRUST, ph_main, ISP);

	// thrusters in aft pod (rotational RCS)
	th_ap[0] = CreateThruster (_V(-0.8,0,-11.1), _V(1,0,0), MAX_RCS_THRUST, ph_main, ISP);
	th_ap[1] = CreateThruster (_V(0.8,0,-11.1), _V(-1,0,0), MAX_RCS_THRUST, ph_main, ISP);
	th_ap[2] = CreateThruster (_V(0,-0.8,-11.1), _V(0,1,0), MAX_RCS_THRUST, ph_main, ISP);
	th_ap[3] = CreateThruster (_V(0,0.8,-11.1), _V(0,-1,0), MAX_RCS_THRUST, ph_main, ISP);

	// exhaust definitions for left pod
	AddExhaust (th_lp[0], 1, 0.15, _V(-3.5,0.18,-0.18), _V(-1,0,0));
	AddExhaust (th_lp[0], 1, 0.15, _V(-3.5,-0.18,0.18), _V(-1,0,0));
	for (i = 1; i < 5; i++) AddExhaust (th_lp[i], 1, 0.15);

	// exhaust definitions for right pod
	AddExhaust (th_rp[0], 1, 0.15, _V(3.5,-0.18,-0.18), _V(1,0,0));
	AddExhaust (th_rp[0], 1, 0.15, _V(3.5,0.18,0.18), _V(1,0,0));
	for (i = 1; i < 5; i++) AddExhaust (th_rp[i], 1, 0.15);

	// exhaust definitions for aft pod
	for (i = 0; i < 4; i++) AddExhaust (th_ap[i], 1, 0.15);
	//thruster definitions. Both manual and "automatic" RCS
	SetManualRCS();
	SetNormalRCS();//
	
	// *************************** docking port ************************************

	SetDockParams (_V(0,0,3.2), _V(0,0,1), _V(0,1,0));
    
	// ******************************** mesh ***************************************

	AddMesh (oapiLoadMeshGlobal ("Dragonfly"));
};
コード例 #24
0
void ResourceManager::Init()
{
    AddMesh( MODEL_UNIT_SWORD, MESH_KEY_UNIT_SWORD );
    AddMesh( MODEL_UNIT_PIKE, MESH_KEY_UNIT_PIKE );
    AddMesh( MODEL_UNIT_ARROW, MESH_KEY_UNIT_ARROW );
    AddMesh( MODEL_UNIT_KNIGHT, MESH_KEY_UNIT_KNIGHT );
    AddMesh( MODEL_UNIT_GUARD, MESH_KEY_UNIT_GUARD );
    AddMesh( MODEL_UNIT_KING, MESH_KEY_UNIT_KING );

    AddMesh( MODEL_CORPS_DESTROY_A, MESH_KEY_CORPS_DESTROY_ENEMY );
    AddMesh( MODEL_CORPS_DEFENSE_A, MESH_KEY_CORPS_DEFENSE_ENEMY );
    AddMesh( MODEL_CORPS_RUSH_A, MESH_KEY_CORPS_RUSH_ENEMY );
    AddMesh( MODEL_CORPS_DESTROY_B, MESH_KEY_CORPS_DESTROY_MINE );
    AddMesh( MODEL_CORPS_DEFENSE_B, MESH_KEY_CORPS_DEFENSE_MINE );
    AddMesh( MODEL_CORPS_RUSH_B, MESH_KEY_CORPS_RUSH_MINE );

    AddMap( HEIGHT_MAP, HEIGHT_TEX, MAP_KEY_TEST );
    CreateMap( MAP_KEY_TEST );

    //////////////////////////////////////////////////////////////////////////
    // 쿼드트리를 적용하기 위해 하이트 맵은 2^n 형태의 크기로 만들어야 합니다.
    //
    // 주의! 실제 하이트맵 크기는 한 변이 2^n + 1 사이즈여야 합니다!
    //////////////////////////////////////////////////////////////////////////
    InitGroundMesh( 128, 128 );
    CreateRawGround( 128, 128, 5.0f );

    if ( FAILED( InitHeightMap( HEIGHT_MAP, 5.0f ) ) )
    {
        m_IsMapForQuadTreeReady = false;
    }
    else
    {
        m_IsMapForQuadTreeReady = true;
    }

    MapManager::GetInstance()->SetPixelSize( 5.0f );

    m_MapSize = 640;
    m_IsMapReady = true;

    InitSkyBoxMesh( 640 );

    SetSkyBoxTexture( SPRITE_SKYBOX_BACK, SKY_BOX_BACK );
    SetSkyBoxTexture( SPRITE_SKYBOX_FRONT, SKY_BOX_FRONT );
    SetSkyBoxTexture( SPRITE_SKYBOX_LEFT, SKY_BOX_LEFT );
    SetSkyBoxTexture( SPRITE_SKYBOX_RIGHT, SKY_BOX_RIGHT );
    SetSkyBoxTexture( SPRITE_SKYBOX_TOP, SKY_BOX_TOP );
    SetSkyBoxTexture( SPRITE_SKYBOX_BOTTOM, SKY_BOX_BOTTOM );

    InitCursor( CURSOR_MAX, MouseManager::GetInstance()->GetMousePositionX(), MouseManager::GetInstance()->GetMousePositionY() );
    CreateCursorImage( SPRITE_CURSOR_DEFAULT, CURSOR_DEFAULT );
    CreateCursorImage( SPRITE_CURSOR_ATTACK, CURSOR_ATTACK );
    CreateCursorImage( SPRITE_CURSOR_CLICK, CURSOR_CLICK );
    CreateCursorImage( SPRITE_CURSOR_OVER_CORPS, CURSOR_OVER_CORPS );
    CreateCursorImage( SPRITE_CURSOR_UNRECHEABLE, CURSOR_UNRECHEABLE );
    CreateCursorImage( SPRITE_CURSOR_CAMERA_ROTATING, CURSOR_CAMERA_ROTATING );
    CreateCursorImage( SPRITE_CURSOR_CORPS_MOVABLE, CURSOR_CORPS_MOVABLE );
    CreateCursorImage( SPRITE_CURSOR_CORPS_MOVABLE_CLICK, CURSOR_CORPS_MOVABLE_CLICK );
    CreateCursorImage( SPRITE_CURSOR_OVER_PICKED_CORPS, CURSOR_OVER_PICKED_CORPS );

    m_ISCursorReady = true;

    CreateSprite();

    ShaderCreate( SHADER_TYPE_MAX );
    ShaderImport( SELECT_SHADER, SHADER_SELECT );
    ShaderImport( FIGHT_SHADER, SHADER_FIGHT );
    ShaderImport( MAP_SHADER, SHADER_MAP );

    MeshTextureCreateBySize( CORPS_TEXTURE_MAX );
    MeshTextureImport( SPRITE_CORPS_TYPE_ARROW, CORPS_TEXTURE_ARROW );
    MeshTextureImport( SPRITE_CORPS_TYPE_GUARD, CORPS_TEXTURE_GUARD );
    MeshTextureImport( SPRITE_CORPS_TYPE_KING, CORPS_TEXTURE_KING );
    MeshTextureImport( SPRITE_CORPS_TYPE_KNIGHT, CORPS_TEXTURE_KNIGHT );
    MeshTextureImport( SPRITE_CORPS_TYPE_PIKE, CORPS_TEXTURE_PIKE );
    MeshTextureImport( SPRITE_CORPS_TYPE_SWORD, CORPS_TEXTURE_SWORD );
}
コード例 #25
0
void CPUTModel_CPRT::CreateModelLayer(ID3D11Device* pd3dDevice, ID3D11DeviceContext* pImmediateContext, ID3D10Blob* pVertexShaderBlob, LayerInitialization layerType)
{
	CPUTMesh* pMesh = new CPUTMesh();

	float* layer = NULL;
	switch(layerType)
	{
	case NORMAL_LAYER:
		if(normals.size() < 1)
			return;
		normalOverlays.push_back(pMesh);
		layer = normals.front();
		break;
	case TANGENT_LAYER:
		if(tangents.size() < 1)
			return;
		tangentOverlays.push_back(pMesh);
		layer = tangents.front();
		break;
	}
	
	float* vertsToSubmit = new float[vertexCount.front()*3*2];
	float* uvsToSubmit = new float[vertexCount.front()*3*2];

	unsigned int vertIndexToSubmit = 0, uvIndexToSubmit=0;
	for(unsigned int i = 0; i < vertexCount.front()*3; ++i,vertIndexToSubmit+=3,uvIndexToSubmit+=2)//Going to process the vertex/normal information to create a bunch of lines
	{
		vertsToSubmit[vertIndexToSubmit] = vertices.front()[i];
		uvsToSubmit[uvIndexToSubmit] = 0.0f;
		vertsToSubmit[vertIndexToSubmit+3] = vertices.front()[i]+0.2f*layer[i];
		uvsToSubmit[uvIndexToSubmit+2] = 1.0f;
		++i,++vertIndexToSubmit;++uvIndexToSubmit;
		vertsToSubmit[vertIndexToSubmit] = vertices.front()[i];
		uvsToSubmit[uvIndexToSubmit] = 0.0f;
		vertsToSubmit[vertIndexToSubmit+3] = vertices.front()[i]+0.2f*layer[i];
		uvsToSubmit[uvIndexToSubmit+2] = 1.0f;
		++i,++vertIndexToSubmit;++uvIndexToSubmit;
		vertsToSubmit[vertIndexToSubmit] = vertices.front()[i];
		vertsToSubmit[vertIndexToSubmit+3] = vertices.front()[i]+0.2f*layer[i];
		++vertIndexToSubmit;
	}
	delete layer;
	// set the topology
	pMesh->SetMeshTopology( CPUT_TOPOLOGY_LINE_LIST );
	CPUTMeshStreamUniform* meshStream = new CPUTMeshStreamUniform();
	// position stream
	CPUTMeshStreamInfoBlock* infoBlock = new CPUTMeshStreamInfoBlock();
	meshStream->SetName("POSITION");
	meshStream->SetData(vertsToSubmit);
	infoBlock->m_StreamBufferType = CPUT_STREAM_TYPE_VERTEX;
	infoBlock->m_StreamComponentsLayoutType =  CPUT_STREAM_ELEMENT_LAYOUT_UNIFORM;
	infoBlock->m_DataFormatElementType = CPUT_F32;
	infoBlock->m_NumberDataFormatElements = 3;  // 3xF32 
	infoBlock->m_DataElementBlockSize = sizeof(float)*3; // 12 bytes = size of CPUT_F32_F32_F32 element
	infoBlock->m_NumberVerticies = vertexCount.front()*2;
	meshStream->SetStreamInfo(infoBlock);
	pMesh->AddVertexStream(meshStream);

	// UV stream
	meshStream = new CPUTMeshStreamUniform();
	infoBlock = new CPUTMeshStreamInfoBlock();
	meshStream->SetName("TEXCOORD");
	meshStream->SetData(uvsToSubmit);
	infoBlock->m_StreamBufferType = CPUT_STREAM_TYPE_VERTEX;
	infoBlock->m_StreamComponentsLayoutType =  CPUT_STREAM_ELEMENT_LAYOUT_UNIFORM;
	infoBlock->m_DataFormatElementType = CPUT_F32;
	infoBlock->m_NumberDataFormatElements = 2;  // 3xF32 
	infoBlock->m_DataElementBlockSize = sizeof(float)*3; // 12 bytes = size of CPUT_F32_F32_F32 element
	infoBlock->m_NumberVerticies = vertexCount.front()*2;
	meshStream->SetStreamInfo(infoBlock);
	pMesh->AddVertexStream(meshStream);

	CPUTMaterialPhong* pMaterialPhong = new CPUTMaterialPhong();
	switch(layerType)
	{
	case NORMAL_LAYER:
		pMaterialPhong->SetTexture( CPUT_PHONG_MATERIAL_PROPERTY_DIFFUSE_TEXTURE, pd3dDevice, "../media/normals.png" );
		break;
	case TANGENT_LAYER:
		pMaterialPhong->SetTexture( CPUT_PHONG_MATERIAL_PROPERTY_DIFFUSE_TEXTURE, pd3dDevice, "../media/tangents.png" );
		break;
	}
		
	pMesh->SetMaterial((CPUTMaterialBase*)pMaterialPhong);

	int currentNumMeshes = AddMesh(pMesh);

	D3D11_INPUT_ELEMENT_DESC* layout = NULL;
	ID3D11InputLayout*  pVertexLayout = NULL;
	pMesh = (CPUTMesh*) GetMesh(currentNumMeshes-1);
	layerIndices.push_back(currentNumMeshes-1);

	// register each mesh with the current graphics device
	pMesh->Register(pd3dDevice, &layout);
                    
	// Create the input layout (TODO: should this be left to user to do?) 
	int numInputLayoutElements;
	pMesh->GetNumberOfInputLayoutElements(numInputLayoutElements); 

	int numElements = pMesh->GetVertexStreamCount();            
	pd3dDevice->CreateInputLayout( layout, numInputLayoutElements, pVertexShaderBlob->GetBufferPointer(), pVertexShaderBlob->GetBufferSize(), &pVertexLayout );         
	pMesh->SetDXLayout(pVertexLayout);
	delete vertsToSubmit;
	delete uvsToSubmit;
	
	switch(layerType)
	{
	case NORMAL_LAYER:
		normals.erase(normals.begin());
		break;
	case TANGENT_LAYER:
		tangents.erase(tangents.begin());
		break;
	}
}
コード例 #26
0
// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
void ShuttlePB::clbkSetClassCaps (FILEHANDLE cfg)
{
	THRUSTER_HANDLE th_main, th_hover, th_rcs[14], th_group[4];

	// physical vessel parameters
	SetSize (PB_SIZE);
	SetEmptyMass (PB_EMPTYMASS);
	SetPMI (PB_PMI);
	SetCrossSections (PB_CS);
	SetRotDrag (PB_RD);
	SetTouchdownPoints (PB_TDP[0], PB_TDP[1], PB_TDP[2]);

	// docking port definitions
	SetDockParams (PB_DOCK_POS, PB_DOCK_DIR, PB_DOCK_ROT);

	// airfoil definitions
	CreateAirfoil3 (LIFT_VERTICAL,   PB_COP, vlift, NULL, PB_VLIFT_C, PB_VLIFT_S, PB_VLIFT_A);
	CreateAirfoil3 (LIFT_HORIZONTAL, PB_COP, hlift, NULL, PB_HLIFT_C, PB_HLIFT_S, PB_HLIFT_A);

	// control surface animations
	UINT anim_Laileron = CreateAnimation (0.5);
	UINT anim_Raileron = CreateAnimation (0.5);
	UINT anim_elevator = CreateAnimation (0.5);
	AddAnimationComponent (anim_Laileron, 0, 1, &trans_Laileron);
	AddAnimationComponent (anim_Raileron, 0, 1, &trans_Raileron);
	AddAnimationComponent (anim_elevator, 0, 1, &trans_Lelevator);
	AddAnimationComponent (anim_elevator, 0, 1, &trans_Relevator);

	// aerodynamic control surface defintions
	CreateControlSurface (AIRCTRL_ELEVATOR, 1.5, 0.7, _V( 0,0,-2.5), AIRCTRL_AXIS_XPOS, anim_elevator);
	CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, _V( 1,0,-2.5), AIRCTRL_AXIS_XPOS, anim_Laileron);
	CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, _V(-1,0,-2.5), AIRCTRL_AXIS_XNEG, anim_Raileron);

	// propellant resources
	PROPELLANT_HANDLE hpr = CreatePropellantResource (PB_FUELMASS);

	// main engine
	th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, PB_ISP);
	CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
	AddExhaust (th_main, 8, 1, _V(0,0.3,-4.35), _V(0,0,-1));

	PARTICLESTREAMSPEC contrail_main = {
		0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};
	PARTICLESTREAMSPEC exhaust_main = {
		0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
	AddExhaustStream (th_main, _V(0,0.3,-10), &contrail_main);
	AddExhaustStream (th_main, _V(0,0.3,-5), &exhaust_main);

	// hover engine
	th_hover = CreateThruster (_V(0,-1.5,0), _V(0,1,0), PB_MAXHOVERTH, hpr, PB_ISP);
	CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);
	AddExhaust (th_hover, 8, 1, _V(0,-1.5,1), _V(0,-1,0));
	AddExhaust (th_hover, 8, 1, _V(0,-1.5,-1), _V(0,-1,0));

	PARTICLESTREAMSPEC contrail_hover = {
		0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};
	PARTICLESTREAMSPEC exhaust_hover = {
		0, 2.0, 10, 200, 0.05, 0.05, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};

	AddExhaustStream (th_hover, _V(0,-3, 1), &contrail_hover);
	AddExhaustStream (th_hover, _V(0,-3,-1), &contrail_hover);
	AddExhaustStream (th_hover, _V(0,-2, 1), &exhaust_hover);
	AddExhaustStream (th_hover, _V(0,-2,-1), &exhaust_hover);

	// RCS engines
	th_rcs[ 0] = CreateThruster (_V( 1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 1] = CreateThruster (_V( 1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 2] = CreateThruster (_V(-1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 3] = CreateThruster (_V(-1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 4] = CreateThruster (_V( 1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 5] = CreateThruster (_V( 1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 6] = CreateThruster (_V(-1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 7] = CreateThruster (_V(-1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 8] = CreateThruster (_V( 1,0, 3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 9] = CreateThruster (_V(-1,0, 3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[10] = CreateThruster (_V( 1,0,-3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[11] = CreateThruster (_V(-1,0,-3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[12] = CreateThruster (_V( 0,0,-3), _V(0,0, 1), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[13] = CreateThruster (_V( 0,0, 3), _V(0,0,-1), PB_MAXRCSTH, hpr, PB_ISP);

	th_group[0] = th_rcs[0];
	th_group[1] = th_rcs[2];
	th_group[2] = th_rcs[5];
	th_group[3] = th_rcs[7];
	CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHUP);

	th_group[0] = th_rcs[1];
	th_group[1] = th_rcs[3];
	th_group[2] = th_rcs[4];
	th_group[3] = th_rcs[6];
	CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHDOWN);

	th_group[0] = th_rcs[0];
	th_group[1] = th_rcs[4];
	th_group[2] = th_rcs[3];
	th_group[3] = th_rcs[7];
	CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKLEFT);

	th_group[0] = th_rcs[1];
	th_group[1] = th_rcs[5];
	th_group[2] = th_rcs[2];
	th_group[3] = th_rcs[6];
	CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKRIGHT);

	th_group[0] = th_rcs[0];
	th_group[1] = th_rcs[4];
	th_group[2] = th_rcs[2];
	th_group[3] = th_rcs[6];
	CreateThrusterGroup (th_group, 4, THGROUP_ATT_UP);

	th_group[0] = th_rcs[1];
	th_group[1] = th_rcs[5];
	th_group[2] = th_rcs[3];
	th_group[3] = th_rcs[7];
	CreateThrusterGroup (th_group, 4, THGROUP_ATT_DOWN);

	th_group[0] = th_rcs[8];
	th_group[1] = th_rcs[11];
	CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWLEFT);

	th_group[0] = th_rcs[9];
	th_group[1] = th_rcs[10];
	CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWRIGHT);

	th_group[0] = th_rcs[8];
	th_group[1] = th_rcs[10];
	CreateThrusterGroup (th_group, 2, THGROUP_ATT_LEFT);

	th_group[0] = th_rcs[9];
	th_group[1] = th_rcs[11];
	CreateThrusterGroup (th_group, 2, THGROUP_ATT_RIGHT);

	CreateThrusterGroup (th_rcs+12, 1, THGROUP_ATT_FORWARD);
	CreateThrusterGroup (th_rcs+13, 1, THGROUP_ATT_BACK);

	// camera parameters
	SetCameraOffset (_V(0,0.8,0));

	// associate a mesh for the visual
	AddMesh ("ShuttlePB");
}
コード例 #27
0
void dgPolygonSoupDatabaseBuilder::Optimize(bool optimize)
{
	#define DG_PATITION_SIZE (1024 * 4)
	if (optimize && (m_faceCount > DG_PATITION_SIZE)) {

		dgBigVector median (hacd::HaF32 (0.0f), hacd::HaF32 (0.0f), hacd::HaF32 (0.0f), hacd::HaF32 (0.0f));
		dgBigVector varian (hacd::HaF32 (0.0f), hacd::HaF32 (0.0f), hacd::HaF32 (0.0f), hacd::HaF32 (0.0f));

		dgStack<dgVector> pool (1024 * 2);
		dgStack<hacd::HaI32> indexArray (1024 * 2);
		hacd::HaI32 polygonIndex = 0;
		for (hacd::HaI32 i = 0; i < m_faceCount; i ++) {

			dgBigVector p0 (hacd::HaF32 ( 1.0e10f), hacd::HaF32 ( 1.0e10f), hacd::HaF32 ( 1.0e10f), hacd::HaF32 (0.0f));
			dgBigVector p1 (hacd::HaF32 (-1.0e10f), hacd::HaF32 (-1.0e10f), hacd::HaF32 (-1.0e10f), hacd::HaF32 (0.0f));
			hacd::HaI32 count = m_faceVertexCount[i];

			for (hacd::HaI32 j = 1; j < count; j ++) {
				hacd::HaI32 k = m_vertexIndex[polygonIndex + j];
				p0.m_x = GetMin (p0.m_x, hacd::HaF64 (m_vertexPoints[k].m_x));
				p0.m_y = GetMin (p0.m_y, hacd::HaF64 (m_vertexPoints[k].m_y));
				p0.m_z = GetMin (p0.m_z, hacd::HaF64 (m_vertexPoints[k].m_z));
				p1.m_x = GetMax (p1.m_x, hacd::HaF64 (m_vertexPoints[k].m_x));
				p1.m_y = GetMax (p1.m_y, hacd::HaF64 (m_vertexPoints[k].m_y));
				p1.m_z = GetMax (p1.m_z, hacd::HaF64 (m_vertexPoints[k].m_z));
			}

			dgBigVector p ((p0 + p1).Scale (0.5f));
			median += p;
			varian += p.CompProduct (p);
			polygonIndex += count;
		}

		varian = varian.Scale (hacd::HaF32 (m_faceCount)) - median.CompProduct(median);

		hacd::HaI32 axis = 0;
		hacd::HaF32 maxVarian = hacd::HaF32 (-1.0e10f);
		for (hacd::HaI32 i = 0; i < 3; i ++) {
			if (varian[i] > maxVarian) {
				axis = i;
				maxVarian = hacd::HaF32 (varian[i]);
			}
		}
		dgBigVector center = median.Scale (hacd::HaF32 (1.0f) / hacd::HaF32 (m_faceCount));
		hacd::HaF64 axisVal = center[axis];

		dgPolygonSoupDatabaseBuilder left;
		dgPolygonSoupDatabaseBuilder right;

		left.Begin();
		right.Begin();
		polygonIndex = 0;
		for (hacd::HaI32 i = 0; i < m_faceCount; i ++) {
			hacd::HaI32 side = 0;
			hacd::HaI32 count = m_faceVertexCount[i];
			for (hacd::HaI32 j = 1; j < count; j ++) {
				hacd::HaI32 k;
				k = m_vertexIndex[polygonIndex + j];
				dgVector p (&m_vertexPoints[k].m_x);
				if (p[axis] > axisVal) {
					side = 1;
					break;
				}
			}

			hacd::HaI32 faceArray = count - 1;
			hacd::HaI32 faceTagsData = m_vertexIndex[polygonIndex];
			for (hacd::HaI32 j = 1; j < count; j ++) {
				hacd::HaI32 k = m_vertexIndex[polygonIndex + j];
				pool[j - 1] = m_vertexPoints[k];
				indexArray[j - 1] = j - 1;
			}

			if (!side) {
				left.AddMesh (&pool[0].m_x, count - 1, sizeof (dgVector), 1, &faceArray, &indexArray[0], &faceTagsData, dgGetIdentityMatrix()); 
			} else {
				right.AddMesh (&pool[0].m_x, count - 1, sizeof (dgVector), 1, &faceArray, &indexArray[0], &faceTagsData, dgGetIdentityMatrix()); 
			}
			polygonIndex += count;
		}

		left.Optimize(optimize);
		right.Optimize(optimize);

		m_faceCount = 0;
		m_indexCount = 0;
		m_vertexCount = 0;
		m_normalCount = 0;
		polygonIndex = 0;
		for (hacd::HaI32 i = 0; i < left.m_faceCount; i ++) {
			hacd::HaI32 count = left.m_faceVertexCount[i];
			hacd::HaI32 faceArray = count - 1;
			hacd::HaI32 faceTagsData = left.m_vertexIndex[polygonIndex];
			for (hacd::HaI32 j = 1; j < count; j ++) {
				hacd::HaI32 k = left.m_vertexIndex[polygonIndex + j];
				pool[j - 1] = left.m_vertexPoints[k];
				indexArray[j - 1] = j - 1;
			}
			AddMesh (&pool[0].m_x, count - 1, sizeof (dgVector), 1, &faceArray, &indexArray[0], &faceTagsData, dgGetIdentityMatrix()); 
			polygonIndex += count;
		}

		polygonIndex = 0;
		for (hacd::HaI32 i = 0; i < right.m_faceCount; i ++) {
			hacd::HaI32 count = right.m_faceVertexCount[i];
			hacd::HaI32 faceArray = count - 1;
			hacd::HaI32 faceTagsData = right.m_vertexIndex[polygonIndex];
			for (hacd::HaI32 j = 1; j < count; j ++) {
				hacd::HaI32 k = right.m_vertexIndex[polygonIndex + j];
				pool[j - 1] = right.m_vertexPoints[k];
				indexArray[j - 1] = j - 1;
			}
			AddMesh (&pool[0].m_x, count - 1, sizeof (dgVector), 1, &faceArray, &indexArray[0], &faceTagsData, dgGetIdentityMatrix()); 
			polygonIndex += count;
		}

		if (m_faceCount < DG_PATITION_SIZE) { 
			EndAndOptimize(optimize);
		} else {
			EndAndOptimize(false);
		}

	} else {
		EndAndOptimize(optimize);
	}
}
コード例 #28
0
void dgPolygonSoupDatabaseBuilder::OptimizeByGroupID (dgPolygonSoupDatabaseBuilder& source, hacd::HaI32 faceNumber, hacd::HaI32 faceIndexNumber, dgPolygonSoupDatabaseBuilder& leftOver) 
{
	hacd::HaI32 indexPool[1024 * 1];
	hacd::HaI32 atributeData[1024 * 1];
	dgVector vertexPool[1024 * 1];
	dgPolyhedra polyhedra;

	hacd::HaI32 attribute = source.m_vertexIndex[faceIndexNumber];
	for (hacd::HaI32 i = 0; i < hacd::HaI32 (sizeof(atributeData) / sizeof (hacd::HaI32)); i ++) {
		indexPool[i] = i;
		atributeData[i] = attribute;
	}

	leftOver.Begin();
	polyhedra.BeginFace ();
	for (hacd::HaI32 i = faceNumber; i < source.m_faceCount; i ++) {
		hacd::HaI32 indexCount;
		indexCount = source.m_faceVertexCount[i];
		HACD_ASSERT (indexCount < 1024);

		if (source.m_vertexIndex[faceIndexNumber] == attribute) {
			dgEdge* const face = polyhedra.AddFace(indexCount - 1, &source.m_vertexIndex[faceIndexNumber + 1]);
			if (!face) {
				hacd::HaI32 faceArray;
				for (hacd::HaI32 j = 0; j < indexCount - 1; j ++) {
					hacd::HaI32 index;
					index = source.m_vertexIndex[faceIndexNumber + j + 1];
					vertexPool[j] = source.m_vertexPoints[index];
				}
				faceArray = indexCount - 1;
				leftOver.AddMesh (&vertexPool[0].m_x, indexCount - 1, sizeof (dgVector), 1, &faceArray, indexPool, atributeData, dgGetIdentityMatrix());
			} else {
				// set the attribute
				dgEdge* ptr = face;
				do {
					ptr->m_userData = hacd::HaU64 (attribute);
					ptr = ptr->m_next;
				} while (ptr != face);
			}
		}
		faceIndexNumber += indexCount; 
	} 

	leftOver.Optimize(false);
	polyhedra.EndFace();


	dgPolyhedra facesLeft;
	facesLeft.BeginFace();
	polyhedra.ConvexPartition (&source.m_vertexPoints[0].m_x, sizeof (dgBigVector), &facesLeft);
	facesLeft.EndFace();


	hacd::HaI32 mark = polyhedra.IncLRU();
	dgPolyhedra::Iterator iter (polyhedra);
	for (iter.Begin(); iter; iter ++) {
		dgEdge* const edge = &(*iter);
		if (edge->m_incidentFace < 0) {
			continue;
		}
		if (edge->m_mark == mark) {
			continue;
		}

		dgEdge* ptr = edge;
		hacd::HaI32 indexCount = 0;
		do {
			ptr->m_mark = mark;
			vertexPool[indexCount] = source.m_vertexPoints[ptr->m_incidentVertex];
			indexCount ++;
			ptr = ptr->m_next;
 		} while (ptr != edge);

		if (indexCount >= 3) {
			AddMesh (&vertexPool[0].m_x, indexCount, sizeof (dgVector), 1, &indexCount, indexPool, atributeData, dgGetIdentityMatrix());
		}
	}


	mark = facesLeft.IncLRU();
	dgPolyhedra::Iterator iter1 (facesLeft);
	for (iter1.Begin(); iter1; iter1 ++) {
		dgEdge* const edge = &(*iter1);
		if (edge->m_incidentFace < 0) {
			continue;
		}
		if (edge->m_mark == mark) {
			continue;
		}

		dgEdge* ptr = edge;
		hacd::HaI32 indexCount = 0;
		do {
			ptr->m_mark = mark;
			vertexPool[indexCount] = source.m_vertexPoints[ptr->m_incidentVertex];
			indexCount ++;
			ptr = ptr->m_next;
 		} while (ptr != edge);
		if (indexCount >= 3) {
			AddMesh (&vertexPool[0].m_x, indexCount, sizeof (dgVector), 1, &indexCount, indexPool, atributeData, dgGetIdentityMatrix());
		}
	}
}
コード例 #29
0
	Dbool MeshManager::LoadMesh(string PathName)
	{
		CustomMesh* pMesh = CreateMeshFromFile(PathName.c_str());

		return AddMesh(PathName, pMesh);
	}
コード例 #30
0
ファイル: asd.Mesh_Test.cpp プロジェクト: Pctg-x8/Altseed
void Graphics_Mesh(bool isOpenGLMode)
{
	StartGraphicsTest();
	SetGLEnable(isOpenGLMode);

	asd::Log* log = asd::Log_Imp::Create(L"graphics.html", L"メッシュ");

	auto window = asd::Window_Imp::Create(640, 480, asd::ToAString(L"メッシュ").c_str());
	ASSERT_TRUE(window != nullptr);

	auto file = asd::File_Imp::Create();
	ASSERT_TRUE(file != nullptr);

	auto graphics = asd::Graphics_Imp::Create(window, isOpenGLMode ? asd::GraphicsDeviceType::OpenGL : asd::GraphicsDeviceType::DirectX11, log, file, false, false);
	ASSERT_TRUE(graphics != nullptr);

	auto renderer3d = new asd::Renderer3D(graphics, asd::RenderSettings());
	ASSERT_TRUE(renderer3d != nullptr);
	renderer3d->SetWindowSize(asd::Vector2DI(640, 480));

	auto mesh1 = CreateMesh(graphics);
	auto mesh2 = CreateMesh(graphics);
	auto deformer = CreateDeformer(graphics);
	auto animation = CreateAnimation();

	SetMeshBone(mesh2);

	mesh1->SendToGPUMemory();
	mesh2->SendToGPUMemory();

	auto cameraObject = new asd::RenderedCameraObject3D(graphics);
	cameraObject->SetPosition(asd::Vector3DF(0, 0, 10));
	cameraObject->SetFocus(asd::Vector3DF(0, 0, 0));
	cameraObject->SetFieldOfView(20.0f);
	cameraObject->SetZNear(1.0f);
	cameraObject->SetZFar(20.0f);
	cameraObject->SetWindowSize(asd::Vector2DI(800, 600));

	auto meshObject1 = new asd::RenderedModelObject3D(graphics);
	meshObject1->AddMesh(mesh1);
	
	meshObject1->SetPosition(asd::Vector3DF(1, 0, 0));
	meshObject1->SetRotation(asd::Vector3DF(20.0f, 20.0f, 0.0f));

	auto meshObject2 = new asd::RenderedModelObject3D(graphics);
	meshObject2->AddMesh(mesh2);
	meshObject2->SetDeformer(deformer.get());
	meshObject2->SetPosition(asd::Vector3DF(-1, 0, 0));
	meshObject2->SetRotation(asd::Vector3DF(20.0f, 20.0f, 0.0f));
	meshObject2->AddAnimationClip(asd::ToAString("anime1").c_str(), animation.get());
	meshObject2->PlayAnimation(0, asd::ToAString("anime1").c_str());

	auto lightObject = new asd::RenderedDirectionalLightObject3D(graphics);
	lightObject->SetRotation(asd::Vector3DF(30, 160, 0));

	renderer3d->AddObject(cameraObject);
	renderer3d->AddObject(meshObject1);
	renderer3d->AddObject(meshObject2);
	renderer3d->AddObject(lightObject);

	int32_t time = 0;
	while (window->DoEvent())
	{
		graphics->Begin();
		graphics->Clear(true, false, asd::Color(0, 0, 0, 255));

		renderer3d->Flip(1);

		renderer3d->BeginRendering(1);
		asd::Sleep(100);
		renderer3d->EndRendering();

		graphics->SetRenderTarget(nullptr, nullptr);
		graphics->Clear(true, false, asd::Color(0, 0, 0, 255));

		renderer3d->RenderResult();

		graphics->Present();

		graphics->End();

		if (time == 10)
		{
			SAVE_SCREEN_SHOT(graphics, 0);
		}

		if (time == 11)
		{
			window->Close();
		}
		time++;
	}

	meshObject1->Release();
	meshObject2->Release();

	cameraObject->Release();
	lightObject->Release();

	delete renderer3d;

	graphics->Release();
	file->Release();

	window->Release();
	delete log;
}