added eggRename tool support

This commit is contained in:
Asad M. Zaman 2005-04-27 18:26:12 +00:00
parent 7cb711d9bc
commit cb673496b5
10 changed files with 66 additions and 16 deletions

View File

@ -271,7 +271,7 @@ prepare_texture(Texture *) {
// the given texture. // the given texture.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian:: void GraphicsStateGuardian::
apply_texture(TextureContext *) { apply_texture(TextureContext *, int index) {
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -107,7 +107,7 @@ public:
virtual PreparedGraphicsObjects *get_prepared_objects(); virtual PreparedGraphicsObjects *get_prepared_objects();
virtual TextureContext *prepare_texture(Texture *tex); virtual TextureContext *prepare_texture(Texture *tex);
virtual void apply_texture(TextureContext *tc); virtual void apply_texture(TextureContext *tc, int index=0);
virtual void release_texture(TextureContext *tc); virtual void release_texture(TextureContext *tc);
virtual GeomContext *prepare_geom(Geom *geom); virtual GeomContext *prepare_geom(Geom *geom);

View File

@ -159,7 +159,7 @@ make_current(void) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool wdxGraphicsWindow7:: bool wdxGraphicsWindow7::
open_window(void) { open_window(void) {
if (!choose_device(0, NULL)) { if (!choose_device(0, NULL)) {
wdxdisplay7_cat.error() << "Unable to find suitable rendering device.\n"; wdxdisplay7_cat.error() << "Unable to find suitable rendering device.\n";
return false; return false;

View File

@ -2586,7 +2586,7 @@ prepare_texture(Texture *tex) {
// rendering. // rendering.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void DXGraphicsStateGuardian9:: void DXGraphicsStateGuardian9::
apply_texture(TextureContext *tc) { apply_texture(TextureContext *tc, int index) {
if (tc==NULL) { if (tc==NULL) {
// The texture wasn't bound properly or something, so ensure // The texture wasn't bound properly or something, so ensure
// texturing is disabled and just return. // texturing is disabled and just return.
@ -2738,11 +2738,12 @@ apply_texture(TextureContext *tc) {
// bugbug: does this handle the case of untextured geometry? // bugbug: does this handle the case of untextured geometry?
// we dont see this bug cause we never mix textured/untextured // we dont see this bug cause we never mix textured/untextured
_pD3DDevice->SetTexture(0,dtc->_pD3DTexture9); _pD3DDevice->SetTexture(index, dtc->_pD3DTexture9);
#if 0 #if 1
if (dtc!=NULL) { if (dtc!=NULL) {
dxgsg9_cat.spam() << "Setting active DX texture: " << dtc->_tex->get_name() << "\n"; dxgsg9_cat.info() << "Setting active DX texture " << index << " : "
<< dtc->_tex->get_name() << "\n";
} }
#endif #endif
@ -2983,11 +2984,13 @@ void DXGraphicsStateGuardian9::SetTextureBlendMode(TextureApplyAttrib::Mode TexB
{D3DTOP_MODULATE,D3DTOP_BLENDTEXTUREALPHA,D3DTOP_MODULATE,D3DTOP_SELECTARG1,D3DTOP_ADD}; {D3DTOP_MODULATE,D3DTOP_BLENDTEXTUREALPHA,D3DTOP_MODULATE,D3DTOP_SELECTARG1,D3DTOP_ADD};
//if bCanJustEnable, then we only need to make sure ColorOp is turned on and set properly //if bCanJustEnable, then we only need to make sure ColorOp is turned on and set properly
/*
if (bCanJustEnable && (TexBlendMode==_CurTexBlendMode)) { if (bCanJustEnable && (TexBlendMode==_CurTexBlendMode)) {
// just reset COLOROP 0 to enable pipeline, rest is already set properly // just reset COLOROP 0 to enable pipeline, rest is already set properly
_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, TexBlendColorOp1[TexBlendMode] ); _pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, TexBlendColorOp1[TexBlendMode] );
return; return;
} }
*/
_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, TexBlendColorOp1[TexBlendMode] ); _pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, TexBlendColorOp1[TexBlendMode] );
@ -2996,12 +2999,23 @@ void DXGraphicsStateGuardian9::SetTextureBlendMode(TextureApplyAttrib::Mode TexB
case TextureApplyAttrib::M_modulate: case TextureApplyAttrib::M_modulate:
// emulates GL_MODULATE glTexEnv mode // emulates GL_MODULATE glTexEnv mode
// want to multiply tex-color*pixel color to emulate GL modulate blend (see glTexEnv) // want to multiply tex-color*pixel color to emulate GL modulate blend (see glTexEnv)
/*
_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); _pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); _pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); _pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); _pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); _pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
*/
// Program Stage 0:
//_pD3DDevice->SetTexture(0, pTex0 );
_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
// Program Stage 1:
//_pD3DDevice->SetTexture(1, pTex1 );
_pD3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
_pD3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
_pD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
dxgsg9_cat.info() << "--------------modulating--------------" << endl;
break; break;
case TextureApplyAttrib::M_decal: case TextureApplyAttrib::M_decal:
// emulates GL_DECAL glTexEnv mode // emulates GL_DECAL glTexEnv mode
@ -3174,11 +3188,16 @@ issue_texture(const TextureAttrib *attrib) {
if (attrib->is_off()) { if (attrib->is_off()) {
enable_texturing(false); enable_texturing(false);
} else { } else {
Texture *tex = attrib->get_texture(); int num_stages = attrib->get_num_on_stages();
nassertv(tex != (Texture *)NULL); //dxgsg9_cat.info() << "num_on_texture: " << num_stages << endl;
for (int i=0; i<num_stages; ++i){
TextureStage *stage = attrib->get_on_stage(i);
Texture *tex = attrib->get_on_texture(stage);
nassertv(tex != (Texture *)NULL);
TextureContext *tc = tex->prepare_now(_prepared_objects, this); TextureContext *tc = tex->prepare_now(_prepared_objects, this);
apply_texture(tc); apply_texture(tc, 1-i);
}
} }
} }

View File

@ -91,7 +91,7 @@ public:
virtual void draw_sphere(GeomSphere *geom, GeomContext *gc); virtual void draw_sphere(GeomSphere *geom, GeomContext *gc);
virtual TextureContext *prepare_texture(Texture *tex); virtual TextureContext *prepare_texture(Texture *tex);
virtual void apply_texture(TextureContext *tc); virtual void apply_texture(TextureContext *tc, int index=0);
virtual void release_texture(TextureContext *tc); virtual void release_texture(TextureContext *tc);
virtual void framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr, virtual void framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,

View File

@ -766,6 +766,35 @@ mesh_triangles(int flags) {
} }
} }
////////////////////////////////////////////////////////////////////
// Function: EggGroupNode::rename_nodes
// Access: Published
// Description: Rename by stripping out the prefix
////////////////////////////////////////////////////////////////////
int EggGroupNode::
rename_nodes(vector_string strip_prefix, bool recurse) {
int num_renamed = 0;
for (unsigned int ni=0; ni<strip_prefix.size(); ++ ni) {
string axe_name = strip_prefix[ni];
if (this->get_name().find(axe_name)!= -1) {
string new_name = this->get_name().substr(axe_name.size());
//cout << "renaming " << this->get_name() << "->" << new_name << endl;
this->set_name(new_name);
num_renamed += 1;
}
}
if (recurse) {
EggGroupNode::iterator ci;
for (ci = begin(); ci != end(); ++ci) {
if ((*ci)->is_of_type(EggGroupNode::get_class_type())) {
EggGroupNode *group_child = DCAST(EggGroupNode, *ci);
num_renamed += group_child->rename_nodes(strip_prefix, recurse);
}
}
}
return num_renamed;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: EggGroupNode::remove_unused_vertices // Function: EggGroupNode::remove_unused_vertices
// Access: Published // Access: Published

View File

@ -141,6 +141,8 @@ PUBLISHED:
int triangulate_polygons(int flags); int triangulate_polygons(int flags);
void mesh_triangles(int flags); void mesh_triangles(int flags);
int rename_nodes(vector_string strip_prefix, bool recurse);
int remove_unused_vertices(bool recurse); int remove_unused_vertices(bool recurse);
int remove_invalid_primitives(bool recurse); int remove_invalid_primitives(bool recurse);
void clear_connected_shading(); void clear_connected_shading();

View File

@ -2789,7 +2789,7 @@ prepare_texture(Texture *tex) {
// rendering. // rendering.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CLP(GraphicsStateGuardian):: void CLP(GraphicsStateGuardian)::
apply_texture(TextureContext *tc) { apply_texture(TextureContext *tc, int index) {
CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc);
add_to_texture_record(gtc); add_to_texture_record(gtc);

View File

@ -108,7 +108,7 @@ public:
INLINE bool draw_display_list(GeomContext *gc); INLINE bool draw_display_list(GeomContext *gc);
virtual TextureContext *prepare_texture(Texture *tex); virtual TextureContext *prepare_texture(Texture *tex);
virtual void apply_texture(TextureContext *tc); virtual void apply_texture(TextureContext *tc, int index=0);
virtual void release_texture(TextureContext *tc); virtual void release_texture(TextureContext *tc);
virtual GeomContext *prepare_geom(Geom *geom); virtual GeomContext *prepare_geom(Geom *geom);

View File

@ -135,7 +135,7 @@ public:
virtual PreparedGraphicsObjects *get_prepared_objects()=0; virtual PreparedGraphicsObjects *get_prepared_objects()=0;
virtual TextureContext *prepare_texture(Texture *tex)=0; virtual TextureContext *prepare_texture(Texture *tex)=0;
virtual void apply_texture(TextureContext *tc)=0; virtual void apply_texture(TextureContext *tc, int index=0)=0;
virtual void release_texture(TextureContext *tc)=0; virtual void release_texture(TextureContext *tc)=0;
virtual GeomContext *prepare_geom(Geom *geom)=0; virtual GeomContext *prepare_geom(Geom *geom)=0;