Esempio n. 1
0
void CEntityEclassModel::OnKeyValueChanged(entity_t *e, const char *key, const char* value)
{
  if(strcmp(key,"origin") == 0)
  {
    sscanf(value, "%f %f %f", &m_translate[0], &m_translate[1], &m_translate[2]); 
    UpdateCachedData();
  } 
  else if(strcmp(key,"angle") == 0)
  {
    VectorSet(m_euler, 0, 0, (float) atof(value));
    UpdateCachedData();
  }
}
void CEntityMiscModel::OnKeyValueChanged( entity_t *e, const char *key, const char* value ){
	if ( strcmp( key, "model" ) == 0 ) {
		SetName( value );
	}
	else if ( strcmp( key, "_frame" ) == 0 ) {
		SetName( ValueForKey( e, "model" ) );
	}
	else if ( strcmp( key, "angle" ) == 0 ) {
		VectorSet( m_euler, 0.f, 0.f, 0.f );
		m_euler[2] = atof( value );
		UpdateCachedData();
	}
	else if ( strcmp( key, "angles" ) == 0 ) {
		VectorSet( m_euler, 0.f, 0.f, 0.f );
		if ( value[0] != '\0' ) {
			sscanf( value, "%f %f %f", &m_euler[1], &m_euler[2], &m_euler[0] );
		}
		UpdateCachedData();
	}
	else if ( strcmp( key, "modelscale" ) == 0 || strcmp( key,"modelscale_vec" ) == 0 ) {
		const char *s;
		VectorSet( m_scale, 1.f, 1.f, 1.f );
		s = ValueForKey( e,"modelscale" );
		if ( s[0] != '\0' ) {
			float f = atof( s );
			if ( f != 0 ) {
				VectorSet( m_scale, f, f, f );
			}
			else{
				Sys_FPrintf( SYS_WRN, "WARNING: ignoring 0 modelscale key\n" );
			}
		}
		s = ValueForKey( e,"modelscale_vec" );
		if ( s[0] != '\0' ) {
			sscanf( s, "%f %f %f", &m_scale[0], &m_scale[1], &m_scale[2] );
			if ( m_scale[0] == 0.0 && m_scale[1] == 0.0 && m_scale[2] == 0.0 ) {
				VectorSet( m_scale, 1,1,1 );
				Sys_FPrintf( SYS_WRN, "WARNING: ignoring 0 0 0 modelscale_vec key\n" );
			}
		}
		UpdateCachedData();
	}
	else if ( strcmp( key, "origin" ) == 0 ) {
		sscanf( value, "%f %f %f", &m_translate[0], &m_translate[1], &m_translate[2] );
		UpdateCachedData();
	}
	else if ( strncmp( key,"_remap",6 ) == 0 ) {
		SetName( ValueForKey( e, "model" ) );
	}
}
void CEntityMiscModel::SetName( const char *name ){
	Str m_oldcachereq = m_cachereq;

	if ( name[0] == '\0' ) {
		return;
	}

	BuildCacheRequestString( name );

	if ( strcmp( m_oldcachereq, m_cachereq ) == 0 ) {
		return;
	}

	if ( m_oldcachereq.GetBuffer()[0] != ':'
		 && m_version.c_str()[0] != '\0' ) {
		GetModelCache()->DeleteByID( m_oldcachereq.GetBuffer(), m_version.c_str() );
	} else {
		assert(m_model == NULL);
	}

	m_model = NULL;

	if ( name[0] != '\0' ) {
		const char* dot = strrchr( name, '.' );
		if ( dot != NULL ) {
			m_version = ++dot;
			m_model = GetModelCache()->GetByID( m_cachereq.GetBuffer(), m_version.c_str() );
		}
	}

	UpdateCachedData();
}
void CEntityMiscModel::Rotate( const vec3_t pivot, const vec3_t rotation ){
	m4x4_t rotation_matrix;

	m4x4_identity( rotation_matrix );
	m4x4_pivoted_rotate_by_vec3( rotation_matrix, rotation, eXYZ, pivot );
	m4x4_transform_point( rotation_matrix, m_translate );

	VectorIncrement( rotation, m_euler );

	UpdateCachedData();
}
Esempio n. 5
0
void CEntityEclassModel::SetName(const char *name)
{
  if(strcmp(m_name.c_str(), name) == 0)
    return;

  if(m_name.c_str()[0] != '\0'
    && m_version.c_str()[0] != '\0')
    GetModelCache()->DeleteByID(m_name.c_str(), m_version.c_str());

  m_model = NULL;
  m_name = name;

  if(m_name.c_str()[0] != '\0')
  {
    const char* dot = strrchr(m_name.c_str(), '.');
    if(dot != NULL)
    {
      m_version = ++dot;
      m_model = GetModelCache()->GetByID(m_name.c_str(), m_version.c_str());
    }
  }

  UpdateCachedData();
}
Esempio n. 6
0
void CEntityEclassModel::Translate(const vec3_t translation)
{
  VectorIncrement(translation, m_translate);
  UpdateCachedData();
}