more eol-style
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/ZeroRadiant.ab@186 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
@@ -1,220 +1,220 @@
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "cpicomodel.h"
|
||||
#include "cpicosurface.h"
|
||||
|
||||
CPicoModel::CPicoModel(const PicoModelKey& key)
|
||||
: m_refcount(1)
|
||||
{
|
||||
load(key.first.GetBuffer(), key.second);
|
||||
}
|
||||
|
||||
CPicoModel::CPicoModel(const Str& name)
|
||||
: m_refcount(1)
|
||||
{
|
||||
load(name.GetBuffer(), 0);
|
||||
}
|
||||
|
||||
CPicoModel::CPicoModel(const Str& name, const int frame)
|
||||
: m_refcount(1)
|
||||
{
|
||||
load(name.GetBuffer(), frame);
|
||||
}
|
||||
|
||||
CPicoModel::CPicoModel(const char *name, const int frame)
|
||||
: m_refcount(1)
|
||||
{
|
||||
load(name, frame);
|
||||
}
|
||||
|
||||
void CPicoModel::load(const char *name, const int frame)
|
||||
{
|
||||
CPicoSurface *surf;
|
||||
picoSurface_t *pSurface;
|
||||
int i;
|
||||
|
||||
m_name= new char[strlen(name)+1];
|
||||
strcpy(m_name,name);
|
||||
|
||||
m_frame = frame;
|
||||
|
||||
if( !(m_pModel = PicoLoadModel(m_name, frame)) )
|
||||
{
|
||||
int len = strlen(m_name);
|
||||
|
||||
// Try loading an mdc if md3 fails and vice-versa (fixme: only do this for games with mdc support)
|
||||
if( !strcmp( m_name + len - 4, ".md3" ) )
|
||||
{
|
||||
m_name[len - 1] = 'c';
|
||||
m_pModel = PicoLoadModel(m_name, frame);
|
||||
} else if( !strcmp( m_name + len - 4, ".mdc" ) )
|
||||
{
|
||||
m_name[len - 1] = '3';
|
||||
m_pModel = PicoLoadModel(m_name, frame);
|
||||
}
|
||||
}
|
||||
|
||||
if( m_pModel )
|
||||
{
|
||||
m_children = g_ptr_array_new();
|
||||
aabb_clear(&m_BBox);
|
||||
for (i = 0; i < PicoGetModelNumSurfaces(m_pModel); i++ )
|
||||
{
|
||||
pSurface = PicoGetModelSurface(m_pModel,i);
|
||||
surf = new CPicoSurface(pSurface);
|
||||
g_ptr_array_add(m_children, surf);
|
||||
aabb_extend_by_aabb(&m_BBox, surf->GetAABB());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BBox.origin[0] = m_BBox.origin[1] = m_BBox.origin[2] = 0;
|
||||
m_BBox.extents[0] = m_BBox.extents[1] = m_BBox.extents[2] = 0;
|
||||
}
|
||||
|
||||
m_parents = g_ptr_array_new();
|
||||
}
|
||||
|
||||
CPicoModel::~CPicoModel()
|
||||
{
|
||||
if( m_pModel ) {
|
||||
for(unsigned int i=0; i<m_children->len; i++)
|
||||
((CPicoSurface*)m_children->pdata[i])->DecRef();
|
||||
g_ptr_array_free(m_children, FALSE);
|
||||
}
|
||||
g_ptr_array_free(m_parents, FALSE);
|
||||
delete [] m_name;
|
||||
}
|
||||
|
||||
void CPicoModel::AddParent( CPicoParent *parent )
|
||||
{
|
||||
g_ptr_array_add(m_parents, parent);
|
||||
}
|
||||
|
||||
void CPicoModel::RemoveParent( CPicoParent *parent )
|
||||
{
|
||||
unsigned int i;
|
||||
for(i=0; i<m_parents->len; i++) {
|
||||
if( parent == (CPicoParent*)m_parents->pdata[i] )
|
||||
g_ptr_array_remove_index_fast(m_parents, i);
|
||||
}
|
||||
}
|
||||
|
||||
void CPicoModel::Reload( void )
|
||||
{
|
||||
CPicoSurface *surf;
|
||||
picoSurface_t *pSurface;
|
||||
int i;
|
||||
unsigned int j;
|
||||
|
||||
// Get rid of the old model
|
||||
if( m_pModel ) {
|
||||
for(j=0; j<m_children->len; j++) {
|
||||
((CPicoSurface*)m_children->pdata[j])->DecRef();
|
||||
g_ptr_array_remove_index_fast(m_children, j);
|
||||
}
|
||||
}
|
||||
|
||||
// And reload it
|
||||
m_pModel = PicoLoadModel(m_name, m_frame);
|
||||
|
||||
if( m_pModel )
|
||||
{
|
||||
m_children = g_ptr_array_new();
|
||||
aabb_clear(&m_BBox);
|
||||
for (i = 0; i < PicoGetModelNumSurfaces(m_pModel); i++ )
|
||||
{
|
||||
pSurface = PicoGetModelSurface(m_pModel,i);
|
||||
surf = new CPicoSurface(pSurface);
|
||||
g_ptr_array_add(m_children, surf);
|
||||
aabb_extend_by_aabb(&m_BBox, surf->GetAABB());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BBox.origin[0] = m_BBox.origin[1] = m_BBox.origin[2] = 0;
|
||||
m_BBox.extents[0] = m_BBox.extents[1] = m_BBox.extents[2] = 0;
|
||||
}
|
||||
|
||||
for(j=0; j<m_parents->len; j++) {
|
||||
((CPicoParent*)m_parents->pdata[j])->UpdateShaders();
|
||||
}
|
||||
}
|
||||
|
||||
void CPicoModel::Draw(int state, vector<IShader*> shaders, int rflags) const
|
||||
{
|
||||
if( m_pModel ) {
|
||||
for(unsigned int i=0; i<m_children->len; i++)
|
||||
((CPicoSurface*)m_children->pdata[i])->Draw(state, shaders[i], rflags);
|
||||
}
|
||||
}
|
||||
|
||||
void CPicoModel::Draw(int state, int rflags) const
|
||||
{
|
||||
if( m_pModel ) {
|
||||
for(unsigned int i=0; i<m_children->len; i++)
|
||||
((CPicoSurface*)m_children->pdata[i])->Draw(state, rflags);
|
||||
}
|
||||
}
|
||||
|
||||
bool CPicoModel::TestRay(const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
vec_t dist_start = *dist;
|
||||
vec_t dist_local = *dist;
|
||||
ray_t ray_local = *ray;
|
||||
|
||||
if( !m_pModel ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aabb_intersect_ray(&m_BBox, &ray_local, &dist_local))
|
||||
return false;
|
||||
dist_local = dist_start;
|
||||
|
||||
for(unsigned int i=0; i<m_children->len; i++)
|
||||
{
|
||||
if(((CPicoSurface*)m_children->pdata[i])->TestRay(&ray_local, &dist_local))
|
||||
{
|
||||
*dist = dist_local;
|
||||
}
|
||||
}
|
||||
|
||||
return *dist < dist_start;
|
||||
}
|
||||
|
||||
int CPicoModel::GetNumSurfaces( void )
|
||||
{
|
||||
if( !m_pModel ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_children->len;
|
||||
}
|
||||
|
||||
char *CPicoModel::GetShaderNameForSurface( const unsigned int surf )
|
||||
{
|
||||
if( !m_pModel || surf < 0 || surf >= m_children->len ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((CPicoSurface*)m_children->pdata[surf])->GetShaderName();
|
||||
}
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "cpicomodel.h"
|
||||
#include "cpicosurface.h"
|
||||
|
||||
CPicoModel::CPicoModel(const PicoModelKey& key)
|
||||
: m_refcount(1)
|
||||
{
|
||||
load(key.first.GetBuffer(), key.second);
|
||||
}
|
||||
|
||||
CPicoModel::CPicoModel(const Str& name)
|
||||
: m_refcount(1)
|
||||
{
|
||||
load(name.GetBuffer(), 0);
|
||||
}
|
||||
|
||||
CPicoModel::CPicoModel(const Str& name, const int frame)
|
||||
: m_refcount(1)
|
||||
{
|
||||
load(name.GetBuffer(), frame);
|
||||
}
|
||||
|
||||
CPicoModel::CPicoModel(const char *name, const int frame)
|
||||
: m_refcount(1)
|
||||
{
|
||||
load(name, frame);
|
||||
}
|
||||
|
||||
void CPicoModel::load(const char *name, const int frame)
|
||||
{
|
||||
CPicoSurface *surf;
|
||||
picoSurface_t *pSurface;
|
||||
int i;
|
||||
|
||||
m_name= new char[strlen(name)+1];
|
||||
strcpy(m_name,name);
|
||||
|
||||
m_frame = frame;
|
||||
|
||||
if( !(m_pModel = PicoLoadModel(m_name, frame)) )
|
||||
{
|
||||
int len = strlen(m_name);
|
||||
|
||||
// Try loading an mdc if md3 fails and vice-versa (fixme: only do this for games with mdc support)
|
||||
if( !strcmp( m_name + len - 4, ".md3" ) )
|
||||
{
|
||||
m_name[len - 1] = 'c';
|
||||
m_pModel = PicoLoadModel(m_name, frame);
|
||||
} else if( !strcmp( m_name + len - 4, ".mdc" ) )
|
||||
{
|
||||
m_name[len - 1] = '3';
|
||||
m_pModel = PicoLoadModel(m_name, frame);
|
||||
}
|
||||
}
|
||||
|
||||
if( m_pModel )
|
||||
{
|
||||
m_children = g_ptr_array_new();
|
||||
aabb_clear(&m_BBox);
|
||||
for (i = 0; i < PicoGetModelNumSurfaces(m_pModel); i++ )
|
||||
{
|
||||
pSurface = PicoGetModelSurface(m_pModel,i);
|
||||
surf = new CPicoSurface(pSurface);
|
||||
g_ptr_array_add(m_children, surf);
|
||||
aabb_extend_by_aabb(&m_BBox, surf->GetAABB());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BBox.origin[0] = m_BBox.origin[1] = m_BBox.origin[2] = 0;
|
||||
m_BBox.extents[0] = m_BBox.extents[1] = m_BBox.extents[2] = 0;
|
||||
}
|
||||
|
||||
m_parents = g_ptr_array_new();
|
||||
}
|
||||
|
||||
CPicoModel::~CPicoModel()
|
||||
{
|
||||
if( m_pModel ) {
|
||||
for(unsigned int i=0; i<m_children->len; i++)
|
||||
((CPicoSurface*)m_children->pdata[i])->DecRef();
|
||||
g_ptr_array_free(m_children, FALSE);
|
||||
}
|
||||
g_ptr_array_free(m_parents, FALSE);
|
||||
delete [] m_name;
|
||||
}
|
||||
|
||||
void CPicoModel::AddParent( CPicoParent *parent )
|
||||
{
|
||||
g_ptr_array_add(m_parents, parent);
|
||||
}
|
||||
|
||||
void CPicoModel::RemoveParent( CPicoParent *parent )
|
||||
{
|
||||
unsigned int i;
|
||||
for(i=0; i<m_parents->len; i++) {
|
||||
if( parent == (CPicoParent*)m_parents->pdata[i] )
|
||||
g_ptr_array_remove_index_fast(m_parents, i);
|
||||
}
|
||||
}
|
||||
|
||||
void CPicoModel::Reload( void )
|
||||
{
|
||||
CPicoSurface *surf;
|
||||
picoSurface_t *pSurface;
|
||||
int i;
|
||||
unsigned int j;
|
||||
|
||||
// Get rid of the old model
|
||||
if( m_pModel ) {
|
||||
for(j=0; j<m_children->len; j++) {
|
||||
((CPicoSurface*)m_children->pdata[j])->DecRef();
|
||||
g_ptr_array_remove_index_fast(m_children, j);
|
||||
}
|
||||
}
|
||||
|
||||
// And reload it
|
||||
m_pModel = PicoLoadModel(m_name, m_frame);
|
||||
|
||||
if( m_pModel )
|
||||
{
|
||||
m_children = g_ptr_array_new();
|
||||
aabb_clear(&m_BBox);
|
||||
for (i = 0; i < PicoGetModelNumSurfaces(m_pModel); i++ )
|
||||
{
|
||||
pSurface = PicoGetModelSurface(m_pModel,i);
|
||||
surf = new CPicoSurface(pSurface);
|
||||
g_ptr_array_add(m_children, surf);
|
||||
aabb_extend_by_aabb(&m_BBox, surf->GetAABB());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BBox.origin[0] = m_BBox.origin[1] = m_BBox.origin[2] = 0;
|
||||
m_BBox.extents[0] = m_BBox.extents[1] = m_BBox.extents[2] = 0;
|
||||
}
|
||||
|
||||
for(j=0; j<m_parents->len; j++) {
|
||||
((CPicoParent*)m_parents->pdata[j])->UpdateShaders();
|
||||
}
|
||||
}
|
||||
|
||||
void CPicoModel::Draw(int state, vector<IShader*> shaders, int rflags) const
|
||||
{
|
||||
if( m_pModel ) {
|
||||
for(unsigned int i=0; i<m_children->len; i++)
|
||||
((CPicoSurface*)m_children->pdata[i])->Draw(state, shaders[i], rflags);
|
||||
}
|
||||
}
|
||||
|
||||
void CPicoModel::Draw(int state, int rflags) const
|
||||
{
|
||||
if( m_pModel ) {
|
||||
for(unsigned int i=0; i<m_children->len; i++)
|
||||
((CPicoSurface*)m_children->pdata[i])->Draw(state, rflags);
|
||||
}
|
||||
}
|
||||
|
||||
bool CPicoModel::TestRay(const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
vec_t dist_start = *dist;
|
||||
vec_t dist_local = *dist;
|
||||
ray_t ray_local = *ray;
|
||||
|
||||
if( !m_pModel ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aabb_intersect_ray(&m_BBox, &ray_local, &dist_local))
|
||||
return false;
|
||||
dist_local = dist_start;
|
||||
|
||||
for(unsigned int i=0; i<m_children->len; i++)
|
||||
{
|
||||
if(((CPicoSurface*)m_children->pdata[i])->TestRay(&ray_local, &dist_local))
|
||||
{
|
||||
*dist = dist_local;
|
||||
}
|
||||
}
|
||||
|
||||
return *dist < dist_start;
|
||||
}
|
||||
|
||||
int CPicoModel::GetNumSurfaces( void )
|
||||
{
|
||||
if( !m_pModel ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_children->len;
|
||||
}
|
||||
|
||||
char *CPicoModel::GetShaderNameForSurface( const unsigned int surf )
|
||||
{
|
||||
if( !m_pModel || surf < 0 || surf >= m_children->len ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((CPicoSurface*)m_children->pdata[surf])->GetShaderName();
|
||||
}
|
||||
|
||||
@@ -1,203 +1,203 @@
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "cpicosurface.h"
|
||||
|
||||
// public
|
||||
|
||||
CPicoSurface::CPicoSurface(picoSurface_t *pSurface)
|
||||
{
|
||||
refCount = 1;
|
||||
|
||||
m_pSurface = pSurface;
|
||||
|
||||
// PicoFixSurfaceNormals( pSurface );
|
||||
|
||||
AccumulateBBox();
|
||||
|
||||
m_shader = QERApp_Shader_ForName(GetShaderName());
|
||||
}
|
||||
|
||||
CPicoSurface::~CPicoSurface()
|
||||
{
|
||||
m_shader->DecRef();
|
||||
}
|
||||
|
||||
void CPicoSurface::Draw(int state, int rflags)
|
||||
{
|
||||
Draw(state, m_shader, rflags);
|
||||
}
|
||||
|
||||
void CPicoSurface::Draw(int state, IShader *pShader, int rflags)
|
||||
{
|
||||
int j;
|
||||
|
||||
if( !(rflags & (DRAW_RF_SEL_OUTLINE|DRAW_RF_SEL_FILL|DRAW_RF_XY)) )
|
||||
{
|
||||
if(state & DRAW_GL_TEXTURE_2D)
|
||||
{
|
||||
g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, pShader->getTexture()->texture_number);
|
||||
if( (rflags & DRAW_RF_CAM) && (pShader->getFlags() & QER_ALPHAFUNC) ) {
|
||||
int nFunc = 0;
|
||||
float fRef = 0.f;
|
||||
|
||||
g_QglTable.m_pfn_qglColor4f( 1.f, 1.f, 1.f, 1.f ); // identity
|
||||
|
||||
g_QglTable.m_pfn_qglEnable( GL_ALPHA_TEST );
|
||||
|
||||
pShader->getAlphaFunc( &nFunc, &fRef );
|
||||
g_QglTable.m_pfn_qglAlphaFunc( nFunc, fRef );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//g_QglTable.m_pfn_qglColor3fv( pShader->getTexture()->color );
|
||||
/* g_QglTable.m_pfn_qglEnableClientState(GL_COLOR_ARRAY);*/
|
||||
}
|
||||
|
||||
if( !(state & DRAW_GL_WIRE) && (pShader->getFlags() & QER_CULL) )
|
||||
{
|
||||
if( pShader->getCull() == 2 )
|
||||
{
|
||||
g_QglTable.m_pfn_qglDisable( GL_CULL_FACE );
|
||||
g_QglTable.m_pfn_qglPolygonMode (GL_FRONT, GL_FILL);
|
||||
}
|
||||
else // is 1
|
||||
{
|
||||
g_QglTable.m_pfn_qglCullFace( GL_BACK );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch( PicoGetSurfaceType(m_pSurface) )
|
||||
{
|
||||
case PICO_TRIANGLES: g_QglTable.m_pfn_qglBegin(GL_TRIANGLES);
|
||||
for (j=0; j<PicoGetSurfaceNumIndexes(m_pSurface); j++)
|
||||
{
|
||||
g_QglTable.m_pfn_qglNormal3fv(PicoGetSurfaceNormal(m_pSurface,PicoGetSurfaceIndex(m_pSurface,j)));
|
||||
|
||||
if( !(rflags & (DRAW_RF_SEL_OUTLINE|DRAW_RF_SEL_FILL|DRAW_RF_XY)) ) {
|
||||
if(state & DRAW_GL_TEXTURE_2D) {
|
||||
g_QglTable.m_pfn_qglTexCoord2fv(PicoGetSurfaceST(m_pSurface,0,PicoGetSurfaceIndex(m_pSurface,j)));
|
||||
} else {
|
||||
picoByte_t *vertexColor = PicoGetSurfaceColor(m_pSurface,0,PicoGetSurfaceIndex(m_pSurface,j));
|
||||
//% g_QglTable.m_pfn_qglColor4f( vertexColor[ 0 ] / 255.f,
|
||||
//% vertexColor[ 1 ] / 255.f,
|
||||
//% vertexColor[ 2 ] / 255.f,
|
||||
//% vertexColor[ 3 ] / 255.f );
|
||||
g_QglTable.m_pfn_qglColor4ubv( vertexColor );
|
||||
}
|
||||
}
|
||||
g_QglTable.m_pfn_qglVertex3fv( PicoGetSurfaceXYZ( m_pSurface, PicoGetSurfaceIndex( m_pSurface, j ) ) );
|
||||
}
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
/*g_QglTable.m_pfn_qglVertexPointer( 3, GL_FLOAT, 0, PicoGetSurfaceXYZ( m_pSurface, 0 ) );
|
||||
g_QglTable.m_pfn_qglNormalPointer( GL_FLOAT, 0, PicoGetSurfaceNormal( m_pSurface, 0 ) );
|
||||
if( !(rflags & (DRAW_RF_SEL_OUTLINE|DRAW_RF_SEL_FILL|DRAW_RF_XY)) ) {
|
||||
if( state & DRAW_GL_TEXTURE_2D ) {
|
||||
g_QglTable.m_pfn_qglTexCoordPointer( 2, GL_FLOAT, 0, PicoGetSurfaceST( m_pSurface, 0, 0 ) );
|
||||
} else {
|
||||
g_QglTable.m_pfn_qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, PicoGetSurfaceColor( m_pSurface, 0, 0 ) );
|
||||
}
|
||||
}
|
||||
g_QglTable.m_pfn_qglDrawElements( GL_TRIANGLES, PicoGetSurfaceNumIndexes( m_pSurface ), GL_UNSIGNED_INT, PicoGetSurfaceIndexes( m_pSurface, 0 ) );*/
|
||||
|
||||
/*g_QglTable.m_pfn_qglColor3f( 0.f, .5f, 1.f );
|
||||
g_QglTable.m_pfn_qglBegin( GL_LINES );
|
||||
for( int i = 0; i < PicoGetSurfaceNumIndexes( m_pSurface ); i++ ) {
|
||||
vec3_t outerpoint;
|
||||
VectorMA( PicoGetSurfaceXYZ( m_pSurface, PicoGetSurfaceIndex( m_pSurface, i ) ), .3f, PicoGetSurfaceNormal( m_pSurface, PicoGetSurfaceIndex( m_pSurface, i ) ), outerpoint );
|
||||
g_QglTable.m_pfn_qglVertex3fv( PicoGetSurfaceXYZ( m_pSurface, PicoGetSurfaceIndex( m_pSurface, i ) ) );
|
||||
g_QglTable.m_pfn_qglVertex3fv( outerpoint );
|
||||
}
|
||||
g_QglTable.m_pfn_qglEnd();*/
|
||||
|
||||
break;
|
||||
default: Sys_Printf( "ERROR: Unsupported Pico Surface Type: %i", PicoGetSurfaceType(m_pSurface) );
|
||||
break;
|
||||
}
|
||||
|
||||
if( !(rflags & (DRAW_RF_SEL_OUTLINE|DRAW_RF_SEL_FILL|DRAW_RF_XY)) )
|
||||
{
|
||||
if( (state & DRAW_GL_TEXTURE_2D) && (rflags & DRAW_RF_CAM) && (pShader->getFlags() & QER_ALPHAFUNC) ) {
|
||||
g_QglTable.m_pfn_qglDisable( GL_ALPHA_TEST );
|
||||
}
|
||||
|
||||
/* if(!(state & DRAW_GL_TEXTURE_2D)) {
|
||||
g_QglTable.m_pfn_qglDisableClientState(GL_COLOR_ARRAY);
|
||||
}*/
|
||||
|
||||
if( !(state & DRAW_GL_WIRE) && (pShader->getFlags() & QER_CULL) )
|
||||
{
|
||||
if( pShader->getCull() == 2 )
|
||||
{
|
||||
g_QglTable.m_pfn_qglPolygonMode (GL_FRONT, GL_LINE);
|
||||
g_QglTable.m_pfn_qglEnable( GL_CULL_FACE );
|
||||
}
|
||||
else // is 1
|
||||
{
|
||||
g_QglTable.m_pfn_qglCullFace( GL_FRONT );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
void CPicoSurface::AccumulateBBox()
|
||||
{
|
||||
int i;
|
||||
picoVec_t *p;
|
||||
aabb_clear(&m_BBox);
|
||||
for (i=0; i<PicoGetSurfaceNumVertexes(m_pSurface); i++)
|
||||
{
|
||||
p=PicoGetSurfaceXYZ(m_pSurface,i);
|
||||
aabb_extend_by_point(&m_BBox, p);
|
||||
}
|
||||
aabb_update_radius(&m_BBox);
|
||||
}
|
||||
|
||||
bool CPicoSurface::TestRay (const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
int i;
|
||||
vec_t start_dist = *dist;
|
||||
vec_t local_dist = *dist;
|
||||
if (aabb_intersect_ray(&m_BBox, ray, &local_dist))
|
||||
{
|
||||
switch( PicoGetSurfaceType(m_pSurface) )
|
||||
{
|
||||
case PICO_TRIANGLES:
|
||||
for (i=0; i<PicoGetSurfaceNumIndexes(m_pSurface); i+=3)
|
||||
{
|
||||
local_dist = ray_intersect_triangle(ray, true, PicoGetSurfaceXYZ(m_pSurface,PicoGetSurfaceIndex(m_pSurface,i+2)),
|
||||
PicoGetSurfaceXYZ(m_pSurface,PicoGetSurfaceIndex(m_pSurface,i+1)),
|
||||
PicoGetSurfaceXYZ(m_pSurface,PicoGetSurfaceIndex(m_pSurface,i)));
|
||||
if (local_dist < *dist)
|
||||
*dist = local_dist;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Printf( "ERROR: Unsupported Pico Surface Type: %i", PicoGetSurfaceType(m_pSurface) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (*dist < start_dist);
|
||||
}
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "cpicosurface.h"
|
||||
|
||||
// public
|
||||
|
||||
CPicoSurface::CPicoSurface(picoSurface_t *pSurface)
|
||||
{
|
||||
refCount = 1;
|
||||
|
||||
m_pSurface = pSurface;
|
||||
|
||||
// PicoFixSurfaceNormals( pSurface );
|
||||
|
||||
AccumulateBBox();
|
||||
|
||||
m_shader = QERApp_Shader_ForName(GetShaderName());
|
||||
}
|
||||
|
||||
CPicoSurface::~CPicoSurface()
|
||||
{
|
||||
m_shader->DecRef();
|
||||
}
|
||||
|
||||
void CPicoSurface::Draw(int state, int rflags)
|
||||
{
|
||||
Draw(state, m_shader, rflags);
|
||||
}
|
||||
|
||||
void CPicoSurface::Draw(int state, IShader *pShader, int rflags)
|
||||
{
|
||||
int j;
|
||||
|
||||
if( !(rflags & (DRAW_RF_SEL_OUTLINE|DRAW_RF_SEL_FILL|DRAW_RF_XY)) )
|
||||
{
|
||||
if(state & DRAW_GL_TEXTURE_2D)
|
||||
{
|
||||
g_QglTable.m_pfn_qglBindTexture(GL_TEXTURE_2D, pShader->getTexture()->texture_number);
|
||||
if( (rflags & DRAW_RF_CAM) && (pShader->getFlags() & QER_ALPHAFUNC) ) {
|
||||
int nFunc = 0;
|
||||
float fRef = 0.f;
|
||||
|
||||
g_QglTable.m_pfn_qglColor4f( 1.f, 1.f, 1.f, 1.f ); // identity
|
||||
|
||||
g_QglTable.m_pfn_qglEnable( GL_ALPHA_TEST );
|
||||
|
||||
pShader->getAlphaFunc( &nFunc, &fRef );
|
||||
g_QglTable.m_pfn_qglAlphaFunc( nFunc, fRef );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//g_QglTable.m_pfn_qglColor3fv( pShader->getTexture()->color );
|
||||
/* g_QglTable.m_pfn_qglEnableClientState(GL_COLOR_ARRAY);*/
|
||||
}
|
||||
|
||||
if( !(state & DRAW_GL_WIRE) && (pShader->getFlags() & QER_CULL) )
|
||||
{
|
||||
if( pShader->getCull() == 2 )
|
||||
{
|
||||
g_QglTable.m_pfn_qglDisable( GL_CULL_FACE );
|
||||
g_QglTable.m_pfn_qglPolygonMode (GL_FRONT, GL_FILL);
|
||||
}
|
||||
else // is 1
|
||||
{
|
||||
g_QglTable.m_pfn_qglCullFace( GL_BACK );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch( PicoGetSurfaceType(m_pSurface) )
|
||||
{
|
||||
case PICO_TRIANGLES: g_QglTable.m_pfn_qglBegin(GL_TRIANGLES);
|
||||
for (j=0; j<PicoGetSurfaceNumIndexes(m_pSurface); j++)
|
||||
{
|
||||
g_QglTable.m_pfn_qglNormal3fv(PicoGetSurfaceNormal(m_pSurface,PicoGetSurfaceIndex(m_pSurface,j)));
|
||||
|
||||
if( !(rflags & (DRAW_RF_SEL_OUTLINE|DRAW_RF_SEL_FILL|DRAW_RF_XY)) ) {
|
||||
if(state & DRAW_GL_TEXTURE_2D) {
|
||||
g_QglTable.m_pfn_qglTexCoord2fv(PicoGetSurfaceST(m_pSurface,0,PicoGetSurfaceIndex(m_pSurface,j)));
|
||||
} else {
|
||||
picoByte_t *vertexColor = PicoGetSurfaceColor(m_pSurface,0,PicoGetSurfaceIndex(m_pSurface,j));
|
||||
//% g_QglTable.m_pfn_qglColor4f( vertexColor[ 0 ] / 255.f,
|
||||
//% vertexColor[ 1 ] / 255.f,
|
||||
//% vertexColor[ 2 ] / 255.f,
|
||||
//% vertexColor[ 3 ] / 255.f );
|
||||
g_QglTable.m_pfn_qglColor4ubv( vertexColor );
|
||||
}
|
||||
}
|
||||
g_QglTable.m_pfn_qglVertex3fv( PicoGetSurfaceXYZ( m_pSurface, PicoGetSurfaceIndex( m_pSurface, j ) ) );
|
||||
}
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
/*g_QglTable.m_pfn_qglVertexPointer( 3, GL_FLOAT, 0, PicoGetSurfaceXYZ( m_pSurface, 0 ) );
|
||||
g_QglTable.m_pfn_qglNormalPointer( GL_FLOAT, 0, PicoGetSurfaceNormal( m_pSurface, 0 ) );
|
||||
if( !(rflags & (DRAW_RF_SEL_OUTLINE|DRAW_RF_SEL_FILL|DRAW_RF_XY)) ) {
|
||||
if( state & DRAW_GL_TEXTURE_2D ) {
|
||||
g_QglTable.m_pfn_qglTexCoordPointer( 2, GL_FLOAT, 0, PicoGetSurfaceST( m_pSurface, 0, 0 ) );
|
||||
} else {
|
||||
g_QglTable.m_pfn_qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, PicoGetSurfaceColor( m_pSurface, 0, 0 ) );
|
||||
}
|
||||
}
|
||||
g_QglTable.m_pfn_qglDrawElements( GL_TRIANGLES, PicoGetSurfaceNumIndexes( m_pSurface ), GL_UNSIGNED_INT, PicoGetSurfaceIndexes( m_pSurface, 0 ) );*/
|
||||
|
||||
/*g_QglTable.m_pfn_qglColor3f( 0.f, .5f, 1.f );
|
||||
g_QglTable.m_pfn_qglBegin( GL_LINES );
|
||||
for( int i = 0; i < PicoGetSurfaceNumIndexes( m_pSurface ); i++ ) {
|
||||
vec3_t outerpoint;
|
||||
VectorMA( PicoGetSurfaceXYZ( m_pSurface, PicoGetSurfaceIndex( m_pSurface, i ) ), .3f, PicoGetSurfaceNormal( m_pSurface, PicoGetSurfaceIndex( m_pSurface, i ) ), outerpoint );
|
||||
g_QglTable.m_pfn_qglVertex3fv( PicoGetSurfaceXYZ( m_pSurface, PicoGetSurfaceIndex( m_pSurface, i ) ) );
|
||||
g_QglTable.m_pfn_qglVertex3fv( outerpoint );
|
||||
}
|
||||
g_QglTable.m_pfn_qglEnd();*/
|
||||
|
||||
break;
|
||||
default: Sys_Printf( "ERROR: Unsupported Pico Surface Type: %i", PicoGetSurfaceType(m_pSurface) );
|
||||
break;
|
||||
}
|
||||
|
||||
if( !(rflags & (DRAW_RF_SEL_OUTLINE|DRAW_RF_SEL_FILL|DRAW_RF_XY)) )
|
||||
{
|
||||
if( (state & DRAW_GL_TEXTURE_2D) && (rflags & DRAW_RF_CAM) && (pShader->getFlags() & QER_ALPHAFUNC) ) {
|
||||
g_QglTable.m_pfn_qglDisable( GL_ALPHA_TEST );
|
||||
}
|
||||
|
||||
/* if(!(state & DRAW_GL_TEXTURE_2D)) {
|
||||
g_QglTable.m_pfn_qglDisableClientState(GL_COLOR_ARRAY);
|
||||
}*/
|
||||
|
||||
if( !(state & DRAW_GL_WIRE) && (pShader->getFlags() & QER_CULL) )
|
||||
{
|
||||
if( pShader->getCull() == 2 )
|
||||
{
|
||||
g_QglTable.m_pfn_qglPolygonMode (GL_FRONT, GL_LINE);
|
||||
g_QglTable.m_pfn_qglEnable( GL_CULL_FACE );
|
||||
}
|
||||
else // is 1
|
||||
{
|
||||
g_QglTable.m_pfn_qglCullFace( GL_FRONT );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
void CPicoSurface::AccumulateBBox()
|
||||
{
|
||||
int i;
|
||||
picoVec_t *p;
|
||||
aabb_clear(&m_BBox);
|
||||
for (i=0; i<PicoGetSurfaceNumVertexes(m_pSurface); i++)
|
||||
{
|
||||
p=PicoGetSurfaceXYZ(m_pSurface,i);
|
||||
aabb_extend_by_point(&m_BBox, p);
|
||||
}
|
||||
aabb_update_radius(&m_BBox);
|
||||
}
|
||||
|
||||
bool CPicoSurface::TestRay (const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
int i;
|
||||
vec_t start_dist = *dist;
|
||||
vec_t local_dist = *dist;
|
||||
if (aabb_intersect_ray(&m_BBox, ray, &local_dist))
|
||||
{
|
||||
switch( PicoGetSurfaceType(m_pSurface) )
|
||||
{
|
||||
case PICO_TRIANGLES:
|
||||
for (i=0; i<PicoGetSurfaceNumIndexes(m_pSurface); i+=3)
|
||||
{
|
||||
local_dist = ray_intersect_triangle(ray, true, PicoGetSurfaceXYZ(m_pSurface,PicoGetSurfaceIndex(m_pSurface,i+2)),
|
||||
PicoGetSurfaceXYZ(m_pSurface,PicoGetSurfaceIndex(m_pSurface,i+1)),
|
||||
PicoGetSurfaceXYZ(m_pSurface,PicoGetSurfaceIndex(m_pSurface,i)));
|
||||
if (local_dist < *dist)
|
||||
*dist = local_dist;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Printf( "ERROR: Unsupported Pico Surface Type: %i", PicoGetSurfaceType(m_pSurface) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (*dist < start_dist);
|
||||
}
|
||||
|
||||
@@ -1,451 +1,451 @@
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "entitymodel.h"
|
||||
|
||||
extern CModelManager g_model_cache;
|
||||
|
||||
//
|
||||
// CEntityMiscModel implementation
|
||||
//
|
||||
|
||||
CEntityMiscModel::CEntityMiscModel ()
|
||||
{
|
||||
refCount = 1;
|
||||
m_name = NULL;
|
||||
m_model = NULL;
|
||||
m_entity = NULL;
|
||||
m_frame = 0;
|
||||
m_remaps = g_ptr_array_new ();
|
||||
m_shaders = g_ptr_array_new ();
|
||||
VectorSet(m_translate, 0,0,0);
|
||||
VectorSet(m_euler, 0,0,0);
|
||||
VectorSet(m_scale, 1,1,1);
|
||||
VectorSet(m_pivot, 0,0,0);
|
||||
m4x4_identity(m_transform);
|
||||
m4x4_identity(m_inverse_transform);
|
||||
}
|
||||
|
||||
typedef struct remap_s {
|
||||
char m_key[64];
|
||||
char m_remapbuff[64+1024];
|
||||
char *m_remap[2];
|
||||
} remap_t;
|
||||
|
||||
CEntityMiscModel::~CEntityMiscModel ()
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if(m_name && *m_name != '\0') {
|
||||
if( !g_model_cache.DeleteByNameAndFrame(m_name,m_frame) && m_model )
|
||||
m_model->RemoveParent( this );
|
||||
m_model = NULL;
|
||||
delete [] m_name;
|
||||
}
|
||||
|
||||
for( i = 0; i < m_remaps->len; i++ )
|
||||
delete (remap_t*)m_remaps->pdata[i];
|
||||
g_ptr_array_free(m_remaps, FALSE);
|
||||
|
||||
for( i = 0; i < m_shaders->len; i++ )
|
||||
{
|
||||
(*(IShader**)m_shaders->pdata[i])->DecRef();
|
||||
delete (IShader**)m_shaders->pdata[i];
|
||||
}
|
||||
g_ptr_array_free(m_shaders, FALSE);
|
||||
|
||||
if(m_entity) {
|
||||
// This might be just an evasion of the actual problem
|
||||
m_entity->model.pRender = NULL;
|
||||
m_entity->model.pSelect = NULL;
|
||||
m_entity->model.pEdit = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// IRender
|
||||
|
||||
void CEntityMiscModel::Draw(int state, int rflags) const
|
||||
{
|
||||
m4x4_t matrix;
|
||||
vec3_t pivot;
|
||||
|
||||
memcpy(matrix, m_transform, sizeof(m4x4_t));
|
||||
m4x4_transpose(matrix);
|
||||
|
||||
VectorAdd(m_pivot, m_translate, pivot);
|
||||
pivot_draw(pivot);
|
||||
|
||||
// push the current modelview matrix
|
||||
// FIXME: put in a check for stack recursion depth..
|
||||
// or avoid recursion of opengl matrix stack
|
||||
g_QglTable.m_pfn_qglPushMatrix();
|
||||
// apply the parent-to-local transform
|
||||
g_QglTable.m_pfn_qglMultMatrixf(matrix);
|
||||
|
||||
// draw children
|
||||
if(m_model)
|
||||
m_model->Draw(state, m_shaders, rflags);
|
||||
|
||||
g_QglTable.m_pfn_qglPopMatrix();
|
||||
}
|
||||
|
||||
// ISelect
|
||||
|
||||
bool CEntityMiscModel::TestRay(const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
vec_t dist_start = *dist;
|
||||
vec_t dist_local = *dist;
|
||||
ray_t ray_local = *ray;
|
||||
|
||||
if (!aabb_intersect_ray(&m_BBox, &ray_local, &dist_local))
|
||||
return false;
|
||||
|
||||
if(m_model){
|
||||
ray_transform(&ray_local, m_inverse_transform);
|
||||
dist_local = dist_start;
|
||||
if(m_model->TestRay(&ray_local, &dist_local))
|
||||
*dist = dist_local;
|
||||
} else *dist = dist_local;
|
||||
|
||||
return *dist < dist_start;
|
||||
}
|
||||
|
||||
|
||||
//IEdit
|
||||
|
||||
void CEntityMiscModel::Translate(const vec3_t translation)
|
||||
{
|
||||
VectorIncrement(translation, m_translate);
|
||||
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, pivot);
|
||||
m4x4_transform_point(rotation_matrix, m_translate);
|
||||
|
||||
VectorIncrement(rotation, m_euler);
|
||||
|
||||
UpdateCachedData();
|
||||
}
|
||||
|
||||
void CEntityMiscModel::OnKeyChanged(entity_t *e, const char *key)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
// FIXME: keys are case-sensitive?
|
||||
|
||||
m_entity = e;
|
||||
|
||||
if(strcmp(key,"model") == 0)
|
||||
SetName(ValueForKey(e,"model"));
|
||||
else if(strcmp(key,"_frame") == 0)
|
||||
SetFrame(IntForKey(e,"_frame"));
|
||||
else if(strcmp(key,"angle") == 0 || strcmp(key,"angles") == 0)
|
||||
{
|
||||
VectorSet(m_euler, 0.f, 0.f, 0.f);
|
||||
m_euler[2] = FloatForKey(e,"angle");
|
||||
value = ValueForKey(e,"angles");
|
||||
if (value[0] != '\0')
|
||||
sscanf (value, "%f %f %f", &m_euler[0], &m_euler[2], &m_euler[1]);
|
||||
UpdateCachedData();
|
||||
}
|
||||
else if(strcmp(key,"modelscale") == 0 || strcmp(key,"modelscale_vec") == 0)
|
||||
{
|
||||
VectorSet(m_scale, 1.f, 1.f, 1.f);
|
||||
value = ValueForKey(e,"modelscale");
|
||||
if (value[0] != '\0')
|
||||
{
|
||||
float f = atof(value);
|
||||
if( f != 0 )
|
||||
VectorSet(m_scale, f, f, f);
|
||||
else
|
||||
Sys_FPrintf(SYS_WRN, "WARNING: ignoring 0 modelscale key\n");
|
||||
}
|
||||
value = ValueForKey(e,"modelscale_vec");
|
||||
if (value[0] != '\0')
|
||||
{
|
||||
sscanf (value, "%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)
|
||||
{
|
||||
value = ValueForKey(e,"origin");
|
||||
sscanf(value, "%f %f %f", &m_translate[0], &m_translate[1], &m_translate[2]);
|
||||
UpdateCachedData();
|
||||
}
|
||||
else if(strncmp(key,"_remap",6) == 0)
|
||||
{
|
||||
unsigned int i;
|
||||
remap_t *pRemap;
|
||||
char *ch;
|
||||
|
||||
value = ValueForKey(e,key);
|
||||
|
||||
for(i=0; i<m_remaps->len; i++)
|
||||
{
|
||||
pRemap = (remap_t*)m_remaps->pdata[i];
|
||||
if(strcmp(key,pRemap->m_key) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if( i == m_remaps->len )
|
||||
{
|
||||
if( value[0] == '\0' )
|
||||
return;
|
||||
|
||||
pRemap = new remap_t;
|
||||
g_ptr_array_add(m_remaps, pRemap);
|
||||
}
|
||||
else if( value[0] == '\0' )
|
||||
{
|
||||
g_ptr_array_remove_index_fast(m_remaps, i);
|
||||
delete pRemap;
|
||||
|
||||
UpdateShaders();
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(pRemap->m_remapbuff,value,sizeof(pRemap->m_remapbuff));
|
||||
strncpy(pRemap->m_key,key,sizeof(pRemap->m_key));
|
||||
|
||||
pRemap->m_remap[0] = ch = pRemap->m_remapbuff;
|
||||
|
||||
while( *ch && *ch != ';' )
|
||||
ch++;
|
||||
|
||||
if( *ch == '\0' )
|
||||
{
|
||||
// bad remap
|
||||
Sys_FPrintf(SYS_WRN, "WARNING: Shader _remap key found in misc_model without a ; character\n" );
|
||||
g_ptr_array_remove_index_fast(m_remaps, i);
|
||||
delete pRemap;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ch = '\0';
|
||||
pRemap->m_remap[1] = ch + 1;
|
||||
}
|
||||
|
||||
UpdateShaders();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CEntityMiscModel
|
||||
//
|
||||
|
||||
// private:
|
||||
|
||||
void CEntityMiscModel::SetName(const char *name)
|
||||
{
|
||||
if(m_name && *m_name != '\0') {
|
||||
if(strcmp(m_name, name) == 0)
|
||||
return;
|
||||
if( !g_model_cache.DeleteByNameAndFrame(m_name,m_frame) && m_model )
|
||||
m_model->RemoveParent( this );
|
||||
delete [] m_name;
|
||||
}
|
||||
|
||||
m_model = NULL;
|
||||
m_name = new char[strlen(name)+1];
|
||||
strcpy(m_name,name);
|
||||
|
||||
if(*m_name != '\0') {
|
||||
m_model = g_model_cache.GetByNameAndFrame(m_name, m_frame);
|
||||
m_model->AddParent( this );
|
||||
}
|
||||
|
||||
UpdateCachedData();
|
||||
UpdateShaders();
|
||||
}
|
||||
|
||||
void CEntityMiscModel::SetFrame(const int frame)
|
||||
{
|
||||
if( m_frame == frame )
|
||||
return;
|
||||
|
||||
if(m_name && *m_name != '\0') {
|
||||
if( !g_model_cache.DeleteByNameAndFrame(m_name,m_frame) && m_model )
|
||||
m_model->RemoveParent( this );
|
||||
}
|
||||
|
||||
m_model = NULL;
|
||||
|
||||
m_frame = frame;
|
||||
|
||||
if(*m_name != '\0') {
|
||||
m_model = g_model_cache.GetByNameAndFrame(m_name, m_frame);
|
||||
m_model->AddParent( this );
|
||||
}
|
||||
|
||||
UpdateCachedData();
|
||||
}
|
||||
|
||||
void CEntityMiscModel::UpdateCachedData()
|
||||
{
|
||||
aabb_t aabb_temp;
|
||||
bbox_t bbox_temp;
|
||||
|
||||
m4x4_identity(m_transform);
|
||||
m4x4_pivoted_transform_by_vec3(m_transform, m_translate, m_euler, m_scale, m_pivot);
|
||||
memcpy(m_inverse_transform, m_transform, sizeof(m4x4_t));
|
||||
if(m4x4_invert(m_inverse_transform) == 1) {
|
||||
Sys_Printf("ERROR: Singular Matrix, cannot invert");
|
||||
}
|
||||
|
||||
aabb_clear(&aabb_temp);
|
||||
|
||||
if(m_model)
|
||||
aabb_extend_by_aabb(&aabb_temp, m_model->GetAABB());
|
||||
else
|
||||
{
|
||||
if (m_entity->eclass)
|
||||
VectorSet(aabb_temp.extents, m_entity->eclass->maxs[0], m_entity->eclass->maxs[1], m_entity->eclass->maxs[2]);
|
||||
else
|
||||
VectorSet(aabb_temp.extents, 8, 8, 8);
|
||||
}
|
||||
|
||||
// create an oriented BBox in world-space
|
||||
bbox_for_oriented_aabb(&bbox_temp, &aabb_temp, m_transform, m_euler, m_scale);
|
||||
// create an axis aligned bbox in world-space
|
||||
aabb_for_bbox(&m_BBox, &bbox_temp);
|
||||
|
||||
aabb_update_radius(&m_BBox);
|
||||
}
|
||||
|
||||
void CEntityMiscModel::UpdateShaders()
|
||||
{
|
||||
unsigned int i, j, numSurfaces;
|
||||
remap_t *pRemap, *pGlobRemap = NULL;
|
||||
char *surfShaderName;
|
||||
IShader **pShader;
|
||||
|
||||
if( !m_model )
|
||||
{
|
||||
if( m_shaders->len )
|
||||
{
|
||||
// free our shaders
|
||||
for( i = 0; i < m_shaders->len; i++ )
|
||||
{
|
||||
g_ptr_array_remove_index_fast(m_shaders, i);
|
||||
(*(IShader**)m_shaders->pdata[i])->DecRef();
|
||||
delete (IShader**)m_shaders->pdata[i];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
numSurfaces = m_model->GetNumSurfaces();
|
||||
|
||||
if( numSurfaces < m_shaders->len )
|
||||
{
|
||||
// free unneeded shader pointers
|
||||
for( i = m_shaders->len - 1; i >= numSurfaces; i-- )
|
||||
{
|
||||
g_ptr_array_remove_index_fast(m_shaders, i);
|
||||
(*(IShader**)m_shaders->pdata[i])->DecRef();
|
||||
delete (IShader**)m_shaders->pdata[i];
|
||||
}
|
||||
}
|
||||
|
||||
// now go through our surface and find our shaders, remap if needed
|
||||
for( j = 0; j < numSurfaces; j++ )
|
||||
{
|
||||
surfShaderName = m_model->GetShaderNameForSurface(j);
|
||||
|
||||
if( j < m_shaders->len )
|
||||
{
|
||||
pShader = (IShader **)m_shaders->pdata[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
pShader = new (IShader *);
|
||||
*pShader = NULL;
|
||||
g_ptr_array_add(m_shaders, pShader);
|
||||
}
|
||||
|
||||
if( m_remaps->len )
|
||||
{
|
||||
for( i = 0; i < m_remaps->len; i++ )
|
||||
{
|
||||
pRemap = (remap_t*)m_remaps->pdata[i];
|
||||
if( stricmp(pRemap->m_remap[0],surfShaderName) == 0 )
|
||||
{
|
||||
// only do the shader lookups if really needed
|
||||
if( !(*pShader) || stricmp(pRemap->m_remap[1],(*pShader)->getName()) )
|
||||
{
|
||||
if( *pShader )
|
||||
(*pShader)->DecRef();
|
||||
*pShader = QERApp_Shader_ForName(pRemap->m_remap[1]);
|
||||
}
|
||||
|
||||
pGlobRemap = NULL;
|
||||
break;
|
||||
}
|
||||
else if( pRemap->m_remap[0][0] == '*' && pRemap->m_remap[0][1] == '\0' )
|
||||
pGlobRemap = pRemap;
|
||||
}
|
||||
|
||||
if( pGlobRemap )
|
||||
{
|
||||
if( !(*pShader) || stricmp(pGlobRemap->m_remap[1],(*pShader)->getName()) )
|
||||
{
|
||||
if( *pShader )
|
||||
(*pShader)->DecRef();
|
||||
*pShader = QERApp_Shader_ForName(pGlobRemap->m_remap[1]);
|
||||
}
|
||||
}
|
||||
else if( i == m_remaps->len )
|
||||
{
|
||||
// Back to the default one, if needed
|
||||
if( !(*pShader) || (stricmp(surfShaderName,(*pShader)->getName()) && !(surfShaderName[0] == '\0')) )
|
||||
{
|
||||
if( *pShader )
|
||||
(*pShader)->DecRef();
|
||||
*pShader = QERApp_Shader_ForName(surfShaderName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Model specified shader, if needed
|
||||
if( !(*pShader) || (stricmp(surfShaderName,(*pShader)->getName()) && !(surfShaderName[0] == '\0')) )
|
||||
{
|
||||
if( *pShader )
|
||||
(*pShader)->DecRef();
|
||||
*pShader = QERApp_Shader_ForName(surfShaderName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "entitymodel.h"
|
||||
|
||||
extern CModelManager g_model_cache;
|
||||
|
||||
//
|
||||
// CEntityMiscModel implementation
|
||||
//
|
||||
|
||||
CEntityMiscModel::CEntityMiscModel ()
|
||||
{
|
||||
refCount = 1;
|
||||
m_name = NULL;
|
||||
m_model = NULL;
|
||||
m_entity = NULL;
|
||||
m_frame = 0;
|
||||
m_remaps = g_ptr_array_new ();
|
||||
m_shaders = g_ptr_array_new ();
|
||||
VectorSet(m_translate, 0,0,0);
|
||||
VectorSet(m_euler, 0,0,0);
|
||||
VectorSet(m_scale, 1,1,1);
|
||||
VectorSet(m_pivot, 0,0,0);
|
||||
m4x4_identity(m_transform);
|
||||
m4x4_identity(m_inverse_transform);
|
||||
}
|
||||
|
||||
typedef struct remap_s {
|
||||
char m_key[64];
|
||||
char m_remapbuff[64+1024];
|
||||
char *m_remap[2];
|
||||
} remap_t;
|
||||
|
||||
CEntityMiscModel::~CEntityMiscModel ()
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if(m_name && *m_name != '\0') {
|
||||
if( !g_model_cache.DeleteByNameAndFrame(m_name,m_frame) && m_model )
|
||||
m_model->RemoveParent( this );
|
||||
m_model = NULL;
|
||||
delete [] m_name;
|
||||
}
|
||||
|
||||
for( i = 0; i < m_remaps->len; i++ )
|
||||
delete (remap_t*)m_remaps->pdata[i];
|
||||
g_ptr_array_free(m_remaps, FALSE);
|
||||
|
||||
for( i = 0; i < m_shaders->len; i++ )
|
||||
{
|
||||
(*(IShader**)m_shaders->pdata[i])->DecRef();
|
||||
delete (IShader**)m_shaders->pdata[i];
|
||||
}
|
||||
g_ptr_array_free(m_shaders, FALSE);
|
||||
|
||||
if(m_entity) {
|
||||
// This might be just an evasion of the actual problem
|
||||
m_entity->model.pRender = NULL;
|
||||
m_entity->model.pSelect = NULL;
|
||||
m_entity->model.pEdit = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// IRender
|
||||
|
||||
void CEntityMiscModel::Draw(int state, int rflags) const
|
||||
{
|
||||
m4x4_t matrix;
|
||||
vec3_t pivot;
|
||||
|
||||
memcpy(matrix, m_transform, sizeof(m4x4_t));
|
||||
m4x4_transpose(matrix);
|
||||
|
||||
VectorAdd(m_pivot, m_translate, pivot);
|
||||
pivot_draw(pivot);
|
||||
|
||||
// push the current modelview matrix
|
||||
// FIXME: put in a check for stack recursion depth..
|
||||
// or avoid recursion of opengl matrix stack
|
||||
g_QglTable.m_pfn_qglPushMatrix();
|
||||
// apply the parent-to-local transform
|
||||
g_QglTable.m_pfn_qglMultMatrixf(matrix);
|
||||
|
||||
// draw children
|
||||
if(m_model)
|
||||
m_model->Draw(state, m_shaders, rflags);
|
||||
|
||||
g_QglTable.m_pfn_qglPopMatrix();
|
||||
}
|
||||
|
||||
// ISelect
|
||||
|
||||
bool CEntityMiscModel::TestRay(const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
vec_t dist_start = *dist;
|
||||
vec_t dist_local = *dist;
|
||||
ray_t ray_local = *ray;
|
||||
|
||||
if (!aabb_intersect_ray(&m_BBox, &ray_local, &dist_local))
|
||||
return false;
|
||||
|
||||
if(m_model){
|
||||
ray_transform(&ray_local, m_inverse_transform);
|
||||
dist_local = dist_start;
|
||||
if(m_model->TestRay(&ray_local, &dist_local))
|
||||
*dist = dist_local;
|
||||
} else *dist = dist_local;
|
||||
|
||||
return *dist < dist_start;
|
||||
}
|
||||
|
||||
|
||||
//IEdit
|
||||
|
||||
void CEntityMiscModel::Translate(const vec3_t translation)
|
||||
{
|
||||
VectorIncrement(translation, m_translate);
|
||||
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, pivot);
|
||||
m4x4_transform_point(rotation_matrix, m_translate);
|
||||
|
||||
VectorIncrement(rotation, m_euler);
|
||||
|
||||
UpdateCachedData();
|
||||
}
|
||||
|
||||
void CEntityMiscModel::OnKeyChanged(entity_t *e, const char *key)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
// FIXME: keys are case-sensitive?
|
||||
|
||||
m_entity = e;
|
||||
|
||||
if(strcmp(key,"model") == 0)
|
||||
SetName(ValueForKey(e,"model"));
|
||||
else if(strcmp(key,"_frame") == 0)
|
||||
SetFrame(IntForKey(e,"_frame"));
|
||||
else if(strcmp(key,"angle") == 0 || strcmp(key,"angles") == 0)
|
||||
{
|
||||
VectorSet(m_euler, 0.f, 0.f, 0.f);
|
||||
m_euler[2] = FloatForKey(e,"angle");
|
||||
value = ValueForKey(e,"angles");
|
||||
if (value[0] != '\0')
|
||||
sscanf (value, "%f %f %f", &m_euler[0], &m_euler[2], &m_euler[1]);
|
||||
UpdateCachedData();
|
||||
}
|
||||
else if(strcmp(key,"modelscale") == 0 || strcmp(key,"modelscale_vec") == 0)
|
||||
{
|
||||
VectorSet(m_scale, 1.f, 1.f, 1.f);
|
||||
value = ValueForKey(e,"modelscale");
|
||||
if (value[0] != '\0')
|
||||
{
|
||||
float f = atof(value);
|
||||
if( f != 0 )
|
||||
VectorSet(m_scale, f, f, f);
|
||||
else
|
||||
Sys_FPrintf(SYS_WRN, "WARNING: ignoring 0 modelscale key\n");
|
||||
}
|
||||
value = ValueForKey(e,"modelscale_vec");
|
||||
if (value[0] != '\0')
|
||||
{
|
||||
sscanf (value, "%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)
|
||||
{
|
||||
value = ValueForKey(e,"origin");
|
||||
sscanf(value, "%f %f %f", &m_translate[0], &m_translate[1], &m_translate[2]);
|
||||
UpdateCachedData();
|
||||
}
|
||||
else if(strncmp(key,"_remap",6) == 0)
|
||||
{
|
||||
unsigned int i;
|
||||
remap_t *pRemap;
|
||||
char *ch;
|
||||
|
||||
value = ValueForKey(e,key);
|
||||
|
||||
for(i=0; i<m_remaps->len; i++)
|
||||
{
|
||||
pRemap = (remap_t*)m_remaps->pdata[i];
|
||||
if(strcmp(key,pRemap->m_key) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if( i == m_remaps->len )
|
||||
{
|
||||
if( value[0] == '\0' )
|
||||
return;
|
||||
|
||||
pRemap = new remap_t;
|
||||
g_ptr_array_add(m_remaps, pRemap);
|
||||
}
|
||||
else if( value[0] == '\0' )
|
||||
{
|
||||
g_ptr_array_remove_index_fast(m_remaps, i);
|
||||
delete pRemap;
|
||||
|
||||
UpdateShaders();
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(pRemap->m_remapbuff,value,sizeof(pRemap->m_remapbuff));
|
||||
strncpy(pRemap->m_key,key,sizeof(pRemap->m_key));
|
||||
|
||||
pRemap->m_remap[0] = ch = pRemap->m_remapbuff;
|
||||
|
||||
while( *ch && *ch != ';' )
|
||||
ch++;
|
||||
|
||||
if( *ch == '\0' )
|
||||
{
|
||||
// bad remap
|
||||
Sys_FPrintf(SYS_WRN, "WARNING: Shader _remap key found in misc_model without a ; character\n" );
|
||||
g_ptr_array_remove_index_fast(m_remaps, i);
|
||||
delete pRemap;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ch = '\0';
|
||||
pRemap->m_remap[1] = ch + 1;
|
||||
}
|
||||
|
||||
UpdateShaders();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CEntityMiscModel
|
||||
//
|
||||
|
||||
// private:
|
||||
|
||||
void CEntityMiscModel::SetName(const char *name)
|
||||
{
|
||||
if(m_name && *m_name != '\0') {
|
||||
if(strcmp(m_name, name) == 0)
|
||||
return;
|
||||
if( !g_model_cache.DeleteByNameAndFrame(m_name,m_frame) && m_model )
|
||||
m_model->RemoveParent( this );
|
||||
delete [] m_name;
|
||||
}
|
||||
|
||||
m_model = NULL;
|
||||
m_name = new char[strlen(name)+1];
|
||||
strcpy(m_name,name);
|
||||
|
||||
if(*m_name != '\0') {
|
||||
m_model = g_model_cache.GetByNameAndFrame(m_name, m_frame);
|
||||
m_model->AddParent( this );
|
||||
}
|
||||
|
||||
UpdateCachedData();
|
||||
UpdateShaders();
|
||||
}
|
||||
|
||||
void CEntityMiscModel::SetFrame(const int frame)
|
||||
{
|
||||
if( m_frame == frame )
|
||||
return;
|
||||
|
||||
if(m_name && *m_name != '\0') {
|
||||
if( !g_model_cache.DeleteByNameAndFrame(m_name,m_frame) && m_model )
|
||||
m_model->RemoveParent( this );
|
||||
}
|
||||
|
||||
m_model = NULL;
|
||||
|
||||
m_frame = frame;
|
||||
|
||||
if(*m_name != '\0') {
|
||||
m_model = g_model_cache.GetByNameAndFrame(m_name, m_frame);
|
||||
m_model->AddParent( this );
|
||||
}
|
||||
|
||||
UpdateCachedData();
|
||||
}
|
||||
|
||||
void CEntityMiscModel::UpdateCachedData()
|
||||
{
|
||||
aabb_t aabb_temp;
|
||||
bbox_t bbox_temp;
|
||||
|
||||
m4x4_identity(m_transform);
|
||||
m4x4_pivoted_transform_by_vec3(m_transform, m_translate, m_euler, m_scale, m_pivot);
|
||||
memcpy(m_inverse_transform, m_transform, sizeof(m4x4_t));
|
||||
if(m4x4_invert(m_inverse_transform) == 1) {
|
||||
Sys_Printf("ERROR: Singular Matrix, cannot invert");
|
||||
}
|
||||
|
||||
aabb_clear(&aabb_temp);
|
||||
|
||||
if(m_model)
|
||||
aabb_extend_by_aabb(&aabb_temp, m_model->GetAABB());
|
||||
else
|
||||
{
|
||||
if (m_entity->eclass)
|
||||
VectorSet(aabb_temp.extents, m_entity->eclass->maxs[0], m_entity->eclass->maxs[1], m_entity->eclass->maxs[2]);
|
||||
else
|
||||
VectorSet(aabb_temp.extents, 8, 8, 8);
|
||||
}
|
||||
|
||||
// create an oriented BBox in world-space
|
||||
bbox_for_oriented_aabb(&bbox_temp, &aabb_temp, m_transform, m_euler, m_scale);
|
||||
// create an axis aligned bbox in world-space
|
||||
aabb_for_bbox(&m_BBox, &bbox_temp);
|
||||
|
||||
aabb_update_radius(&m_BBox);
|
||||
}
|
||||
|
||||
void CEntityMiscModel::UpdateShaders()
|
||||
{
|
||||
unsigned int i, j, numSurfaces;
|
||||
remap_t *pRemap, *pGlobRemap = NULL;
|
||||
char *surfShaderName;
|
||||
IShader **pShader;
|
||||
|
||||
if( !m_model )
|
||||
{
|
||||
if( m_shaders->len )
|
||||
{
|
||||
// free our shaders
|
||||
for( i = 0; i < m_shaders->len; i++ )
|
||||
{
|
||||
g_ptr_array_remove_index_fast(m_shaders, i);
|
||||
(*(IShader**)m_shaders->pdata[i])->DecRef();
|
||||
delete (IShader**)m_shaders->pdata[i];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
numSurfaces = m_model->GetNumSurfaces();
|
||||
|
||||
if( numSurfaces < m_shaders->len )
|
||||
{
|
||||
// free unneeded shader pointers
|
||||
for( i = m_shaders->len - 1; i >= numSurfaces; i-- )
|
||||
{
|
||||
g_ptr_array_remove_index_fast(m_shaders, i);
|
||||
(*(IShader**)m_shaders->pdata[i])->DecRef();
|
||||
delete (IShader**)m_shaders->pdata[i];
|
||||
}
|
||||
}
|
||||
|
||||
// now go through our surface and find our shaders, remap if needed
|
||||
for( j = 0; j < numSurfaces; j++ )
|
||||
{
|
||||
surfShaderName = m_model->GetShaderNameForSurface(j);
|
||||
|
||||
if( j < m_shaders->len )
|
||||
{
|
||||
pShader = (IShader **)m_shaders->pdata[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
pShader = new (IShader *);
|
||||
*pShader = NULL;
|
||||
g_ptr_array_add(m_shaders, pShader);
|
||||
}
|
||||
|
||||
if( m_remaps->len )
|
||||
{
|
||||
for( i = 0; i < m_remaps->len; i++ )
|
||||
{
|
||||
pRemap = (remap_t*)m_remaps->pdata[i];
|
||||
if( stricmp(pRemap->m_remap[0],surfShaderName) == 0 )
|
||||
{
|
||||
// only do the shader lookups if really needed
|
||||
if( !(*pShader) || stricmp(pRemap->m_remap[1],(*pShader)->getName()) )
|
||||
{
|
||||
if( *pShader )
|
||||
(*pShader)->DecRef();
|
||||
*pShader = QERApp_Shader_ForName(pRemap->m_remap[1]);
|
||||
}
|
||||
|
||||
pGlobRemap = NULL;
|
||||
break;
|
||||
}
|
||||
else if( pRemap->m_remap[0][0] == '*' && pRemap->m_remap[0][1] == '\0' )
|
||||
pGlobRemap = pRemap;
|
||||
}
|
||||
|
||||
if( pGlobRemap )
|
||||
{
|
||||
if( !(*pShader) || stricmp(pGlobRemap->m_remap[1],(*pShader)->getName()) )
|
||||
{
|
||||
if( *pShader )
|
||||
(*pShader)->DecRef();
|
||||
*pShader = QERApp_Shader_ForName(pGlobRemap->m_remap[1]);
|
||||
}
|
||||
}
|
||||
else if( i == m_remaps->len )
|
||||
{
|
||||
// Back to the default one, if needed
|
||||
if( !(*pShader) || (stricmp(surfShaderName,(*pShader)->getName()) && !(surfShaderName[0] == '\0')) )
|
||||
{
|
||||
if( *pShader )
|
||||
(*pShader)->DecRef();
|
||||
*pShader = QERApp_Shader_ForName(surfShaderName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Model specified shader, if needed
|
||||
if( !(*pShader) || (stricmp(surfShaderName,(*pShader)->getName()) && !(surfShaderName[0] == '\0')) )
|
||||
{
|
||||
if( *pShader )
|
||||
(*pShader)->DecRef();
|
||||
*pShader = QERApp_Shader_ForName(surfShaderName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,88 +1,88 @@
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "plugin.h"
|
||||
#include "picomodel.h"
|
||||
|
||||
void pivot_draw(const vec3_t pivot)
|
||||
{
|
||||
vec3_t vCenter, vMin, vMax;
|
||||
VectorCopy(pivot, vCenter);
|
||||
|
||||
g_QglTable.m_pfn_qglPointSize(4);
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_POINTS);
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_LINES);
|
||||
vCenter[0] -= 8;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[0] += 16;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[0] -= 8;
|
||||
vCenter[1] -= 8;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[1] += 16;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[1] -= 8;
|
||||
vCenter[2] -= 8;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[2] += 16;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[2] -= 8;
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
|
||||
VectorCopy(vCenter, vMin);
|
||||
VectorCopy(vCenter, vMax);
|
||||
vMin[0] -= 4;
|
||||
vMin[1] -= 4;
|
||||
vMin[2] -= 4;
|
||||
vMax[0] += 4;
|
||||
vMax[1] += 4;
|
||||
vMax[2] += 4;
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_LINE_LOOP);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMin[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMin[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMax[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMax[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_LINE_LOOP);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMin[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMin[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMax[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMax[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_LINES);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMin[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMin[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMax[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMax[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMin[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMin[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMax[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMax[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "plugin.h"
|
||||
#include "picomodel.h"
|
||||
|
||||
void pivot_draw(const vec3_t pivot)
|
||||
{
|
||||
vec3_t vCenter, vMin, vMax;
|
||||
VectorCopy(pivot, vCenter);
|
||||
|
||||
g_QglTable.m_pfn_qglPointSize(4);
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_POINTS);
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_LINES);
|
||||
vCenter[0] -= 8;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[0] += 16;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[0] -= 8;
|
||||
vCenter[1] -= 8;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[1] += 16;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[1] -= 8;
|
||||
vCenter[2] -= 8;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[2] += 16;
|
||||
g_QglTable.m_pfn_qglVertex3fv(vCenter);
|
||||
vCenter[2] -= 8;
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
|
||||
VectorCopy(vCenter, vMin);
|
||||
VectorCopy(vCenter, vMax);
|
||||
vMin[0] -= 4;
|
||||
vMin[1] -= 4;
|
||||
vMin[2] -= 4;
|
||||
vMax[0] += 4;
|
||||
vMax[1] += 4;
|
||||
vMax[2] += 4;
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_LINE_LOOP);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMin[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMin[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMax[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMax[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_LINE_LOOP);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMin[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMin[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMax[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMax[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
|
||||
g_QglTable.m_pfn_qglBegin(GL_LINES);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMin[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMin[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMax[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMin[0],vMax[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMin[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMin[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMax[1],vMax[2]);
|
||||
g_QglTable.m_pfn_qglVertex3f(vMax[0],vMax[1],vMin[2]);
|
||||
g_QglTable.m_pfn_qglEnd();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,429 +1,429 @@
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
#if 0 // stop using windowing systems in plugins - put the text in SynapseClient::GetInfo
|
||||
// =============================================================================
|
||||
// Utility functions
|
||||
static void dialog_button_callback (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
int *loop, *ret;
|
||||
|
||||
parent = gtk_widget_get_toplevel (widget);
|
||||
loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
|
||||
ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");
|
||||
|
||||
*loop = 0;
|
||||
*ret = (int)data;
|
||||
}
|
||||
|
||||
static gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
|
||||
{
|
||||
int *loop;
|
||||
|
||||
gtk_widget_hide (widget);
|
||||
loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");
|
||||
*loop = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int DoAboutBox( GtkWidget *parent )
|
||||
{
|
||||
GtkWidget *window, *w, *text, *vbox, *hbox, *hbox2, *frame;
|
||||
GdkPixmap *pixmap;
|
||||
GdkBitmap *mask;
|
||||
GtkStyle *style;
|
||||
int ret, loop = 1;
|
||||
char buf[2048];
|
||||
const picoModule_t **modules, *pm;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "About...");
|
||||
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
||||
g_object_set_data (G_OBJECT (window), "loop", &loop);
|
||||
g_object_set_data (G_OBJECT (window), "ret", &ret);
|
||||
gtk_widget_realize (window);
|
||||
|
||||
if (parent != NULL)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (parent));
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 10);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
style = gtk_widget_get_style(window);
|
||||
|
||||
hbox2 = gtk_hbox_new (FALSE, 10);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 2);
|
||||
gtk_widget_show (hbox2);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 2);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
if( g_FuncTable.m_pfnLoadBitmap( "picomodel.bmp", (void **)&pixmap, (void **)&mask ) ) {
|
||||
w = gtk_pixmap_new (pixmap, mask);
|
||||
gtk_container_add (GTK_CONTAINER (frame), w);
|
||||
gtk_widget_show (w);
|
||||
}
|
||||
|
||||
w = gtk_label_new ("Model Module v1.0 for GtkRadiant\nby Arnout van Meer (rr2do2@splashdamage.com)\n\nBased on the MD3Model Module by SPoG\nPicoModel Library Copyright (c) 2002, Randy Reddig & seaw0lf" );
|
||||
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
|
||||
gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT);
|
||||
gtk_widget_show (w);
|
||||
|
||||
w = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 2);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
|
||||
gtk_widget_show(w);
|
||||
|
||||
text = gtk_text_new(NULL, NULL);
|
||||
gtk_text_set_editable(GTK_TEXT(text), FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(w), text);
|
||||
|
||||
strcpy( buf, "#Supported Model Formats:\n" );
|
||||
gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buf, -1);
|
||||
|
||||
for( modules = PicoModuleList( NULL ); *modules != NULL; modules++ )
|
||||
{
|
||||
pm = *modules;
|
||||
|
||||
if( pm == NULL)
|
||||
break;
|
||||
|
||||
sprintf( buf, "\n%s, version %s, (c) %s", pm->displayName, pm->version, pm->copyright );
|
||||
gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buf, -1);
|
||||
}
|
||||
|
||||
gtk_text_set_word_wrap(GTK_TEXT(text), FALSE);
|
||||
gtk_widget_show(text);
|
||||
|
||||
gtk_text_set_point(GTK_TEXT(text), 0);
|
||||
gtk_text_forward_delete(GTK_TEXT(text), 1);
|
||||
|
||||
w = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
|
||||
gtk_widget_show (w);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 10);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 2);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
w = gtk_button_new_with_label ("Ok");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
|
||||
GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default (w);
|
||||
gtk_widget_show (w);
|
||||
ret = IDOK;
|
||||
|
||||
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
|
||||
gtk_widget_show (window);
|
||||
gtk_grab_add (window);
|
||||
|
||||
while (loop)
|
||||
gtk_main_iteration ();
|
||||
|
||||
gtk_grab_remove (window);
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
// toolbar implementation
|
||||
|
||||
class CFlushReloadSelectedToolbarButton : public IToolbarButton
|
||||
{
|
||||
public:
|
||||
virtual const char* getImage() const
|
||||
{
|
||||
return "model_reload_entity.bmp";
|
||||
}
|
||||
virtual const char* getText() const
|
||||
{
|
||||
return "Reload";
|
||||
}
|
||||
virtual const char* getTooltip() const
|
||||
{
|
||||
return "Flush & Reload Selected Model";
|
||||
}
|
||||
virtual void activate() const
|
||||
{
|
||||
DoFlushReloadSelected();
|
||||
}
|
||||
virtual EType getType() const
|
||||
{
|
||||
return eButton;
|
||||
}
|
||||
};
|
||||
|
||||
CFlushReloadSelectedToolbarButton g_flushreloadselected;
|
||||
|
||||
unsigned int ToolbarButtonCount()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const IToolbarButton* GetToolbarButton(unsigned int index)
|
||||
{
|
||||
return &g_flushreloadselected;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Pico utility functions
|
||||
|
||||
#include "picomodel.h"
|
||||
|
||||
void PicoPrintFunc( int level, const char *str )
|
||||
{
|
||||
if( str == NULL )
|
||||
return;
|
||||
switch( level )
|
||||
{
|
||||
case PICO_NORMAL:
|
||||
Sys_Printf( "%s\n", str );
|
||||
break;
|
||||
|
||||
case PICO_VERBOSE:
|
||||
Sys_FPrintf( SYS_VRB, "%s\n", str );
|
||||
break;
|
||||
|
||||
case PICO_WARNING:
|
||||
Sys_Printf( "WARNING: %s\n", str );
|
||||
break;
|
||||
|
||||
case PICO_ERROR:
|
||||
Sys_FPrintf( SYS_VRB, "ERROR: %s\n", str );
|
||||
break;
|
||||
|
||||
case PICO_FATAL:
|
||||
Sys_Printf( "ERROR: %s\n", str );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PicoLoadFileFunc( char *name, byte **buffer, int *bufSize )
|
||||
{
|
||||
*bufSize = vfsLoadFile( (const char*) name, (void**) buffer, 0 );
|
||||
}
|
||||
|
||||
void PicoFreeFileFunc( void* file )
|
||||
{
|
||||
vfsFreeFile(file);
|
||||
}
|
||||
|
||||
static void initialise()
|
||||
{
|
||||
PicoInit();
|
||||
PicoSetMallocFunc( malloc );
|
||||
PicoSetFreeFunc( free );
|
||||
PicoSetPrintFunc( PicoPrintFunc );
|
||||
PicoSetLoadFileFunc( PicoLoadFileFunc );
|
||||
PicoSetFreeFileFunc( PicoFreeFileFunc );
|
||||
}
|
||||
|
||||
static void add_model_apis(CSynapseClient& client)
|
||||
{
|
||||
const picoModule_t** modules = PicoModuleList( NULL );
|
||||
while(*modules != NULL)
|
||||
{
|
||||
const picoModule_t* module = *modules++;
|
||||
if(module->canload && module->load)
|
||||
for(unsigned int j = 0; module->defaultExts[j] != NULL; j++)
|
||||
client.AddAPI(MODEL_MAJOR, module->defaultExts[j], sizeof(_QERPlugModelTable));
|
||||
}
|
||||
}
|
||||
|
||||
static bool model_is_supported(const char* extension)
|
||||
{
|
||||
const picoModule_t** modules = PicoModuleList( NULL );
|
||||
while(*modules != NULL)
|
||||
{
|
||||
const picoModule_t* module = *modules++;
|
||||
if(module->canload && module->load)
|
||||
for(unsigned int j = 0; module->defaultExts[j] != NULL; j++)
|
||||
if(strcmp(extension, module->defaultExts[j]) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void init_filetypes()
|
||||
{
|
||||
const picoModule_t **modules = PicoModuleList(NULL);
|
||||
while(*modules != NULL)
|
||||
{
|
||||
const picoModule_t* module = *modules++;
|
||||
if(module->canload && module->load)
|
||||
{
|
||||
for(char*const* ext = module->defaultExts; *ext != NULL; ++ext)
|
||||
{
|
||||
char buf[16];
|
||||
buf[0] = '*';
|
||||
buf[1] = '.';
|
||||
strcpy(buf+2, *ext);
|
||||
GetFileTypeRegistry()->addType(MODEL_MAJOR, filetype_t(module->displayName, buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// plugin implementation
|
||||
|
||||
static const char *PLUGIN_NAME = "Model loading module";
|
||||
static const char *PLUGIN_COMMANDS = "Flush & Reload Models,Flush & Reload Selected";
|
||||
static const char *PLUGIN_ABOUT = "Model loading module";
|
||||
|
||||
extern "C" const char* QERPlug_Init (void *hApp, void* pMainWidget)
|
||||
{
|
||||
init_filetypes();
|
||||
return (char *) PLUGIN_NAME;
|
||||
}
|
||||
|
||||
extern "C" const char* QERPlug_GetName ()
|
||||
{
|
||||
return (char *) PLUGIN_NAME;
|
||||
}
|
||||
|
||||
extern "C" const char* QERPlug_GetCommandList ()
|
||||
{
|
||||
return (char *) PLUGIN_COMMANDS;
|
||||
}
|
||||
|
||||
extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
|
||||
{
|
||||
if( !strcmp( p, "Flush & Reload Selected" ) )
|
||||
DoFlushReloadSelected();
|
||||
else if( !strcmp( p, "Flush & Reload Models" ) )
|
||||
DoFlushReloadAll();
|
||||
}
|
||||
|
||||
|
||||
void DoFlushReloadSelected() {
|
||||
}
|
||||
|
||||
void DoFlushReloadAll() {
|
||||
GetModelCache()->RefreshAll();
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
// function tables
|
||||
_QERFuncTable_1 g_FuncTable;
|
||||
_QERQglTable g_QglTable;
|
||||
_QERShadersTable g_ShadersTable;
|
||||
_QERFileSystemTable g_FileSystemTable;
|
||||
|
||||
// =============================================================================
|
||||
// SYNAPSE
|
||||
|
||||
CSynapseServer* g_pSynapseServer = NULL;
|
||||
CSynapseClientModel g_SynapseClient;
|
||||
|
||||
static const XMLConfigEntry_t entries[] =
|
||||
{ { SHADERS_MAJOR, SYN_REQUIRE, sizeof(g_ShadersTable), &g_ShadersTable },
|
||||
{ VFS_MAJOR, SYN_REQUIRE, sizeof(g_FileSystemTable), &g_FileSystemTable },
|
||||
{ NULL, SYN_UNKNOWN, 0, NULL } };
|
||||
|
||||
extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
|
||||
{
|
||||
if (strcmp(version, SYNAPSE_VERSION))
|
||||
{
|
||||
Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
|
||||
return NULL;
|
||||
}
|
||||
g_pSynapseServer = pServer;
|
||||
g_pSynapseServer->IncRef();
|
||||
Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );
|
||||
|
||||
initialise();
|
||||
|
||||
add_model_apis(g_SynapseClient);
|
||||
g_SynapseClient.AddAPI(TOOLBAR_MAJOR, "model", sizeof(_QERPlugToolbarTable));
|
||||
g_SynapseClient.AddAPI(PLUGIN_MAJOR, "model", sizeof(_QERPluginTable));
|
||||
|
||||
g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
|
||||
g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
|
||||
|
||||
if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &g_SynapseClient;
|
||||
}
|
||||
|
||||
bool CSynapseClientModel::RequestAPI(APIDescriptor_t *pAPI)
|
||||
{
|
||||
if (!strcmp(pAPI->major_name, MODEL_MAJOR))
|
||||
{
|
||||
_QERPlugModelTable* pTable= static_cast<_QERPlugModelTable*>(pAPI->mpTable);
|
||||
|
||||
if (model_is_supported(pAPI->minor_name))
|
||||
{
|
||||
pTable->m_pfnLoadModel = &LoadModel;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR))
|
||||
{
|
||||
_QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);
|
||||
|
||||
pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
|
||||
pTable->m_pfnGetToolbarButton = &GetToolbarButton;
|
||||
return true;
|
||||
}
|
||||
else if (!strcmp(pAPI->major_name, PLUGIN_MAJOR))
|
||||
{
|
||||
_QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
|
||||
|
||||
pTable->m_pfnQERPlug_Init = QERPlug_Init;
|
||||
pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
|
||||
pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
|
||||
pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
|
||||
return true;
|
||||
}
|
||||
|
||||
Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "version.h"
|
||||
|
||||
const char* CSynapseClientModel::GetInfo()
|
||||
{
|
||||
return "picomodel loader module built " __DATE__ " " RADIANT_VERSION;
|
||||
}
|
||||
|
||||
const char* CSynapseClientModel::GetName()
|
||||
{
|
||||
return "model";
|
||||
}
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
||||
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
#if 0 // stop using windowing systems in plugins - put the text in SynapseClient::GetInfo
|
||||
// =============================================================================
|
||||
// Utility functions
|
||||
static void dialog_button_callback (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
int *loop, *ret;
|
||||
|
||||
parent = gtk_widget_get_toplevel (widget);
|
||||
loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
|
||||
ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");
|
||||
|
||||
*loop = 0;
|
||||
*ret = (int)data;
|
||||
}
|
||||
|
||||
static gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
|
||||
{
|
||||
int *loop;
|
||||
|
||||
gtk_widget_hide (widget);
|
||||
loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");
|
||||
*loop = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int DoAboutBox( GtkWidget *parent )
|
||||
{
|
||||
GtkWidget *window, *w, *text, *vbox, *hbox, *hbox2, *frame;
|
||||
GdkPixmap *pixmap;
|
||||
GdkBitmap *mask;
|
||||
GtkStyle *style;
|
||||
int ret, loop = 1;
|
||||
char buf[2048];
|
||||
const picoModule_t **modules, *pm;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "About...");
|
||||
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
||||
g_object_set_data (G_OBJECT (window), "loop", &loop);
|
||||
g_object_set_data (G_OBJECT (window), "ret", &ret);
|
||||
gtk_widget_realize (window);
|
||||
|
||||
if (parent != NULL)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (parent));
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 10);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
style = gtk_widget_get_style(window);
|
||||
|
||||
hbox2 = gtk_hbox_new (FALSE, 10);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 2);
|
||||
gtk_widget_show (hbox2);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 2);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
if( g_FuncTable.m_pfnLoadBitmap( "picomodel.bmp", (void **)&pixmap, (void **)&mask ) ) {
|
||||
w = gtk_pixmap_new (pixmap, mask);
|
||||
gtk_container_add (GTK_CONTAINER (frame), w);
|
||||
gtk_widget_show (w);
|
||||
}
|
||||
|
||||
w = gtk_label_new ("Model Module v1.0 for GtkRadiant\nby Arnout van Meer (rr2do2@splashdamage.com)\n\nBased on the MD3Model Module by SPoG\nPicoModel Library Copyright (c) 2002, Randy Reddig & seaw0lf" );
|
||||
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
|
||||
gtk_label_set_justify (GTK_LABEL (w), GTK_JUSTIFY_LEFT);
|
||||
gtk_widget_show (w);
|
||||
|
||||
w = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), w, TRUE, TRUE, 2);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
|
||||
gtk_widget_show(w);
|
||||
|
||||
text = gtk_text_new(NULL, NULL);
|
||||
gtk_text_set_editable(GTK_TEXT(text), FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(w), text);
|
||||
|
||||
strcpy( buf, "#Supported Model Formats:\n" );
|
||||
gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buf, -1);
|
||||
|
||||
for( modules = PicoModuleList( NULL ); *modules != NULL; modules++ )
|
||||
{
|
||||
pm = *modules;
|
||||
|
||||
if( pm == NULL)
|
||||
break;
|
||||
|
||||
sprintf( buf, "\n%s, version %s, (c) %s", pm->displayName, pm->version, pm->copyright );
|
||||
gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buf, -1);
|
||||
}
|
||||
|
||||
gtk_text_set_word_wrap(GTK_TEXT(text), FALSE);
|
||||
gtk_widget_show(text);
|
||||
|
||||
gtk_text_set_point(GTK_TEXT(text), 0);
|
||||
gtk_text_forward_delete(GTK_TEXT(text), 1);
|
||||
|
||||
w = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
|
||||
gtk_widget_show (w);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 10);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 2);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
w = gtk_button_new_with_label ("Ok");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (w), "clicked",
|
||||
GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
|
||||
GTK_WIDGET_SET_FLAGS (w, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default (w);
|
||||
gtk_widget_show (w);
|
||||
ret = IDOK;
|
||||
|
||||
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
|
||||
gtk_widget_show (window);
|
||||
gtk_grab_add (window);
|
||||
|
||||
while (loop)
|
||||
gtk_main_iteration ();
|
||||
|
||||
gtk_grab_remove (window);
|
||||
gtk_widget_destroy (window);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
// toolbar implementation
|
||||
|
||||
class CFlushReloadSelectedToolbarButton : public IToolbarButton
|
||||
{
|
||||
public:
|
||||
virtual const char* getImage() const
|
||||
{
|
||||
return "model_reload_entity.bmp";
|
||||
}
|
||||
virtual const char* getText() const
|
||||
{
|
||||
return "Reload";
|
||||
}
|
||||
virtual const char* getTooltip() const
|
||||
{
|
||||
return "Flush & Reload Selected Model";
|
||||
}
|
||||
virtual void activate() const
|
||||
{
|
||||
DoFlushReloadSelected();
|
||||
}
|
||||
virtual EType getType() const
|
||||
{
|
||||
return eButton;
|
||||
}
|
||||
};
|
||||
|
||||
CFlushReloadSelectedToolbarButton g_flushreloadselected;
|
||||
|
||||
unsigned int ToolbarButtonCount()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const IToolbarButton* GetToolbarButton(unsigned int index)
|
||||
{
|
||||
return &g_flushreloadselected;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Pico utility functions
|
||||
|
||||
#include "picomodel.h"
|
||||
|
||||
void PicoPrintFunc( int level, const char *str )
|
||||
{
|
||||
if( str == NULL )
|
||||
return;
|
||||
switch( level )
|
||||
{
|
||||
case PICO_NORMAL:
|
||||
Sys_Printf( "%s\n", str );
|
||||
break;
|
||||
|
||||
case PICO_VERBOSE:
|
||||
Sys_FPrintf( SYS_VRB, "%s\n", str );
|
||||
break;
|
||||
|
||||
case PICO_WARNING:
|
||||
Sys_Printf( "WARNING: %s\n", str );
|
||||
break;
|
||||
|
||||
case PICO_ERROR:
|
||||
Sys_FPrintf( SYS_VRB, "ERROR: %s\n", str );
|
||||
break;
|
||||
|
||||
case PICO_FATAL:
|
||||
Sys_Printf( "ERROR: %s\n", str );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PicoLoadFileFunc( char *name, byte **buffer, int *bufSize )
|
||||
{
|
||||
*bufSize = vfsLoadFile( (const char*) name, (void**) buffer, 0 );
|
||||
}
|
||||
|
||||
void PicoFreeFileFunc( void* file )
|
||||
{
|
||||
vfsFreeFile(file);
|
||||
}
|
||||
|
||||
static void initialise()
|
||||
{
|
||||
PicoInit();
|
||||
PicoSetMallocFunc( malloc );
|
||||
PicoSetFreeFunc( free );
|
||||
PicoSetPrintFunc( PicoPrintFunc );
|
||||
PicoSetLoadFileFunc( PicoLoadFileFunc );
|
||||
PicoSetFreeFileFunc( PicoFreeFileFunc );
|
||||
}
|
||||
|
||||
static void add_model_apis(CSynapseClient& client)
|
||||
{
|
||||
const picoModule_t** modules = PicoModuleList( NULL );
|
||||
while(*modules != NULL)
|
||||
{
|
||||
const picoModule_t* module = *modules++;
|
||||
if(module->canload && module->load)
|
||||
for(unsigned int j = 0; module->defaultExts[j] != NULL; j++)
|
||||
client.AddAPI(MODEL_MAJOR, module->defaultExts[j], sizeof(_QERPlugModelTable));
|
||||
}
|
||||
}
|
||||
|
||||
static bool model_is_supported(const char* extension)
|
||||
{
|
||||
const picoModule_t** modules = PicoModuleList( NULL );
|
||||
while(*modules != NULL)
|
||||
{
|
||||
const picoModule_t* module = *modules++;
|
||||
if(module->canload && module->load)
|
||||
for(unsigned int j = 0; module->defaultExts[j] != NULL; j++)
|
||||
if(strcmp(extension, module->defaultExts[j]) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void init_filetypes()
|
||||
{
|
||||
const picoModule_t **modules = PicoModuleList(NULL);
|
||||
while(*modules != NULL)
|
||||
{
|
||||
const picoModule_t* module = *modules++;
|
||||
if(module->canload && module->load)
|
||||
{
|
||||
for(char*const* ext = module->defaultExts; *ext != NULL; ++ext)
|
||||
{
|
||||
char buf[16];
|
||||
buf[0] = '*';
|
||||
buf[1] = '.';
|
||||
strcpy(buf+2, *ext);
|
||||
GetFileTypeRegistry()->addType(MODEL_MAJOR, filetype_t(module->displayName, buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// plugin implementation
|
||||
|
||||
static const char *PLUGIN_NAME = "Model loading module";
|
||||
static const char *PLUGIN_COMMANDS = "Flush & Reload Models,Flush & Reload Selected";
|
||||
static const char *PLUGIN_ABOUT = "Model loading module";
|
||||
|
||||
extern "C" const char* QERPlug_Init (void *hApp, void* pMainWidget)
|
||||
{
|
||||
init_filetypes();
|
||||
return (char *) PLUGIN_NAME;
|
||||
}
|
||||
|
||||
extern "C" const char* QERPlug_GetName ()
|
||||
{
|
||||
return (char *) PLUGIN_NAME;
|
||||
}
|
||||
|
||||
extern "C" const char* QERPlug_GetCommandList ()
|
||||
{
|
||||
return (char *) PLUGIN_COMMANDS;
|
||||
}
|
||||
|
||||
extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush)
|
||||
{
|
||||
if( !strcmp( p, "Flush & Reload Selected" ) )
|
||||
DoFlushReloadSelected();
|
||||
else if( !strcmp( p, "Flush & Reload Models" ) )
|
||||
DoFlushReloadAll();
|
||||
}
|
||||
|
||||
|
||||
void DoFlushReloadSelected() {
|
||||
}
|
||||
|
||||
void DoFlushReloadAll() {
|
||||
GetModelCache()->RefreshAll();
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
// function tables
|
||||
_QERFuncTable_1 g_FuncTable;
|
||||
_QERQglTable g_QglTable;
|
||||
_QERShadersTable g_ShadersTable;
|
||||
_QERFileSystemTable g_FileSystemTable;
|
||||
|
||||
// =============================================================================
|
||||
// SYNAPSE
|
||||
|
||||
CSynapseServer* g_pSynapseServer = NULL;
|
||||
CSynapseClientModel g_SynapseClient;
|
||||
|
||||
static const XMLConfigEntry_t entries[] =
|
||||
{ { SHADERS_MAJOR, SYN_REQUIRE, sizeof(g_ShadersTable), &g_ShadersTable },
|
||||
{ VFS_MAJOR, SYN_REQUIRE, sizeof(g_FileSystemTable), &g_FileSystemTable },
|
||||
{ NULL, SYN_UNKNOWN, 0, NULL } };
|
||||
|
||||
extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
|
||||
{
|
||||
if (strcmp(version, SYNAPSE_VERSION))
|
||||
{
|
||||
Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
|
||||
return NULL;
|
||||
}
|
||||
g_pSynapseServer = pServer;
|
||||
g_pSynapseServer->IncRef();
|
||||
Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );
|
||||
|
||||
initialise();
|
||||
|
||||
add_model_apis(g_SynapseClient);
|
||||
g_SynapseClient.AddAPI(TOOLBAR_MAJOR, "model", sizeof(_QERPlugToolbarTable));
|
||||
g_SynapseClient.AddAPI(PLUGIN_MAJOR, "model", sizeof(_QERPluginTable));
|
||||
|
||||
g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable);
|
||||
g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable);
|
||||
|
||||
if ( !g_SynapseClient.ConfigXML( pServer, NULL, entries ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &g_SynapseClient;
|
||||
}
|
||||
|
||||
bool CSynapseClientModel::RequestAPI(APIDescriptor_t *pAPI)
|
||||
{
|
||||
if (!strcmp(pAPI->major_name, MODEL_MAJOR))
|
||||
{
|
||||
_QERPlugModelTable* pTable= static_cast<_QERPlugModelTable*>(pAPI->mpTable);
|
||||
|
||||
if (model_is_supported(pAPI->minor_name))
|
||||
{
|
||||
pTable->m_pfnLoadModel = &LoadModel;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR))
|
||||
{
|
||||
_QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);
|
||||
|
||||
pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
|
||||
pTable->m_pfnGetToolbarButton = &GetToolbarButton;
|
||||
return true;
|
||||
}
|
||||
else if (!strcmp(pAPI->major_name, PLUGIN_MAJOR))
|
||||
{
|
||||
_QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
|
||||
|
||||
pTable->m_pfnQERPlug_Init = QERPlug_Init;
|
||||
pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
|
||||
pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
|
||||
pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
|
||||
return true;
|
||||
}
|
||||
|
||||
Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "version.h"
|
||||
|
||||
const char* CSynapseClientModel::GetInfo()
|
||||
{
|
||||
return "picomodel loader module built " __DATE__ " " RADIANT_VERSION;
|
||||
}
|
||||
|
||||
const char* CSynapseClientModel::GetName()
|
||||
{
|
||||
return "model";
|
||||
}
|
||||
|
||||
@@ -1,318 +1,318 @@
|
||||
|
||||
#include "cpicomodel.h"
|
||||
#include "qertypes.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#define RADIANT_ASSERT(condition, message) if(!(condition)) { Sys_Printf("ASSERTION FAILURE: " message "\n"); } else
|
||||
|
||||
template<class key_type, class value_type>
|
||||
class cache_element
|
||||
{
|
||||
public:
|
||||
inline cache_element() : m_count(0), m_value(NULL) {}
|
||||
inline ~cache_element()
|
||||
{
|
||||
RADIANT_ASSERT(m_count == 0 , "destroyed a reference before it was released\n");
|
||||
if(m_count > 0)
|
||||
destroy();
|
||||
}
|
||||
inline value_type* capture(const key_type& key)
|
||||
{
|
||||
if(++m_count == 1)
|
||||
construct(key);
|
||||
return m_value;
|
||||
}
|
||||
inline void release()
|
||||
{
|
||||
RADIANT_ASSERT(!empty(), "failed to release reference - not found in cache\n");
|
||||
if(--m_count == 0)
|
||||
destroy();
|
||||
}
|
||||
inline bool empty()
|
||||
{
|
||||
return m_count == 0;
|
||||
}
|
||||
inline void refresh(const key_type& key)
|
||||
{
|
||||
m_value->refresh(key);
|
||||
}
|
||||
private:
|
||||
inline void construct(const key_type& key)
|
||||
{
|
||||
m_value = new value_type(key);
|
||||
}
|
||||
inline void destroy()
|
||||
{
|
||||
delete m_value;
|
||||
}
|
||||
|
||||
unsigned int m_count;
|
||||
value_type* m_value;
|
||||
};
|
||||
|
||||
class ModelCache
|
||||
{
|
||||
typedef CPicoModel value_type;
|
||||
|
||||
public:
|
||||
typedef PicoModelKey key_type;
|
||||
typedef cache_element<key_type, value_type> elem_type;
|
||||
typedef map<key_type, elem_type> cache_type;
|
||||
|
||||
value_type* capture(const key_type& key)
|
||||
{
|
||||
return m_cache[key].capture(key);
|
||||
}
|
||||
void release(const key_type& key)
|
||||
{
|
||||
m_cache[key].release();
|
||||
}
|
||||
|
||||
private:
|
||||
cache_type m_cache;
|
||||
};
|
||||
|
||||
ModelCache g_model_cache;
|
||||
|
||||
|
||||
|
||||
typedef struct remap_s {
|
||||
char m_remapbuff[64+1024];
|
||||
char *original;
|
||||
char *remap;
|
||||
} remap_t;
|
||||
|
||||
class RemapWrapper : public IRender, public ISelect
|
||||
{
|
||||
unsigned int m_refcount;
|
||||
public:
|
||||
RemapWrapper(entity_interfaces_t* model, const char* name)
|
||||
: m_refcount(1)
|
||||
{
|
||||
parse_namestr(name);
|
||||
|
||||
m_model = g_model_cache.capture(ModelCache::key_type(m_name.GetBuffer(), m_frame));
|
||||
|
||||
model->pRender = this;
|
||||
model->pRender->IncRef();
|
||||
model->pEdit = NULL;
|
||||
model->pSelect = this;
|
||||
model->pSelect->IncRef();
|
||||
|
||||
construct_shaders();
|
||||
}
|
||||
virtual ~RemapWrapper()
|
||||
{
|
||||
g_model_cache.release(ModelCache::key_type(m_name.GetBuffer(), m_frame));
|
||||
|
||||
for(shaders_t::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i) {
|
||||
(*i)->DecRef();
|
||||
}
|
||||
|
||||
for(remaps_t::iterator j = m_remaps.begin(); j != m_remaps.end(); ++j)
|
||||
{
|
||||
remap_t *pRemap = (*j);
|
||||
delete pRemap;
|
||||
}
|
||||
m_remaps.clear();
|
||||
}
|
||||
virtual void IncRef()
|
||||
{
|
||||
++m_refcount;
|
||||
}
|
||||
virtual void DecRef()
|
||||
{
|
||||
if(--m_refcount == 0)
|
||||
delete this;
|
||||
}
|
||||
virtual void Draw(int state, int rflags) const
|
||||
{
|
||||
m_model->Draw(state, m_shaders, rflags);
|
||||
}
|
||||
virtual const aabb_t *GetAABB() const
|
||||
{
|
||||
return m_model->GetAABB();
|
||||
}
|
||||
virtual bool TestRay(const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
return m_model->TestRay(ray, dist);
|
||||
}
|
||||
private:
|
||||
void add_remap(const char *remap)
|
||||
{
|
||||
const char *ch;
|
||||
remap_t *pRemap;
|
||||
|
||||
ch = remap;
|
||||
|
||||
while( *ch && *ch != ';' )
|
||||
ch++;
|
||||
|
||||
if( *ch == '\0' ) {
|
||||
// bad remap
|
||||
Sys_FPrintf( SYS_WRN, "WARNING: Shader _remap key found in a model entity without a ; character\n" );
|
||||
} else {
|
||||
pRemap = new remap_t;
|
||||
|
||||
strncpy( pRemap->m_remapbuff, remap, sizeof(pRemap->m_remapbuff) );
|
||||
|
||||
pRemap->m_remapbuff[ch - remap] = '\0';
|
||||
|
||||
pRemap->original = pRemap->m_remapbuff;
|
||||
pRemap->remap = pRemap->m_remapbuff + ( ch - remap ) + 1;
|
||||
|
||||
m_remaps.push_back( pRemap );
|
||||
}
|
||||
}
|
||||
|
||||
void parse_namestr(const char *name)
|
||||
{
|
||||
const char *ptr, *s;
|
||||
char buf[1024];
|
||||
bool hasName, hasFrame;
|
||||
|
||||
hasName = hasFrame = false;
|
||||
|
||||
for( s = ptr = name; *ptr; ptr++ ) {
|
||||
if( !hasName && *ptr == ':' ) {
|
||||
// model name
|
||||
hasName = true;
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
m_name = buf;
|
||||
s = ptr + 1;
|
||||
} else if( *ptr == '?' ) {
|
||||
// model frame
|
||||
hasFrame = true;
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
m_frame = atoi(buf);
|
||||
s = ptr + 1;
|
||||
} else if( *ptr == '&' ) {
|
||||
// a remap
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
add_remap( buf );
|
||||
s = ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( !hasFrame ) {
|
||||
// model frame
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
m_frame = atoi(buf);
|
||||
} else {
|
||||
// a remap
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
add_remap( buf );
|
||||
}
|
||||
}
|
||||
|
||||
void construct_shaders()
|
||||
{
|
||||
IShader* global_shader = shader_for_remap("*");
|
||||
|
||||
unsigned int numSurfaces = m_model->GetNumSurfaces();
|
||||
m_shaders.reserve(numSurfaces);
|
||||
// now go through our surface and find our shaders, remap if needed
|
||||
for(unsigned int j = 0; j < numSurfaces; j++ )
|
||||
{
|
||||
const char* surfShaderName = m_model->GetShaderNameForSurface(j);
|
||||
IShader* shader = shader_for_remap(surfShaderName);
|
||||
// m_shaders.push_back((shader) ? shader : (global_shader) ? global_shader : QERApp_Shader_ForName(surfShaderName));
|
||||
if( shader ) {
|
||||
m_shaders.push_back(shader);
|
||||
} else if( global_shader ) {
|
||||
m_shaders.push_back(global_shader);
|
||||
} else {
|
||||
m_shaders.push_back(QERApp_Shader_ForName(surfShaderName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline IShader* shader_for_remap(const char* remap)
|
||||
{
|
||||
remap_t *pRemap;
|
||||
remaps_t::iterator i;
|
||||
for(i = m_remaps.begin(); i != m_remaps.end(); ++i)
|
||||
{
|
||||
pRemap = (*i);
|
||||
if( stricmp( remap, pRemap->original ) == 0 )
|
||||
break;
|
||||
}
|
||||
return (i != m_remaps.end()) ? QERApp_Shader_ForName(pRemap->remap) : NULL;
|
||||
}
|
||||
|
||||
Str m_name;
|
||||
int m_frame;
|
||||
CPicoModel* m_model;
|
||||
|
||||
typedef vector<remap_t *> remaps_t;
|
||||
remaps_t m_remaps;
|
||||
typedef vector<IShader*> shaders_t;
|
||||
shaders_t m_shaders;
|
||||
};
|
||||
|
||||
class ModelWrapper : public IRender, public ISelect
|
||||
{
|
||||
unsigned int m_refcount;
|
||||
public:
|
||||
ModelWrapper(entity_interfaces_t* model, const char* name)
|
||||
: m_refcount(1), m_name(name)
|
||||
{
|
||||
m_model = g_model_cache.capture(ModelCache::key_type(m_name.GetBuffer(), 0));
|
||||
|
||||
model->pRender = this;
|
||||
model->pRender->IncRef();
|
||||
model->pEdit = NULL;
|
||||
model->pSelect = this;
|
||||
model->pSelect->IncRef();
|
||||
}
|
||||
virtual ~ModelWrapper()
|
||||
{
|
||||
g_model_cache.release(ModelCache::key_type(m_name.GetBuffer(), 0));
|
||||
}
|
||||
|
||||
virtual void IncRef()
|
||||
{
|
||||
++m_refcount;
|
||||
}
|
||||
virtual void DecRef()
|
||||
{
|
||||
if(--m_refcount == 0)
|
||||
delete this;
|
||||
}
|
||||
virtual void Draw(int state, int rflags) const
|
||||
{
|
||||
m_model->Draw(state, rflags);
|
||||
}
|
||||
virtual const aabb_t *GetAABB() const
|
||||
{
|
||||
return m_model->GetAABB();
|
||||
}
|
||||
virtual bool TestRay(const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
return m_model->TestRay(ray, dist);
|
||||
}
|
||||
|
||||
Str m_name;
|
||||
CPicoModel* m_model;
|
||||
};
|
||||
|
||||
void LoadModel(entity_interfaces_t* model, const char* name)
|
||||
{
|
||||
if(strchr(name, ':') != NULL || strchr(name, '?') != NULL || strchr(name, '&') != NULL)
|
||||
{
|
||||
RemapWrapper* wrapper = new RemapWrapper(model, name);
|
||||
wrapper->DecRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelWrapper* wrapper = new ModelWrapper(model, name);
|
||||
wrapper->DecRef();
|
||||
}
|
||||
}
|
||||
|
||||
#include "cpicomodel.h"
|
||||
#include "qertypes.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#define RADIANT_ASSERT(condition, message) if(!(condition)) { Sys_Printf("ASSERTION FAILURE: " message "\n"); } else
|
||||
|
||||
template<class key_type, class value_type>
|
||||
class cache_element
|
||||
{
|
||||
public:
|
||||
inline cache_element() : m_count(0), m_value(NULL) {}
|
||||
inline ~cache_element()
|
||||
{
|
||||
RADIANT_ASSERT(m_count == 0 , "destroyed a reference before it was released\n");
|
||||
if(m_count > 0)
|
||||
destroy();
|
||||
}
|
||||
inline value_type* capture(const key_type& key)
|
||||
{
|
||||
if(++m_count == 1)
|
||||
construct(key);
|
||||
return m_value;
|
||||
}
|
||||
inline void release()
|
||||
{
|
||||
RADIANT_ASSERT(!empty(), "failed to release reference - not found in cache\n");
|
||||
if(--m_count == 0)
|
||||
destroy();
|
||||
}
|
||||
inline bool empty()
|
||||
{
|
||||
return m_count == 0;
|
||||
}
|
||||
inline void refresh(const key_type& key)
|
||||
{
|
||||
m_value->refresh(key);
|
||||
}
|
||||
private:
|
||||
inline void construct(const key_type& key)
|
||||
{
|
||||
m_value = new value_type(key);
|
||||
}
|
||||
inline void destroy()
|
||||
{
|
||||
delete m_value;
|
||||
}
|
||||
|
||||
unsigned int m_count;
|
||||
value_type* m_value;
|
||||
};
|
||||
|
||||
class ModelCache
|
||||
{
|
||||
typedef CPicoModel value_type;
|
||||
|
||||
public:
|
||||
typedef PicoModelKey key_type;
|
||||
typedef cache_element<key_type, value_type> elem_type;
|
||||
typedef map<key_type, elem_type> cache_type;
|
||||
|
||||
value_type* capture(const key_type& key)
|
||||
{
|
||||
return m_cache[key].capture(key);
|
||||
}
|
||||
void release(const key_type& key)
|
||||
{
|
||||
m_cache[key].release();
|
||||
}
|
||||
|
||||
private:
|
||||
cache_type m_cache;
|
||||
};
|
||||
|
||||
ModelCache g_model_cache;
|
||||
|
||||
|
||||
|
||||
typedef struct remap_s {
|
||||
char m_remapbuff[64+1024];
|
||||
char *original;
|
||||
char *remap;
|
||||
} remap_t;
|
||||
|
||||
class RemapWrapper : public IRender, public ISelect
|
||||
{
|
||||
unsigned int m_refcount;
|
||||
public:
|
||||
RemapWrapper(entity_interfaces_t* model, const char* name)
|
||||
: m_refcount(1)
|
||||
{
|
||||
parse_namestr(name);
|
||||
|
||||
m_model = g_model_cache.capture(ModelCache::key_type(m_name.GetBuffer(), m_frame));
|
||||
|
||||
model->pRender = this;
|
||||
model->pRender->IncRef();
|
||||
model->pEdit = NULL;
|
||||
model->pSelect = this;
|
||||
model->pSelect->IncRef();
|
||||
|
||||
construct_shaders();
|
||||
}
|
||||
virtual ~RemapWrapper()
|
||||
{
|
||||
g_model_cache.release(ModelCache::key_type(m_name.GetBuffer(), m_frame));
|
||||
|
||||
for(shaders_t::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i) {
|
||||
(*i)->DecRef();
|
||||
}
|
||||
|
||||
for(remaps_t::iterator j = m_remaps.begin(); j != m_remaps.end(); ++j)
|
||||
{
|
||||
remap_t *pRemap = (*j);
|
||||
delete pRemap;
|
||||
}
|
||||
m_remaps.clear();
|
||||
}
|
||||
virtual void IncRef()
|
||||
{
|
||||
++m_refcount;
|
||||
}
|
||||
virtual void DecRef()
|
||||
{
|
||||
if(--m_refcount == 0)
|
||||
delete this;
|
||||
}
|
||||
virtual void Draw(int state, int rflags) const
|
||||
{
|
||||
m_model->Draw(state, m_shaders, rflags);
|
||||
}
|
||||
virtual const aabb_t *GetAABB() const
|
||||
{
|
||||
return m_model->GetAABB();
|
||||
}
|
||||
virtual bool TestRay(const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
return m_model->TestRay(ray, dist);
|
||||
}
|
||||
private:
|
||||
void add_remap(const char *remap)
|
||||
{
|
||||
const char *ch;
|
||||
remap_t *pRemap;
|
||||
|
||||
ch = remap;
|
||||
|
||||
while( *ch && *ch != ';' )
|
||||
ch++;
|
||||
|
||||
if( *ch == '\0' ) {
|
||||
// bad remap
|
||||
Sys_FPrintf( SYS_WRN, "WARNING: Shader _remap key found in a model entity without a ; character\n" );
|
||||
} else {
|
||||
pRemap = new remap_t;
|
||||
|
||||
strncpy( pRemap->m_remapbuff, remap, sizeof(pRemap->m_remapbuff) );
|
||||
|
||||
pRemap->m_remapbuff[ch - remap] = '\0';
|
||||
|
||||
pRemap->original = pRemap->m_remapbuff;
|
||||
pRemap->remap = pRemap->m_remapbuff + ( ch - remap ) + 1;
|
||||
|
||||
m_remaps.push_back( pRemap );
|
||||
}
|
||||
}
|
||||
|
||||
void parse_namestr(const char *name)
|
||||
{
|
||||
const char *ptr, *s;
|
||||
char buf[1024];
|
||||
bool hasName, hasFrame;
|
||||
|
||||
hasName = hasFrame = false;
|
||||
|
||||
for( s = ptr = name; *ptr; ptr++ ) {
|
||||
if( !hasName && *ptr == ':' ) {
|
||||
// model name
|
||||
hasName = true;
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
m_name = buf;
|
||||
s = ptr + 1;
|
||||
} else if( *ptr == '?' ) {
|
||||
// model frame
|
||||
hasFrame = true;
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
m_frame = atoi(buf);
|
||||
s = ptr + 1;
|
||||
} else if( *ptr == '&' ) {
|
||||
// a remap
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
add_remap( buf );
|
||||
s = ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( !hasFrame ) {
|
||||
// model frame
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
m_frame = atoi(buf);
|
||||
} else {
|
||||
// a remap
|
||||
strncpy( buf, s, ptr - s );
|
||||
buf[ptr - s] = '\0';
|
||||
add_remap( buf );
|
||||
}
|
||||
}
|
||||
|
||||
void construct_shaders()
|
||||
{
|
||||
IShader* global_shader = shader_for_remap("*");
|
||||
|
||||
unsigned int numSurfaces = m_model->GetNumSurfaces();
|
||||
m_shaders.reserve(numSurfaces);
|
||||
// now go through our surface and find our shaders, remap if needed
|
||||
for(unsigned int j = 0; j < numSurfaces; j++ )
|
||||
{
|
||||
const char* surfShaderName = m_model->GetShaderNameForSurface(j);
|
||||
IShader* shader = shader_for_remap(surfShaderName);
|
||||
// m_shaders.push_back((shader) ? shader : (global_shader) ? global_shader : QERApp_Shader_ForName(surfShaderName));
|
||||
if( shader ) {
|
||||
m_shaders.push_back(shader);
|
||||
} else if( global_shader ) {
|
||||
m_shaders.push_back(global_shader);
|
||||
} else {
|
||||
m_shaders.push_back(QERApp_Shader_ForName(surfShaderName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline IShader* shader_for_remap(const char* remap)
|
||||
{
|
||||
remap_t *pRemap;
|
||||
remaps_t::iterator i;
|
||||
for(i = m_remaps.begin(); i != m_remaps.end(); ++i)
|
||||
{
|
||||
pRemap = (*i);
|
||||
if( stricmp( remap, pRemap->original ) == 0 )
|
||||
break;
|
||||
}
|
||||
return (i != m_remaps.end()) ? QERApp_Shader_ForName(pRemap->remap) : NULL;
|
||||
}
|
||||
|
||||
Str m_name;
|
||||
int m_frame;
|
||||
CPicoModel* m_model;
|
||||
|
||||
typedef vector<remap_t *> remaps_t;
|
||||
remaps_t m_remaps;
|
||||
typedef vector<IShader*> shaders_t;
|
||||
shaders_t m_shaders;
|
||||
};
|
||||
|
||||
class ModelWrapper : public IRender, public ISelect
|
||||
{
|
||||
unsigned int m_refcount;
|
||||
public:
|
||||
ModelWrapper(entity_interfaces_t* model, const char* name)
|
||||
: m_refcount(1), m_name(name)
|
||||
{
|
||||
m_model = g_model_cache.capture(ModelCache::key_type(m_name.GetBuffer(), 0));
|
||||
|
||||
model->pRender = this;
|
||||
model->pRender->IncRef();
|
||||
model->pEdit = NULL;
|
||||
model->pSelect = this;
|
||||
model->pSelect->IncRef();
|
||||
}
|
||||
virtual ~ModelWrapper()
|
||||
{
|
||||
g_model_cache.release(ModelCache::key_type(m_name.GetBuffer(), 0));
|
||||
}
|
||||
|
||||
virtual void IncRef()
|
||||
{
|
||||
++m_refcount;
|
||||
}
|
||||
virtual void DecRef()
|
||||
{
|
||||
if(--m_refcount == 0)
|
||||
delete this;
|
||||
}
|
||||
virtual void Draw(int state, int rflags) const
|
||||
{
|
||||
m_model->Draw(state, rflags);
|
||||
}
|
||||
virtual const aabb_t *GetAABB() const
|
||||
{
|
||||
return m_model->GetAABB();
|
||||
}
|
||||
virtual bool TestRay(const ray_t *ray, vec_t *dist) const
|
||||
{
|
||||
return m_model->TestRay(ray, dist);
|
||||
}
|
||||
|
||||
Str m_name;
|
||||
CPicoModel* m_model;
|
||||
};
|
||||
|
||||
void LoadModel(entity_interfaces_t* model, const char* name)
|
||||
{
|
||||
if(strchr(name, ':') != NULL || strchr(name, '?') != NULL || strchr(name, '&') != NULL)
|
||||
{
|
||||
RemapWrapper* wrapper = new RemapWrapper(model, name);
|
||||
wrapper->DecRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelWrapper* wrapper = new ModelWrapper(model, name);
|
||||
wrapper->DecRef();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user