Esempio n. 1
0
//--------------------------------------------
void CC4Projectile::Launch(const Vec3 &pos, const Vec3 &dir, const Vec3 &velocity, float speedScale)
{
	CProjectile::Launch(pos, dir, velocity, speedScale);

	if(!gEnv->bMultiplayer)
	{
		//don't want the hud grenade indicator on c4 in multiplayer
		OnLaunch();
	}

	if(m_pAmmoParams->armTime > 0.f)
	{
		GetEntity()->SetTimer(ePTIMER_ACTIVATION, (int)(m_pAmmoParams->armTime*1000.f));
		Arm(false);
	}
	else
	{
		Arm(true);
	}

	//Set up armed/disarmed materials and set material based on initial armed state
	if(SC4ExplosiveParams* pExplosiveParams = m_pAmmoParams->pC4ExplosiveParams)
	{
		if(int count = GetEntity()->GetSlotCount())
		{
			for(int i = 0; i < count; i++)
			{
				SEntitySlotInfo info;
				GetEntity()->GetSlotInfo(i, info);
				if(info.pStatObj)
				{
					IMaterial* pMaterial = info.pStatObj->GetMaterial();
					if(pMaterial)
					{
						m_pStatObj = info.pStatObj;
						m_pStatObj->AddRef();

						IMaterialManager* pMatManager = gEnv->p3DEngine->GetMaterialManager();
						if( m_pArmedMaterial = pMatManager->LoadMaterial(pExplosiveParams->armedMaterial, false) )
						{
							m_pArmedMaterial->AddRef();
						}
						if( m_pDisarmedMaterial = pMatManager->LoadMaterial(pExplosiveParams->disarmedMaterial, false) )
						{
							m_pDisarmedMaterial->AddRef();
						}
						
						info.pStatObj->SetMaterial(m_armed ? m_pArmedMaterial : m_pDisarmedMaterial);

						break;
					}
				}
			}
		}
	}
}
Esempio n. 2
0
int CLivingEntitySample::GetColliderSurfaceTypeId() const
{
	I3DEngine* p3DEngine = gEnv->p3DEngine;
	assert( p3DEngine != NULL );

	IMaterialManager* pMaterialManager = p3DEngine->GetMaterialManager();
	assert( pMaterialManager != NULL );

	const int surfaceTypeId = pMaterialManager->GetSurfaceTypeIdByName( "mat_player_collider" );
	return surfaceTypeId;
}
Esempio n. 3
0
//--------------------------------------------------------------------------------------------------
// Name: LoadMaterial
// Desc: Loads and calls AddRef on material
//--------------------------------------------------------------------------------------------------
IMaterial* CGameEffect::LoadMaterial(const char* pMaterialName) 
{
	IMaterial* pMaterial = NULL;
	I3DEngine* p3DEngine = gEnv->p3DEngine;
	if(pMaterialName && p3DEngine)
	{
		IMaterialManager* pMaterialManager = p3DEngine->GetMaterialManager();
		if(pMaterialManager)
		{
			pMaterial = pMaterialManager->LoadMaterial(pMaterialName);
			if(pMaterial)
			{
				pMaterial->AddRef();
			}
		}
	}
	return pMaterial;
}//-------------------------------------------------------------------------------------------------
Esempio n. 4
0
IInstanceCollectionNode* EditorScene::CreateCollectionNode(IModelMesh* mesh, int maxNum)
{
	IInstanceCollectionNode* collectionNode = mSceneManager->addInstanceCollectionNode(mesh, nullptr, maxNum, 0);
	IMaterialManager* materialManager = IMaterialManager::getInstance();
	IPipelineManager* pipelineManager = IPipelineManager::getInstance();

	std::string prefix = "multi_";
	for (u32 i = 0; i < mesh->getSubsetCount(); i++)
	{
		IMaterial* material = mesh->getMaterial(i);
		if (!material)
			continue;

		std::string multiMaterialName = prefix + material->getName();

		IMaterial* multi_material = materialManager->get(multiMaterialName, false);
		if (!multi_material)
		{
			SMaterial material2(*material);
			material2.setName(multiMaterialName);
			for (u32 j = 0; j < EPU_COUNT; j++)
			{
				IPipeline* pipeline = material2.getPipeline(j);
				if (pipeline)
				{
					std::string pipeline_name2 = prefix + pipeline->getName();
					IPipeline* pipeline2 = pipelineManager->get(pipeline_name2);
					material2.setPipeline(j, pipeline2);
				}
			}

			materialManager->add(material2);
			multi_material = materialManager->get(multiMaterialName, false);
		}

		collectionNode->setMaterial(i, multi_material);
	}

	collectionNode->addShadow(1);
	return collectionNode;
}
IMaterial* CDoorPanelBehavior::CreateClonedMaterial( IEntity* pEntity, const int iSlotIndex )
{
	CRY_ASSERT( m_pClonedAnimatedMaterial == NULL );

	IMaterial* pClonedMaterial = NULL;

	IEntityRenderProxy* pRenderProxy = static_cast<IEntityRenderProxy*>(pEntity->GetProxy(ENTITY_PROXY_RENDER));
	if (pRenderProxy)
	{
		IMaterial* pOriginalMaterial = pRenderProxy->GetRenderMaterial(iSlotIndex);
		if (pOriginalMaterial)
		{
			IMaterialManager* pMatManager = gEnv->p3DEngine->GetMaterialManager();
			CRY_ASSERT(pMatManager);

			pClonedMaterial = pMatManager->CloneMaterial( pOriginalMaterial );
			if (pClonedMaterial)
			{
				m_pClonedAnimatedMaterial = pClonedMaterial;
				pClonedMaterial->SetFlags( pClonedMaterial->GetFlags()|MTL_FLAG_PURE_CHILD ); // Notify that its not shared so won't try to remove by name in material manager which removes original material
			}
			else
			{
				GameWarning("CDoorPanelBehavior::CreateClonedMaterial: Failed to clone material");
			}
		}
		else
		{
			GameWarning("CDoorPanelBehavior::CreateClonedMaterial: Failed to get material from slot: %d", DOOR_PANEL_MODEL_NORMAL_SLOT);
		}
	}
	else
	{
		GameWarning("CDoorPanelBehavior::CreateClonedMaterial: Failed getting render proxy");
	}

	return pClonedMaterial;
}
void CTeamVisualizationManager::InitTeamVisualizationData( XmlNodeRef xmlNode )
{
	if(m_teamVisualizationPartsMap.empty())
	{
		IMaterialManager *pMaterialManager = gEnv->p3DEngine->GetMaterialManager();

		// Parse Team vis data and add to m_teamVisualizationPartsMap; 
		XmlNodeRef pPlayerTeamVisualization = xmlNode->findChild("PlayerTeamVisualization");
		DesignerWarning(pPlayerTeamVisualization, "expected to find <PlayerTeamVisualization> </PlayerTeamVisualization>, not found");
		if(pPlayerTeamVisualization)
		{
			Crc32Gen* pCRCGen = gEnv->pSystem->GetCrc32Gen();

			// Grab each model setup node
			const int modelCount = pPlayerTeamVisualization->getChildCount();
			for(int i = 0; i < modelCount; ++i)
			{
				XmlNodeRef pModelSetup = pPlayerTeamVisualization->getChild(i);
				if(pModelSetup)
				{
					// Friendly 
					XmlNodeRef friendlyNode = pModelSetup->findChild("Friendly");
					DesignerWarning(friendlyNode, "missing <Friendly> </Friendly> tags in model setup <%d> - PlayerTeamVisualization.xml", i);
					if(friendlyNode)
					{
						// Hostile
						XmlNodeRef hostileNode = pModelSetup->findChild("Hostile");
						DesignerWarning(hostileNode, "missing <Hostile> </Hostile> tags in model setup <%d> - PlayerTeamVisualization.xml", i);
						if(hostileNode)
						{

							XmlNodeRef attachmentsNode = pModelSetup->findChild("BodyAttachments");
							const int numAttachments = attachmentsNode->getChildCount();
							DesignerWarning(attachmentsNode && numAttachments > 0, "missing <BodyAttachments> </bodyAttachments> tags in model setup <%d> or no child <BodyAttachment> elements - PlayerTeamVisualization.xml", i);
							if(attachmentsNode && numAttachments > 0)
							{
								const char* pModelName = pModelSetup->getAttr("name");
								DesignerWarning(pModelName && pModelName[0], "missing <Model> tag - or <Model name=""> attribute invalid - in model setup <%d> - PlayerTeamVisualization.xml", i);
								if(pModelName && pModelName[0])
								{
									// Add new + Fill in details
									TModelNameCRC modelNameCRC = pCRCGen->GetCRC32Lowercase(pModelName); 
									CRY_ASSERT(m_teamVisualizationPartsMap.find(modelNameCRC) == m_teamVisualizationPartsMap.end());
									m_teamVisualizationPartsMap[modelNameCRC] = SModelMaterialSetup(); 
									SModelMaterialSetup& newConfig = m_teamVisualizationPartsMap[modelNameCRC];

									// Get materials
									newConfig.SetMaterial(eMI_AliveFriendly, pMaterialManager->LoadMaterial(friendlyNode->getAttr("MaterialName")));
									newConfig.SetMaterial(eMI_AliveHostile, pMaterialManager->LoadMaterial(hostileNode->getAttr("MaterialName")));

									// Hostile
									XmlNodeRef deadFriendlyNode = pModelSetup->findChild("DeadFriendly");
									DesignerWarning(deadFriendlyNode, "missing <DeadFriendly> </DeadFriendly> tags in model setup <%d> - PlayerTeamVisualization.xml", i);
									if(deadFriendlyNode)
									{
										newConfig.SetMaterial(eMI_DeadFriendly, pMaterialManager->LoadMaterial(deadFriendlyNode->getAttr("MaterialName")));
									}

									XmlNodeRef deadHostileNode = pModelSetup->findChild("DeadHostile");
									DesignerWarning(deadHostileNode, "missing <deadHostileNode> </deadHostileNode> tags in model setup <%d> - PlayerTeamVisualization.xml", i);
									if(deadHostileNode)
									{
										newConfig.SetMaterial(eMI_DeadHostile, pMaterialManager->LoadMaterial(deadHostileNode->getAttr("MaterialName")));
									}

									// Attachments
									newConfig.m_attachments.reserve(numAttachments);
									for(int j = 0; j < numAttachments; ++j)
									{
										XmlNodeRef attachmentNode = attachmentsNode->getChild(j);
										newConfig.m_attachments.push_back(pCRCGen->GetCRC32Lowercase(attachmentNode->getAttr("name")));
									}	
									continue;
								}	
							}
						}
					}
				}
			}
		}
	}
}
Esempio n. 7
0
//------------------------------------------------------------------------
void CDebugGun::Update( SEntityUpdateContext& ctx, int update)
{ 
  if (!IsSelected())
    return;
  
  static float drawColor[4] = {1,1,1,1};
  static const int dx = 5; 
  static const int dy = 15;
  static const float font = 1.2f;
  static const float fontLarge = 1.4f;

  IRenderer* pRenderer = gEnv->pRenderer;
  IRenderAuxGeom* pAuxGeom = pRenderer->GetIRenderAuxGeom();
  pAuxGeom->SetRenderFlags(e_Def3DPublicRenderflags);

  pRenderer->Draw2dLabel(pRenderer->GetWidth()/5.f, pRenderer->GetHeight()-35, fontLarge, drawColor, false, "Firemode: %s (%.1f)", m_fireModes[m_fireMode].first.c_str(), m_fireModes[m_fireMode].second);      

  ray_hit rayhit;
  int hits = 0;
  
  unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
  if (m_fireModes[m_fireMode].first == "pierceability")
  { 
    flags = (unsigned int)m_fireModes[m_fireMode].second & rwi_pierceability_mask;
  }
  
  // use cam, no need for firing pos/dir
  CCamera& cam = GetISystem()->GetViewCamera();

  if (hits = gEnv->pPhysicalWorld->RayWorldIntersection(cam.GetPosition()+cam.GetViewdir(), cam.GetViewdir()*HIT_RANGE, ent_all, flags, &rayhit, 1))
  {
    IMaterialManager* pMatMan = gEnv->p3DEngine->GetMaterialManager();
    IActorSystem* pActorSystem = g_pGame->GetIGameFramework()->GetIActorSystem();
    IVehicleSystem* pVehicleSystem = g_pGame->GetIGameFramework()->GetIVehicleSystem();
    
    int x = (int)(pRenderer->GetWidth() *0.5f) + dx;
    int y = (int)(pRenderer->GetHeight()*0.5f) + dx - dy;

    // draw normal
    ColorB colNormal(200,0,0,128);
    Vec3 end = rayhit.pt + 0.75f*rayhit.n;
    pAuxGeom->DrawLine(rayhit.pt, colNormal, end, colNormal);
    pAuxGeom->DrawCone(end, rayhit.n, 0.1f, 0.2f, colNormal);

    IEntity * pEntity = (IEntity*)rayhit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY);
    if(pEntity)
    {  
      pRenderer->Draw2dLabel(x, y+=dy, fontLarge, drawColor, false, pEntity->GetName());      
    }
    
    // material
    const char* matName = pMatMan->GetSurfaceType(rayhit.surface_idx)->GetName();

    if (matName[0])      
      pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%s (%i)", matName, rayhit.surface_idx);

    pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.1f m", rayhit.dist);

    if (pEntity)
    {
      IScriptTable* pScriptTable = pEntity->GetScriptTable();

      // physics 
      if (IPhysicalEntity* pPhysEnt = pEntity->GetPhysics())
      {
        pe_status_dynamics status;
        if (pPhysEnt->GetStatus(&status))
        {        
          if (status.mass > 0.f)
            pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.1f kg", status.mass);

          pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "pe_type: %i", pPhysEnt->GetType());                

          if (status.submergedFraction > 0.f)
            pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.2f submerged", status.submergedFraction);

          if (status.v.len2() > 0.0001f)
            pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.2f m/s", status.v.len());
        }   
      }  

      if (pScriptTable)
      {
        HSCRIPTFUNCTION func = 0;
        if (pScriptTable->GetValue("GetFrozenAmount", func) && func)
        {
          float frozen = 0.f;
          Script::CallReturn(gEnv->pScriptSystem, func, pScriptTable, frozen);
					gEnv->pScriptSystem->ReleaseFunc(func);
          
          if (frozen > 0.f)
            pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "Frozen: %.2f", frozen); 
        }
      }
     
      // class-specific stuff
      if (IActor* pActor = pActorSystem->GetActor(pEntity->GetId()))
      {
        pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%i health", pActor->GetHealth());
      }
      else if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(pEntity->GetId()))
      {
        const SVehicleStatus& status = pVehicle->GetStatus();
        
        pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.0f%% health", 100.f*status.health);
        pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%i passengers", status.passengerCount);
        
        if (pVehicle->GetMovement() && pVehicle->GetMovement()->IsPowered())
        {
          pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "Running");
        }
      }
      else
      {
        if (pScriptTable)
        {
          HSCRIPTFUNCTION func = 0;
          if (pScriptTable->GetValue("GetHealth", func) && func)
          {
            float health = 0.f;
            if (Script::CallReturn(gEnv->pScriptSystem, func, pScriptTable, health))
            {
              pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.0f health", health);
            }
						gEnv->pScriptSystem->ReleaseFunc(func);
          }
        }
      }
    }    
  }  
}
Esempio n. 8
0
int main()
{
	//int avg = 2 * 90 + 3 * 88 + 4 * 87 + 3 * 84 + 4 * 92 + 2 * 93 + 2 * 83 + 2 * 80 + 2 * 95;
	//std::cout << "Avg : " << avg << std::endl;

	SDeviceContextSettings settings;
	settings.MultiSamplingCount = 4;
	settings.MultiSamplingQuality = 32;

	IDevice* device = createDevice(EDT_DIRECT3D11, 800, 600, EWS_NONE, true, settings);
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IMeshManager* meshManager = driver->getMeshManager();
	IMaterialManager* materialManager = driver->getMaterialManager();

	IResourceGroupManager* resourceGroupManager = driver->getResourceGroupManager();
	resourceGroupManager->init("Resources.cfg");
	resourceGroupManager->loadResourceGroup("General");

	ISimpleMesh* cubeMesh = meshManager->createCubeMesh("cube1");
	IMeshNode* cubeMeshNode = smgr->addMeshNode(cubeMesh, nullptr, nullptr, XMFLOAT3(0, 3.0f, 0));
	cubeMeshNode->setMaterialName("test/material01");
	//cubeMeshNode->remove();

	ISimpleMesh* planeMesh = meshManager->createPlaneMesh("plane1", 10.0, 10.0f, 50, 50, 10.0f, 10.0f);
	IMeshNode* planeMeshNode = smgr->addMeshNode(planeMesh, nullptr);
	planeMeshNode->setMaterialName("test/ground_material");

	IAnimatedMesh* animMesh = meshManager->getAnimatedMesh("lxq.mesh");
	IAnimatedMeshNode* animNode = smgr->addAnimatedMeshNode(animMesh);
	animNode->scale(0.02f, 0.02f, 0.02f);
	IModelMesh* heroMesh = meshManager->getModelMesh("hero.mesh");
	IMeshNode* heroNode = smgr->addModelMeshNode(heroMesh);	
	
	heroNode->scale(0.01f, 0.01f, 0.01f);
	heroNode->translate(2.0f, 0.5f, 0);

	// create sampler state
	SSamplerDesc samplerDesc;
	samplerDesc.Filter = ESF_FILTER_MIN_MAG_MIP_LINEAR;
	samplerDesc.AddressU = EAM_WRAP;
	samplerDesc.AddressV = EAM_WRAP;
	samplerDesc.AddressW = EAM_WRAP;
	ISampler* sampler = driver->getSamplerManager()->create(std::string("sampler1"), samplerDesc);

	IPipeline* pipeline = driver->getPipelineManager()->get("test/pipeline01");
	//pipeline->setSampler(std::string("sampleType"), sampler);

	ILightNode* light = smgr->addLightNode(1);
	light->setType(ELT_POINT);
	light->setAmbient(XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f));
	light->setPosition(2.0f, 5.0f, -3.0f);
	light->setSpecular(XMFLOAT4(1.0f, 1.0f, 1.0f, 32.0f));
	light->setDiffuse(XMFLOAT4(0.8f, 0.8f, 0.8f, 1.0f));
	light->setAttenuation(1.0f, 0.0f, 0.0f);
	light->setRange(100.0f);

	materialManager->destroy(std::string("test/material02"));

	//ICameraNode* camera = smgr->addFpsCameraNode(1, nullptr, XMFLOAT3(0, 1.0f, -4.0f), XMFLOAT3(0, 1.0f, 0.0f));
	ICameraNode* camera = smgr->addFpsCameraNode(1, nullptr, XMFLOAT3(0, 1.0f, -4.0f), XMFLOAT3(0, 1.0f, 0.0f));

	f32 rotx = 0;
	f32 roty = 0;
	f32 rotz = 0;

	char caption[200];

	//FILE* fp = fopen("log.txt", "w");

	ITimer* timer = device->createTimer();
	timer->reset();

	while (device->run())
	{
		const float clearColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
		driver->beginScene(true, true, clearColor);

		float dt = timer->tick();
		
		rotx += dt * 2.0f;
		roty += dt * 1.0f;
		rotz += dt * 0.5f;
		if (rotx > XM_2PI) rotx -= XM_2PI;
		if (roty > XM_2PI) roty -= XM_2PI;
		if (rotz > XM_2PI) rotz -= XM_2PI;

		XMMATRIX Mx = XMMatrixRotationX(rotx);
		XMMATRIX My = XMMatrixRotationY(roty);
		XMMATRIX Mz = XMMatrixRotationZ(rotz);
		XMMATRIX rotM = Mx * My * Mz;

		cubeMeshNode->setOrientation(rotM);
	//	heroNode->yaw(dt);
		animNode->addTime(dt * 3000.0f);

		updateCamera(camera, dt);
	//	std::cout << dt << std::endl;

		smgr->drawAll();

		driver->endScene();

		sprintf(caption, "FPS:%f", getFps(dt));
		device->setWindowCaption(caption);
	}

	device->drop();

	return 0;
}
Esempio n. 9
0
BOOL Init3D(HWND hwnd)
{
    const UINT bufferWidth = 640;
    const UINT bufferHeight = 480;

    //初始化失败
    if(!IRoot.InitD3D( hwnd, bufferWidth, bufferHeight,TRUE))return FALSE;

    IScene.CreateMesh(Mesh1);
    IScene.CreateRenderer(Renderer);
    IScene.CreateCamera(ICamera);
    IScene.CreateLightManager(LightMgr);
    IScene.CreateMaterialManager(MatMgr);
    IScene.CreateTextureManager(TexMgr);
    IScene.CreateAtmosphere(Atmos);
    fontMgr.Initialize();


    //漫反射贴图
    //TexMgr.CreateTextureFromFile(L"Earth.jpg", "Earth", TRUE,0, 0, TRUE);
    //TexMgr.CreatePureColorTexture("myText", 300, 100, NVECTOR4(0.0f, 0.0f, 0.0f, 0.0f), TRUE);
    TexMgr.CreateTextureFromFile(L"media/button1.png", "GUI_Button1", TRUE, 0, 0, FALSE);
    TexMgr.CreateTextureFromFile(L"media/button2.png", "GUI_Button2", TRUE, 0, 0, FALSE);
    TexMgr.CreateTextureFromFile(L"media/button3.png", "GUI_Button3", TRUE, 0, 0, FALSE);
    TexMgr.CreateTextureFromFile(L"media/button4.png", "GUI_Button4", TRUE, 0, 0, FALSE);
    TexMgr.CreateTextureFromFile(L"media/Earth.jpg","Earth", TRUE,0, 0,FALSE);
    TexMgr.CreateTextureFromFile(L"media/Earth.jpg", "EarthNormalMap", TRUE, 0, 0, TRUE);
    TexMgr.CreateTextureFromFile(L"media/texture2.jpg", "Wood", TRUE, 0, 0, FALSE);
    TexMgr.CreateTextureFromFile(L"media/universe2.jpg", "Universe", FALSE, 512, 512, FALSE);
    TexMgr.CreateTextureFromFile(L"media/bottom-right-conner-title.jpg", "BottomRightTitle", TRUE, 0, 0, FALSE);
    TexMgr.CreateCubeMapFromDDS(L"media/UniverseEnv.dds", "EnvironmentMap",NOISE_CUBEMAP_SIZE_256x256);
    TexMgr.ConvertTextureToGreyMap(TexMgr.GetTextureID("EarthNormalMap"));
    TexMgr.ConvertHeightMapToNormalMap(TexMgr.GetTextureID("EarthNormalMap"),20.0f);

    //create font texture
    fontMgr.CreateFontFromFile("media/STXINWEI.ttf", "myFont", 24);

    fontMgr.InitStaticTextW(0, L"TextBox的CapsLock和大小写/ GUI system需不需要重构一下啊....很多Event是比较重复的....= =", 300, 100, NVECTOR4(0, 1.0f, 0.5f, 1.0f), 0, 0, myText1);

    myText1.SetTextColor(NVECTOR4(1.0f, 0, 0, 0.5f));
    myText1.SetCenterPos(300.0f, 100.0f);
    fontMgr.InitDynamicTextA(0, "abcdefghijklmnopqrstuvwxyz!@#$%^&*()_<>-+?/+ 1234567890<>?,./{}[]\\", 300, 100, NVECTOR4(0, 1.0f, 0.5f, 1.0f), 0, 0, myText2);
    myText2.SetTextColor(NVECTOR4(0.5f, 0.3f, 1.0f, 0.5f));
    myText2.SetCenterPos(300.0f,400.0f);
    fontMgr.InitDynamicTextA(0, "fps:000", 200, 100, NVECTOR4(0,0,0,1.0f), 0, 0, myText_fps);
    myText_fps.SetTextColor(NVECTOR4(0,0.3f,1.0f,0.5f));
    myText_fps.SetDiagonal(NVECTOR2(20, 20),NVECTOR2(150, 60));
    myText_fps.SetFont(0);

    Renderer.SetFillMode(NOISE_FILLMODE_SOLID);
    Renderer.SetCullMode(NOISE_CULLMODE_BACK);//NOISE_CULLMODE_BACK

    //Mesh1.LoadFile_STL("object.stl");
    Mesh1.CreateSphere(5.0f, 30, 30);
    //Mesh1.CreatePlane(10.0f, 10.0f, 5, 5);
    Mesh1.SetPosition(0,0,0);

    ICamera.SetPosition(2.0f,0,0);
    ICamera.SetLookAt(0,0,0);
    ICamera.SetViewAngle(MATH_PI / 2.5f, 1.333333333f);
    ICamera.SetViewFrustumPlane(1.0f, 500.f);
    //use bounding box of mesh to init camera pos
    NVECTOR3 AABB_MAX = Mesh1.ComputeBoundingBoxMax();
    float rotateRadius = sqrtf(AABB_MAX.x*AABB_MAX.x + AABB_MAX.z*AABB_MAX.z)*1.2f;
    float rotateY = Mesh1.ComputeBoundingBoxMax().y*1.3f;
    ICamera.SetPosition(rotateRadius*0.7f, rotateY, rotateRadius*0.7f);
    ICamera.SetLookAt(0, rotateY / 2, 0);

    Atmos.SetFogEnabled(FALSE);
    Atmos.SetFogParameter(7.0f, 8.0f, NVECTOR3(0, 0, 1.0f));
    Atmos.CreateSkyDome(4.0f, 4.0f, TexMgr.GetTextureID("Universe"));
    //Atmos.CreateSkyBox(10.0f, 10.0f, 10.0f, TexMgr.GetIndexByName("EnvironmentMap"));

    //——————灯光————————
    DirLight1.mAmbientColor = NVECTOR3(1.0f,1.0f,1.0f);
    DirLight1.mDiffuseColor	=	NVECTOR3(1.0f,1.0f,1.0f);
    DirLight1.mSpecularColor	=NVECTOR3(1.0f,1.0f,1.0f);
    DirLight1.mDirection = NVECTOR3(0.0f, -0.5f, 1.0f);
    DirLight1.mSpecularIntensity	=1.5f;
    DirLight1.mDiffuseIntensity = 1.0f;
    LightMgr.CreateDynamicDirLight(DirLight1);

    N_Material Mat1;
    Mat1.baseMaterial.mBaseAmbientColor	= NVECTOR3(0.1f,  0.1f,0.1f);
    Mat1.baseMaterial.mBaseDiffuseColor		= NVECTOR3(1.0f,  1.0f, 1.0f);
    Mat1.baseMaterial.mBaseSpecularColor	=	NVECTOR3(1.0f, 1.0f,1.0f);
    Mat1.baseMaterial.mSpecularSmoothLevel	=	40;
    Mat1.baseMaterial.mNormalMapBumpIntensity = 0.3f;
    Mat1.baseMaterial.mEnvironmentMapTransparency = 0.05f;
    Mat1.diffuseMapID = TexMgr.GetTextureID("Wood");//"Earth");
    Mat1.normalMapID = TexMgr.GetTextureID("EarthNormalMap");
    Mat1.cubeMap_environmentMapID = NOISE_MACRO_INVALID_TEXTURE_ID;//TexMgr.GetTextureID("EnvironmentMap");
    UINT	 Mat1_ID = MatMgr.CreateMaterial(Mat1);

    //set material
    Mesh1.SetMaterial(Mat1_ID);

    GraphicObjBuffer.AddRectangle(NVECTOR2(340.0f, 430.0f), NVECTOR2(640.0f, 480.0f), NVECTOR4(0.3f, 0.3f, 1.0f, 1.0f),TexMgr.GetTextureID("BottomRightTitle"));

    //GUI System
    GUIMgr.Initialize(bufferWidth, bufferHeight, Renderer, inputE, fontMgr, hwnd);
    GUIMgr.SetWindowHWND(hwnd);
    GUIMgr.SetFontManager(fontMgr);
    GUIMgr.InitButton(GUIButton1);
    GUIMgr.InitScrollBar(GUIScrollBar1);
    GUIMgr.InitTextBox(GUITextBox1,0);
    GUIButton1.SetCenterPos(150.0f, 50.0f);
    GUIButton1.SetWidth(300.0f);
    GUIButton1.SetHeight(100.0f);
    GUIButton1.SetDragableX(TRUE);
    GUIButton1.SetDragableY(TRUE);
    GUIButton1.SetTexture(NOISE_GUI_BUTTON_STATE_COMMON,TexMgr.GetTextureID("GUI_Button2"));
    GUIButton1.SetTexture(NOISE_GUI_BUTTON_STATE_MOUSEON,TexMgr.GetTextureID("GUI_Button3"));
    GUIButton1.SetTexture(NOISE_GUI_BUTTON_STATE_MOUSEBUTTONDOWN,TexMgr.GetTextureID("GUI_Button4"));
    GUIButton1.SetEventProcessCallbackFunction(Button1MsgProc);
    GUIScrollBar1.SetCenterPos(300.0f, 300.0f);
    GUIScrollBar1.SetWidth(30.0f);
    GUIScrollBar1.SetHeight(300.0f);
    GUIScrollBar1.SetTexture_ScrollButton(NOISE_GUI_BUTTON_STATE_COMMON, TexMgr.GetTextureID("GUI_Button1"));
    GUIScrollBar1.SetTexture_ScrollButton(NOISE_GUI_BUTTON_STATE_MOUSEON, TexMgr.GetTextureID("GUI_Button2"));
    GUIScrollBar1.SetTexture_ScrollButton(NOISE_GUI_BUTTON_STATE_MOUSEBUTTONDOWN, TexMgr.GetTextureID("GUI_Button3"));
    GUIScrollBar1.SetTexture_ScrollGroove(TexMgr.GetTextureID("GUI_Button4"));
    GUIScrollBar1.SetAlignment(FALSE);
    GUIScrollBar1.SetValue(0.5f);
    GUITextBox1.SetTextColor({ 1.0f,0,0,1.0f });
    GUITextBox1.SetCenterPos(470.0f, 400.0f);
    GUITextBox1.SetWidth(300.0f);
    GUITextBox1.SetHeight(80.0f);
    GUITextBox1.SetFont(0);
    GUITextBox1.SetMaxWordCount(20);
    GUITextBox1.SetTexture_BackGround( TexMgr.GetTextureID("GUI_Button3"));
    GUITextBox1.SetTexture_Cursor( TexMgr.GetTextureID("GUI_Button2"));
    GUIMgr.Update();




    /*Slicer.Step1_LoadPrimitiveMeshFromSTLFile("object.stl");
    Slicer.Step2_Intersection(5);
    Slicer.Step3_GenerateLineStrip();// extremely neccessary for optimization
    Slicer.Step4_SaveLayerDataToFile("object.LayerOutput");*/
    //Slicer.Step3_LoadLineStripsFrom_NOISELAYER_File("object.LayerOutput");

    /*NVECTOR3 v1, v2, n;

    for (UINT i = 0;i < Slicer.GetLineStripCount();i++)
    {

    	Slicer.GetLineStrip(lineStrip, i);
    	for (UINT j = 0;j < lineStrip.at(i).pointList.size() - 1;j++)
    	{
    		v1 = lineStrip.at(i).pointList.at(j);
    		v2 = lineStrip.at(i).pointList.at(j + 1);
    		n = lineStrip.at(i).normalList.at(j);
    		//vertex
    		GraphicObjBuffer.AddLine3D(v1, v2);
    		//normal
    		GraphicObjBuffer.AddLine3D((v1 + v2) / 2, ((v1 + v2) / 2) + n / 4, NVECTOR4(1.0f, 1.0f, 1.0f, 1.0f), NVECTOR4(1.0f, 0.2f, 0.2f, 1.0f));
    	}
    }*/

    return TRUE;
};