Beispiel #1
0
CWreckage* CDigitanksEntity::CreateWreckage()
{
	// Figure out what to do about structures later.
	if (dynamic_cast<CDigitank*>(this) == NULL)
		return NULL;

	CWreckage* pWreckage = GameServer()->Create<CWreckage>("CWreckage");
	pWreckage->SetGlobalOrigin(GetRenderOrigin());
	pWreckage->SetGlobalAngles(GetRenderAngles());
	pWreckage->SetModel(GetModelID());
	pWreckage->SetGlobalGravity(Vector(0, 0, DigitanksGame()->GetGravity()));
	pWreckage->SetOldPlayer(GetDigitanksPlayer());

	pWreckage->CalculateVisibility();

	CDigitank* pTank = dynamic_cast<CDigitank*>(this);
	if (pTank)
		pWreckage->SetTurretModel(pTank->GetTurretModel());

	bool bColorSwap = GetPlayerOwner() && (dynamic_cast<CDigitank*>(this));
	if (bColorSwap)
		pWreckage->SetColorSwap(GetPlayerOwner()->GetColor());

	return pWreckage;
}
VOID Obj_Monster::InitBackupAttr()
{
__ENTER_FUNCTION

	m_AttrBackUp.m_bNameModified		= FALSE;
	m_AttrBackUp.m_bTitleModified		= FALSE;
	m_AttrBackUp.m_HP					= GetHP();
	m_AttrBackUp.m_MP					= GetMP();	//	add by gh 2010/03/25
	const _CAMP_DATA *pCampData = GetCampData();
	if ( pCampData != NULL )
		m_AttrBackUp.m_CampData			= *pCampData;
	m_AttrBackUp.m_MaxHp				= GetMaxHP();
	m_AttrBackUp.m_MaxMp				= GetMaxMP();	//	add by gh 2010/03/25
	m_AttrBackUp.m_MoveSpeed			= GetMoveSpeed();
	m_AttrBackUp.m_nDataID				= GetDataID();
	m_AttrBackUp.m_nModelID				= GetModelID();
	m_AttrBackUp.m_nMountID				= GetMountID();
	m_AttrBackUp.m_nAIType				= GetAIType();
	m_AttrBackUp.m_OwnerID				= GetOwnerID();
	m_AttrBackUp.m_OccupantGUID			= GetOccupantGUID();
	m_AttrBackUp.m_nStealthLevel		= GetStealthLevel();
	m_AttrBackUp.m_nMoodState			= GetMoodState();
	m_AttrBackUp.m_iHorseID				= GetHorseID();
	m_AttrBackUp.m_iWeaponID			= GetWeaponID();
__LEAVE_FUNCTION
}
Beispiel #3
0
void CStatic::OnSetModel()
{
	BaseClass::OnSetModel();

	// In case the model has changed.
	if (IsInPhysics())
		RemoveFromPhysics();

	if (GetModelID() == ~0)
		return;

	AddToPhysics(CT_STATIC_MESH);
}
void Cedrus::XIDDevice::MatchConfigToModel(char model)
{
    m_config = XIDDeviceScanner::GetDeviceScanner().GetConfigForGivenDevice(GetProductID(), model != -1 ? model : GetModelID(), m_config->GetMajorVersion());
    if (model != -1)
        m_ResponseMgr.reset(m_config->IsInputDevice() ? new ResponseManager(m_config) : nullptr);
}
VOID Obj_Monster::SendMsg_RefeshAttrib( VOID )
{
__ENTER_FUNCTION

	BOOL bPublicAttrModified ;
	bPublicAttrModified		= FALSE;

	GCCharBaseAttrib msgPublicAttr, msgProtectedAttr;

	msgPublicAttr.setObjID( GetID() );
	msgProtectedAttr.setObjID( GetID() );

	//msgPublicAttr.setName( GetName() );
	//msgProtectedAttr.setName( GetName() );

	//msgPublicAttr.setTitle( GetTitle() );
	//msgProtectedAttr.setTitle( GetTitle() );

	if(m_AttrBackUp.m_HP != GetHP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_HP = GetHP();

		BYTE yHPPercent = (GetMaxHP())?((BYTE)((GetHP()*100 + GetMaxHP() - 1)/GetMaxHP())):(0);
		msgPublicAttr.setHPPercent( yHPPercent );
		msgProtectedAttr.setHPPercent( yHPPercent );
	}

	if(m_AttrBackUp.m_MaxHp != GetMaxHP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MaxHp = GetMaxHP();

		BYTE yHPPercent = (GetMaxHP())?((BYTE)((GetHP()*100 + GetMaxHP() - 1)/GetMaxHP())):(0);
		msgPublicAttr.setHPPercent( yHPPercent );
		msgProtectedAttr.setHPPercent( yHPPercent );
	}

	// add by gh 2010/03/30
	if(m_AttrBackUp.m_MP != GetMP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MP = GetMP();

		BYTE yMPPercent = (GetMaxMP())?((BYTE)((GetMP()*100 + GetMaxMP() - 1)/GetMaxMP())):(0);
		msgPublicAttr.setMPPercent( yMPPercent );
		msgProtectedAttr.setMPPercent( yMPPercent );
	}

	if(m_AttrBackUp.m_MaxMp != GetMaxMP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MaxMp = GetMaxMP();

		BYTE yMPPercent = (GetMaxMP())?((BYTE)((GetMP()*100 + GetMaxMP() - 1)/GetMaxMP())):(0);
		msgPublicAttr.setMPPercent( yMPPercent );
		msgProtectedAttr.setMPPercent( yMPPercent );
	}
	// end of add
	if(fabs(m_AttrBackUp.m_MoveSpeed-GetMoveSpeed()) > 0.001f)
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MoveSpeed = GetMoveSpeed();

		msgPublicAttr.setMoveSpeed( GetMoveSpeed() );
		msgProtectedAttr.setMoveSpeed( GetMoveSpeed() );
	}

	if(m_AttrBackUp.m_nDataID != GetDataID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nDataID = GetDataID();

	}

	const _CAMP_DATA *pCampData = GetCampData();
	if ( pCampData != NULL )
	{
		if(m_AttrBackUp.m_CampData != *pCampData)
		{
			bPublicAttrModified = TRUE;
			m_AttrBackUp.m_CampData = *pCampData;

			msgPublicAttr.setCampData( pCampData );
			msgProtectedAttr.setCampData( pCampData );
		}
	}

	if(m_AttrBackUp.m_OwnerID != GetOwnerID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_OwnerID = GetOwnerID();

		msgPublicAttr.setOwnerID( GetOwnerID() );
		msgProtectedAttr.setOwnerID( GetOwnerID() );
	}

	if(m_AttrBackUp.m_OccupantGUID != GetOccupantGUID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_OccupantGUID = GetOccupantGUID();

		msgPublicAttr.setOccupantGUID( GetOccupantGUID() );
		msgProtectedAttr.setOccupantGUID( GetOccupantGUID() );
	}

	if(m_AttrBackUp.m_nModelID != GetModelID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nModelID = GetModelID();
		msgPublicAttr.setModelID( GetModelID() );
		msgProtectedAttr.setModelID( GetModelID() );
	}

	if(m_AttrBackUp.m_nMountID != GetMountID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nMountID = GetMountID();
		msgPublicAttr.setMountID( GetMountID() );
		msgProtectedAttr.setMountID( GetMountID() );
	}

	if (m_AttrBackUp.m_nAIType != GetAIType() )
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nAIType = GetAIType();
		INT nRet = GetMonsterAIType();
		msgPublicAttr.setAIType(nRet);
		msgProtectedAttr.setAIType(nRet);
	}

	if(m_AttrBackUp.m_nStealthLevel != GetStealthLevel())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nStealthLevel = GetStealthLevel();

		msgPublicAttr.setStealthLevel( GetStealthLevel() );
		msgProtectedAttr.setStealthLevel( GetStealthLevel() );
	}

	if(m_AttrBackUp.m_nMoodState != GetMoodState())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nMoodState = GetMoodState();

		msgPublicAttr.setMoodState( GetMoodState() );
		msgProtectedAttr.setMoodState( GetMoodState() );
	}

	//if( m_AttrBackUp.m_iWeaponID != GetWeaponID() )
	//{
	//	bPublicAttrModified = TRUE;
	//	m_AttrBackUp.m_iWeaponID = GetWeaponID();
	//	//msgPublicAttr.setWeaponID( m_AttrBackUp.m_iWeaponID );
	//	msgProtectedAttr.setWeaponID( m_AttrBackUp.m_iWeaponID );
	//}

	if( m_AttrBackUp.m_iHorseID != GetHorseID() )
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_iHorseID = GetHorseID();
		msgPublicAttr.setMountID( m_AttrBackUp.m_iHorseID );
		msgProtectedAttr.setMountID( m_AttrBackUp.m_iHorseID );
	}

	if ( bPublicAttrModified )
	{
		if ( bPublicAttrModified )
		{
			m_PublicAttrVersion++;
		}

		if ( bPublicAttrModified || m_ProtectedAttrVersion )
		{
			m_ProtectedAttrVersion++;
		}

		HUMANLIST listHuman;
		getScene()->ScanHuman( getZoneID(), MAX_REFESH_OBJ_ZONE_RADIUS, &(listHuman) );

		BOOL bSendPublicMsg				= bPublicAttrModified;
		BOOL bSendProtectedMsg			= (BOOL)(bPublicAttrModified || m_ProtectedAttrVersion);
		BYTE i;
		for ( i = 0; i < listHuman.m_Count; i++ )
		{
			Obj_Human *pTargetHuman = listHuman.m_aHuman[i];
			if ( IsCanViewMe( pTargetHuman ) )
			{
				ENUM_REFESH_ATTR_TYPE eType = CalcRefeshAttrType( this, pTargetHuman );
				switch( eType )
				{
				case REFESH_ATTR_TYPE_NONE:
					break;
				case REFESH_ATTR_TYPE_PUBLIC:
				case REFESH_ATTR_TYPE_PUBLIC_AND_LEVEL:
					if ( bSendPublicMsg )
					{
						pTargetHuman->GetPlayer()->SendPacket( &msgPublicAttr );
					}
					break;
				case REFESH_ATTR_TYPE_PROTECTED:
					if ( bSendProtectedMsg )
					{
						pTargetHuman->GetPlayer()->SendPacket( &msgProtectedAttr );
					}
					break;
				default:
					break;
				}
			}
		}
	}

__LEAVE_FUNCTION
}
Beispiel #6
0
void VenomModuleStart(GameMemory* memory) {
  SystemInfo* sys = &memory->systemInfo;
  GameData* data = PushStruct(GameData, &memory->mainBlock);
  memory->userdata = data;
  RenderState* rs = &memory->renderState;
  
  BeginProfileEntry("Initalize Terrain Generator");
  InitalizeTerrainGenerator(&data->terrain, V3(0.0, 0.0, 0.0), &memory->mainBlock);
  EndProfileEntry();

  rs->terrain = &data->terrain;
  GetEngine()->physicsSimulation.terrain = &data->terrain;

#if 0
  {
    ModelData data = {};
    data = ImportExternalModelData(VENOM_ASSET_FILE("axis.obj"), 0);
    FILE* file = fopen("test.txt", "wb");
    assert(file != 0);
    for(size_t i = 0; i < data.meshData.vertexCount; i++) {
      fprintf(file, "V3{%ff, %ff, %ff},\n", data.meshData.vertices[i].position.x,
        data.meshData.vertices[i].position.y, data.meshData.vertices[i].position.z);
    }
    fprintf(file, "\n");
    for(size_t i = 0; i < data.meshData.indexCount; i++) {
      fprintf(file, "%u,", data.meshData.indices[i]);
      if(i % 3 == 0) fprintf(file, "\n");
    }
  }
#endif

 
  InitializeCamera(&data->camera, 45*DEG2RAD, 0.1f, 10000.0f, sys->screenWidth, sys->screenHeight);
  data->camera.position = {4, 10, 2};


  EntityContainerInit(&data->entityContainer, 1024, 8);

  {
    AssetManifest *assetManifest = &memory->assetManifest;
    EntityContainer *entityContainer = &data->entityContainer;
    EntityIndex player_index;
    Entity *player = CreateEntity(EntityType_Player, &player_index, entityContainer);
    assign_model_to_entity(player_index, GetModelID("player", assetManifest), assetManifest, entityContainer);
    ModelAsset *asset = GetModelAsset(player->modelID, assetManifest);
    player->animation_state.model_id = player->modelID;
    player->position = player->position += V3(1, 5.0f, 1);
    data->playerEntityIndex = player_index;

#if 0
    Orientation cameraOrientation = CalculateCameraOrientationForTrackTarget(player->position);
    data->camera.position = cameraOrientation.position;
    V3 eulerRotation = QuaternionToEuler(cameraOrientation.rotation);
    data->camera.pitch = eulerRotation.x;
    data->camera.yaw = eulerRotation.y;
#endif

    RNGSeed seed(15);
    ScatterInRectangle(&seed, -128, -128, 256, 256, 8, 8, [&](V2 point) {
      Entity *e = CreateEntity(EntityType_StaticObject, entityContainer);
      e->modelID = GetModelID("Tree", assetManifest);
      e->position.x = point.x;
      e->position.z = point.y;
    });

  }
}
Beispiel #7
0
void VenomModuleRender(GameMemory* memory) {
  RenderState* rs = &memory->renderState;
  GameData* data = (GameData*)memory->userdata;
  EditorData* editorData = &memory->editor;
  EditorData* editor = editorData;

  const V3 sunDirection = Normalize(V3(1.0, 0.5, 0.0f));
  AddDirectionalLight(sunDirection, V3(1.0, 1.0, 1.0), &rs->drawList);

  auto sunModelID = GetModelID("Sun", GetAssetManifest());
  auto sunModel = GetModelAsset(sunModelID);
  AddStaticModelToDrawList(&rs->drawList, sunModel, sunDirection * 10);

  
  
  const F32 deltaTime = memory->deltaTime;
  EntityContainer* entityContainer = &data->entityContainer;
  
  auto engine = GetEngine();



  EntityBlock* block = entityContainer->firstAvaibleBlock;
  for (U64 i = 0; i < entityContainer->capacityPerBlock; i++) {
    if (block->flags[i] & EntityFlag_PRESENT) {
      Entity* entity = &block->entities[i];

      if(block->types[i] == EntityType_PointLight) {
        AddShadowCastingPointLight(entity->position, entity->pointLight.color, 
          entity->pointLight.radius, &rs->drawList);
      }

      ModelAsset *model = GetModelAsset(entity->modelID, &memory->assetManifest);
      if (model == nullptr) continue;
      bool is_entity_animated = model->jointCount > 0;

      if (block->flags[i] & EntityFlag_VISIBLE) {        
        if (editor->selectedEntities.ContainsValue(i)) {
          V3 rotation = QuaternionToEuler(entity->rotation);
          AddOutlinedModelToDrawList(&rs->drawList, model, entity->position, rotation); 
        } else if (is_entity_animated) {
          V3 rotation = QuaternionToEuler(entity->rotation);
          V3 position = entity->position;
          position.y += model->size.y * 0.5f;
          AddAnimatedModelToDrawList(&rs->drawList, model, &entity->animation_state, position, rotation);
        } else {
          V3 rotation = QuaternionToEuler(entity->rotation);
          V3 position = entity->position;
          position.y += model->size.y * 0.5f;
          AddStaticModelToDrawList(&rs->drawList, model, position, rotation); 
        }
      }
    }
  }

  Camera *camera = nullptr;
  camera = &data->camera;
#if 0
  if (editor->isEditorVisible) {
    //camera = &editor->editorCamera;
    ..draw_debug_camera(&data->camera);
  } else {
Beispiel #8
0
CModel* CLevelEntity::GetModel() const
{
	return CModelLibrary::GetModel(GetModelID());
}