當前位置: 首頁>>代碼示例>>C++>>正文


C++ GET_MODEL_PTR函數代碼示例

本文整理匯總了C++中GET_MODEL_PTR函數的典型用法代碼示例。如果您正苦於以下問題:C++ GET_MODEL_PTR函數的具體用法?C++ GET_MODEL_PTR怎麽用?C++ GET_MODEL_PTR使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GET_MODEL_PTR函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: GetModelBoundingBox

// GetModelBoundingBox( index, Float:mins[3], Float:maxs[3], sequence = Model_DefaultSize );
static cell AMX_NATIVE_CALL GetModelBoundingBox(AMX *amx, cell *params)
{
	int entityIndex = params[1];

	CHECK_ENTITY(entityIndex);

	edict_t *pentModel = INDEXENT2(entityIndex);

	if (!FNullEnt(pentModel))
	{
		studiohdr_t *pStudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(pentModel));

		if (!pStudiohdr)
		{
			MF_LogError(amx, AMX_ERR_NATIVE, "Could not find the model pointer for the entity.");
			return 0;
		}

		cell *bbmins = MF_GetAmxAddr(amx, params[2]);
		cell *bbmaxs = MF_GetAmxAddr(amx, params[3]);

		int sequence = params[4];

		if (sequence <= Model_DefaultSize)
		{
			bbmins[0] = amx_ftoc(pStudiohdr->min.x);
			bbmins[1] = amx_ftoc(pStudiohdr->min.y);
			bbmins[2] = amx_ftoc(pStudiohdr->min.z);

			bbmaxs[0] = amx_ftoc(pStudiohdr->max.x);
			bbmaxs[1] = amx_ftoc(pStudiohdr->max.y);
			bbmaxs[2] = amx_ftoc(pStudiohdr->max.z);
		}
		else
		{
			if (sequence <= Model_CurrentSequence || sequence >= pStudiohdr->numseq)
				sequence = pentModel->v.sequence;

			mstudioseqdesc_t *pSeqdesc;
			pSeqdesc = (mstudioseqdesc_t*)((byte*)pStudiohdr + pStudiohdr->seqindex);

			bbmins[0] = amx_ftoc(pSeqdesc[sequence].bbmin.x);
			bbmins[1] = amx_ftoc(pSeqdesc[sequence].bbmin.y);
			bbmins[2] = amx_ftoc(pSeqdesc[sequence].bbmin.z);

			bbmaxs[0] = amx_ftoc(pSeqdesc[sequence].bbmax.x);
			bbmaxs[1] = amx_ftoc(pSeqdesc[sequence].bbmax.y);
			bbmaxs[2] = amx_ftoc(pSeqdesc[sequence].bbmax.z);
		}

		return 1;
	}

	return 0;
};
開發者ID:Chuvi-w,項目名稱:amxmodx,代碼行數:56,代碼來源:misc.cpp

示例2: GET_MODEL_PTR

//=========================================================
//=========================================================
void CBaseAnimating::ResetSequenceInfo()
{
	void *pmodel = GET_MODEL_PTR( ENT( pev ) );

	GetSequenceInfo( pmodel, pev, m_flFrameRate, m_flGroundSpeed );
	m_fSequenceLoops = ( ( GetSequenceFlags() & STUDIO_LOOPING ) != 0 );
	pev->animtime = gpGlobals->time;
	pev->framerate = 1.0;
	m_fSequenceFinished = false;
	m_flLastEventCheck = gpGlobals->time;
}
開發者ID:swmpdg,項目名稱:HLEnhanced,代碼行數:13,代碼來源:CBaseAnimating.cpp

示例3: GET_MODEL_PTR

void CWeaponCycler::SecondaryAttack(void)
{
	pev->sequence = (pev->sequence + 1) % 8;
	pev->modelindex = m_iModel;

	void *pmodel = GET_MODEL_PTR(ENT(pev));

	float flFrameRate, flGroundSpeed;
	GetSequenceInfo(pmodel, pev, &flFrameRate, &flGroundSpeed);
	pev->modelindex = 0;

	if (flFrameRate == 0)
		pev->sequence = 0;

	SendWeaponAnim(pev->sequence);
	m_flNextSecondaryAttack = gpGlobals->time + 0.3;
}
開發者ID:AlexCSilva,項目名稱:cs16-client,代碼行數:17,代碼來源:h_cycler.cpp

示例4: lookup_sequence

// lookup_sequence(entid, "sequence name", &Float:framerate = 0.0, &bool:loops = false, &Float:groundspeed = 0.0);
static cell AMX_NATIVE_CALL lookup_sequence(AMX* amx, cell* params)
{
	int index = params[1];

	CHECK_ENTITY(index);

	edict_t* ent = INDEXENT(index);

	studiohdr_t* pstudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(ent));

	if (pstudiohdr == NULL)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Could not retrieve the model pointer from the entity provided.");
		return 0;
	}

	mstudioseqdesc_t* pseqdesc;

	pseqdesc = reinterpret_cast<mstudioseqdesc_t*>(
					reinterpret_cast<char*>(pstudiohdr) + pstudiohdr->seqindex);

	char* label = MF_GetAmxString(amx, params[2], 0, NULL);

	for (int i = 0; i < pstudiohdr->numseq; i++)
	{
		if (UTIL_stricmp( pseqdesc[i].label, label ) == 0)
		{
			REAL* FrameRate = reinterpret_cast<REAL*>(MF_GetAmxAddr(amx, params[3]));
			cell* Loops = MF_GetAmxAddr(amx, params[4]);
			REAL* GroundSpeed = reinterpret_cast<REAL*>(MF_GetAmxAddr(amx, params[5]));

			// Taken from HLSDK: animation & animating.cpp
			pseqdesc = &pseqdesc[i];
			*FrameRate = 256 * pseqdesc->fps / (pseqdesc->numframes - 1);

			*GroundSpeed = sqrt( pseqdesc->linearmovement[0]*pseqdesc->linearmovement[0]+ pseqdesc->linearmovement[1]*pseqdesc->linearmovement[1]+ pseqdesc->linearmovement[2]*pseqdesc->linearmovement[2] );
			*GroundSpeed = *GroundSpeed * pseqdesc->fps / (pseqdesc->numframes - 1);

			*Loops = pseqdesc->flags & STUDIO_LOOPING;
			return i;
		}
	}

	return -1;

};
開發者ID:Chuvi-w,項目名稱:amxmodx,代碼行數:47,代碼來源:misc.cpp

示例5: FIND_ENTITY_BY_TARGETNAME

// Find an entity that I'm interested in and precache the sounds he'll need in the sequence.
void CCineMonster::Activate(void)
{
	edict_t *     pentTarget;
	CBaseMonster *pTarget;

	// The entity name could be a target name or a classname
	// Check the targetname
	pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEntity));
	pTarget    = NULL;

	while(!pTarget && !FNullEnt(pentTarget))
	{
		if(FBitSet(VARS(pentTarget)->flags, FL_MONSTER))
		{
			pTarget = GetMonsterPointer(pentTarget);
		}
		pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity));
	}

	// If no entity with that targetname, check the classname
	if(!pTarget)
	{
		pentTarget = FIND_ENTITY_BY_CLASSNAME(NULL, STRING(m_iszEntity));
		while(!pTarget && !FNullEnt(pentTarget))
		{
			pTarget    = GetMonsterPointer(pentTarget);
			pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity));
		}
	}
	// Found a compatible entity
	if(pTarget)
	{
		void *pmodel;
		pmodel = GET_MODEL_PTR(pTarget->edict());
		if(pmodel)
		{
			// Look through the event list for stuff to precache
			SequencePrecache(pmodel, STRING(m_iszIdle));
			SequencePrecache(pmodel, STRING(m_iszPlay));
		}
	}
}
開發者ID:Sh1ft0x0EF,項目名稱:HLSDKRevamp,代碼行數:43,代碼來源:Scripted.cpp

示例6: SetModelBoundingBox

// SetModelBoudingBox( index, sequence = Model_DefaultSize );
static cell AMX_NATIVE_CALL SetModelBoundingBox(AMX *amx, cell *params)
{
	int entityIndex = params[1];

	CHECK_ENTITY(entityIndex);

	edict_t *pentModel = INDEXENT2(entityIndex);

	if (!FNullEnt(pentModel))
	{
		studiohdr_t *pStudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(pentModel));

		if (!pStudiohdr)
		{
			MF_LogError(amx, AMX_ERR_NATIVE, "Could not find the model pointer for the entity.");
			return 0;
		}

		int sequence = params[2];

		if (sequence <= Model_DefaultSize)
		{
			SET_SIZE(pentModel, pStudiohdr->min, pStudiohdr->max);
		}
		else
		{
			if (sequence <= Model_CurrentSequence || sequence >= pStudiohdr->numseq)
				sequence = pentModel->v.sequence;

			mstudioseqdesc_t *pSeqdesc; 
			pSeqdesc = (mstudioseqdesc_t*)((byte*)pStudiohdr + pStudiohdr->seqindex);

			SET_SIZE(pentModel, pSeqdesc[sequence].bbmin, pSeqdesc[sequence].bbmax);

			return 1;
		}
	}

	return 0;
}
開發者ID:Chuvi-w,項目名稱:amxmodx,代碼行數:41,代碼來源:misc.cpp

示例7: StudioFrameAdvanceEnt

void StudioFrameAdvanceEnt(edict_t *pEdict)
{
	float flInterval = gpGlobals->time - pEdict->v.animtime;
	if (flInterval <= 0.001f) {
		pEdict->v.animtime = gpGlobals->time;
		return;
	}

	if (pEdict->v.animtime == 0.0f) {
		flInterval = 0.0f;
	}

	studiohdr_t *pstudiohdr = static_cast<studiohdr_t *>(GET_MODEL_PTR(pEdict));
	if (!pstudiohdr) {
		return;
	}

	if (pEdict->v.sequence >= pstudiohdr->numseq || pEdict->v.sequence < 0) {
		return;
	}

	float flFrameRate = 256.0f;
	mstudioseqdesc_t *pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + int(pEdict->v.sequence);
	if (pseqdesc->numframes > 1)
	{
		flFrameRate = pseqdesc->fps * 256.0f / (pseqdesc->numframes - 1);
	}

	pEdict->v.frame += flInterval * flFrameRate * pEdict->v.framerate;
	pEdict->v.animtime = gpGlobals->time;

	if (pEdict->v.frame < 0.0f || pEdict->v.frame >= 256.0f)
	{
		// true if the sequence loops
		if (pseqdesc->flags & STUDIO_LOOPING)
			pEdict->v.frame -= int(pEdict->v.frame / 256.0f) * 256.0f;
		else
			pEdict->v.frame = (pEdict->v.frame < 0.0f) ? 0.0f : 255.0f;
	}
}
開發者ID:s1lentq,項目名稱:reapi,代碼行數:40,代碼來源:reapi_utils.cpp

示例8: while

// Find an entity that I'm interested in and precache the sounds he'll need in the sequence.
void CCineMonster::Activate( void )
{
	CBaseMonster* pTarget = nullptr;

	CBaseEntity* pNextTarget = nullptr;

	// The entity name could be a target name or a classname
	// Check the targetname
	while( !pTarget && ( pNextTarget = UTIL_FindEntityByTargetname( pNextTarget, STRING( m_iszEntity ) ) ) != nullptr )
	{
		if( pNextTarget->GetFlags().Any( FL_MONSTER ) )
		{
			pTarget = pNextTarget->MyMonsterPointer();
		}
	}

	// If no entity with that targetname, check the classname
	if( !pTarget )
	{
		pNextTarget = nullptr;
		while( !pTarget && ( pNextTarget = UTIL_FindEntityByClassname( pNextTarget, STRING( m_iszEntity ) ) ) != nullptr )
		{
			pTarget = pNextTarget->MyMonsterPointer();
		}
	}

	// Found a compatible entity
	if( pTarget )
	{
		void *pmodel;
		pmodel = GET_MODEL_PTR( pTarget->edict() );
		if( pmodel )
		{
			// Look through the event list for stuff to precache
			SequencePrecache( pmodel, STRING( m_iszIdle ) );
			SequencePrecache( pmodel, STRING( m_iszPlay ) );
		}
	}
}
開發者ID:oskarlh,項目名稱:HLEnhanced,代碼行數:40,代碼來源:CCineMonster.cpp

示例9: lookup_sequence_by_id

// lookup_sequence_by_id(entid, sequence_id, &Float:framerate = 0.0, &bool:loops = false, &Float:groundspeed = 0.0);
static cell AMX_NATIVE_CALL lookup_sequence_by_id(AMX* amx, cell* params)
{
	int index = params[1];

	CHECK_ENTITY(index);

	edict_t* ent = INDEXENT(index);

	studiohdr_t* pstudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(ent));

	if (pstudiohdr == NULL)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Could not retrieve the model pointer from the entity (%d %p) provided.", index, ent);
		return 0;
	}

	mstudioseqdesc_t* pseqdesc;

	pseqdesc = reinterpret_cast<mstudioseqdesc_t*>(
		reinterpret_cast<char*>(pstudiohdr)+pstudiohdr->seqindex);

	int sequence_id = params[2];
	if (sequence_id < 0 || sequence_id >= pstudiohdr->numseq)
		return -1;

	REAL* FrameRate = reinterpret_cast<REAL*>(MF_GetAmxAddr(amx, params[3]));
	cell* Loops = MF_GetAmxAddr(amx, params[4]);
	REAL* GroundSpeed = reinterpret_cast<REAL*>(MF_GetAmxAddr(amx, params[5]));

	// Taken from HLSDK: animation & animating.cpp
	pseqdesc = &pseqdesc[sequence_id];
	*FrameRate = 256 * pseqdesc->fps / (pseqdesc->numframes - 1);

	*GroundSpeed = sqrt(pseqdesc->linearmovement[0] * pseqdesc->linearmovement[0] + pseqdesc->linearmovement[1] * pseqdesc->linearmovement[1] + pseqdesc->linearmovement[2] * pseqdesc->linearmovement[2]);
	*GroundSpeed = *GroundSpeed * pseqdesc->fps / (pseqdesc->numframes - 1);

	*Loops = pseqdesc->flags & STUDIO_LOOPING;
	return sequence_id;
};
開發者ID:dreamstalker,項目名稱:amxmodx,代碼行數:40,代碼來源:misc.cpp

示例10: ExtractBbox

/* <10b5f> ../cstrike/dlls/animating.cpp:250 */
int CBaseAnimating::ExtractBbox(int sequence, float *mins, float *maxs)
{
	return ::ExtractBbox(GET_MODEL_PTR(ENT(pev)), sequence, mins, maxs);
}
開發者ID:omertelli,項目名稱:ReGameDLL_CS,代碼行數:5,代碼來源:animating.cpp

示例11: GetBodygroup

/* <10af0> ../cstrike/dlls/animating.cpp:244 */
NOXREF int CBaseAnimating::GetBodygroup(int iGroup)
{
	return ::GetBodygroup(GET_MODEL_PTR(ENT(pev)), pev, iGroup);
}
開發者ID:omertelli,項目名稱:ReGameDLL_CS,代碼行數:5,代碼來源:animating.cpp

示例12: SetBodygroup

/* <10aad> ../cstrike/dlls/animating.cpp:239 */
NOXREF void CBaseAnimating::SetBodygroup(int iGroup, int iValue)
{
	::SetBodygroup(GET_MODEL_PTR(ENT(pev)), pev, iGroup, iValue);
}
開發者ID:omertelli,項目名稱:ReGameDLL_CS,代碼行數:5,代碼來源:animating.cpp

示例13: GET_MODEL_PTR

/* <108d3> ../cstrike/dlls/animating.cpp:192 */
NOXREF float CBaseAnimating::SetBlending(int iBlender, float flValue)
{
	void *pmodel = GET_MODEL_PTR(ENT(pev));
	return ::SetBlending(pmodel, pev, iBlender, flValue);
}
開發者ID:omertelli,項目名稱:ReGameDLL_CS,代碼行數:6,代碼來源:animating.cpp

示例14: SpawnRandomGibs

//LRC - changed signature, to support custom gib models
void CGib :: SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int notfirst, const char *szGibModel )
{
	if (cGibs == 0) return; // spawn nothing!

	CGib *pGib = GetClassPtr( (CGib *)NULL );
	pGib->Spawn( szGibModel );

	//LRC - check the model itself to find out how many gibs are available
	studiohdr_t *pstudiohdr = (studiohdr_t *)(GET_MODEL_PTR( ENT(pGib->pev) ));
	if (! pstudiohdr)
		return;

	mstudiobodyparts_t *pbodypart = (mstudiobodyparts_t *)((byte *)pstudiohdr + pstudiohdr->bodypartindex);
	//ALERT(at_console, "read %d bodyparts, canonical is %d\n", pbodypart->nummodels, HUMAN_GIB_COUNT);

	for (int cSplat = 0 ; cSplat < cGibs ; cSplat++ )
	{
		if (pGib == NULL) // first time through, we set pGib before the loop started
		{
			pGib = GetClassPtr( (CGib *)NULL );
			pGib->Spawn( szGibModel );
		}

		if (notfirst)
			pGib->pev->body = RANDOM_LONG(1, pbodypart->nummodels - 1);// start at one to avoid throwing random amounts of skulls (0th gib)
		else
			pGib->pev->body = RANDOM_LONG(0, pbodypart->nummodels - 1);

		if ( pevVictim )
		{
			// spawn the gib somewhere in the monster's bounding volume
			pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * (RANDOM_FLOAT ( 0 , 1 ) );
			pGib->pev->origin.y = pevVictim->absmin.y + pevVictim->size.y * (RANDOM_FLOAT ( 0 , 1 ) );
			pGib->pev->origin.z = pevVictim->absmin.z + pevVictim->size.z * (RANDOM_FLOAT ( 0 , 1 ) ) + 1;	// absmin.z is in the floor because the engine subtracts 1 to enlarge the box

			// make the gib fly away from the attack vector
			pGib->pev->velocity = g_vecAttackDir * -1;

			// mix in some noise
			pGib->pev->velocity.x += RANDOM_FLOAT ( -0.25, 0.25 );
			pGib->pev->velocity.y += RANDOM_FLOAT ( -0.25, 0.25 );
			pGib->pev->velocity.z += RANDOM_FLOAT ( -0.25, 0.25 );

			pGib->pev->velocity = pGib->pev->velocity * RANDOM_FLOAT ( 300, 400 );

			pGib->pev->avelocity.x = RANDOM_FLOAT ( 100, 200 );
			pGib->pev->avelocity.y = RANDOM_FLOAT ( 100, 300 );

			// copy owner's blood color
			pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor();
			
			if ( pevVictim->health > -50)
			{
				pGib->pev->velocity = pGib->pev->velocity * 0.7;
			}
			else if ( pevVictim->health > -200)
			{
				pGib->pev->velocity = pGib->pev->velocity * 2;
			}
			else
			{
				pGib->pev->velocity = pGib->pev->velocity * 4;
			}

			pGib->pev->solid = SOLID_BBOX;
			UTIL_SetSize ( pGib->pev, Vector( 0 , 0 , 0 ), Vector ( 0, 0, 0 ) );
		}
		pGib->LimitVelocity();
		pGib = NULL; //LRC
	}
}
開發者ID:RichardRohac,項目名稱:hl-amnesia-src,代碼行數:72,代碼來源:combat.cpp

示例15: GetSequenceDuration

float AvHBaseBuildable::GetTimeForAnimation(int inIndex) const
{
	return GetSequenceDuration(GET_MODEL_PTR(ENT(pev)), this->pev);
}
開發者ID:Arkshine,項目名稱:NS,代碼行數:4,代碼來源:AvHBaseBuildable.cpp


注:本文中的GET_MODEL_PTR函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。