diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 460d94b080..0d265a9822 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -271,7 +271,7 @@ prepare_texture(Texture *) { // the given texture. //////////////////////////////////////////////////////////////////// void GraphicsStateGuardian:: -apply_texture(TextureContext *) { +apply_texture(TextureContext *, int index) { } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index bdd9f2e3ae..e04cb855c5 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -107,7 +107,7 @@ public: virtual PreparedGraphicsObjects *get_prepared_objects(); 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 GeomContext *prepare_geom(Geom *geom); diff --git a/panda/src/dxgsg7/wdxGraphicsWindow7.cxx b/panda/src/dxgsg7/wdxGraphicsWindow7.cxx index b3615f167d..c3078122b2 100644 --- a/panda/src/dxgsg7/wdxGraphicsWindow7.cxx +++ b/panda/src/dxgsg7/wdxGraphicsWindow7.cxx @@ -159,7 +159,7 @@ make_current(void) { //////////////////////////////////////////////////////////////////// bool wdxGraphicsWindow7:: open_window(void) { - + if (!choose_device(0, NULL)) { wdxdisplay7_cat.error() << "Unable to find suitable rendering device.\n"; return false; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 8df9400ecc..94d4ec23d3 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -2586,7 +2586,7 @@ prepare_texture(Texture *tex) { // rendering. //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian9:: -apply_texture(TextureContext *tc) { +apply_texture(TextureContext *tc, int index) { if (tc==NULL) { // The texture wasn't bound properly or something, so ensure // texturing is disabled and just return. @@ -2738,11 +2738,12 @@ apply_texture(TextureContext *tc) { // bugbug: does this handle the case of untextured geometry? // 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) { - 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 @@ -2983,11 +2984,13 @@ void DXGraphicsStateGuardian9::SetTextureBlendMode(TextureApplyAttrib::Mode TexB {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 && (TexBlendMode==_CurTexBlendMode)) { // just reset COLOROP 0 to enable pipeline, rest is already set properly _pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, TexBlendColorOp1[TexBlendMode] ); return; } + */ _pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, TexBlendColorOp1[TexBlendMode] ); @@ -2996,12 +2999,23 @@ void DXGraphicsStateGuardian9::SetTextureBlendMode(TextureApplyAttrib::Mode TexB case TextureApplyAttrib::M_modulate: // emulates GL_MODULATE glTexEnv mode // 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_COLORARG2, D3DTA_DIFFUSE ); _pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); _pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); _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; case TextureApplyAttrib::M_decal: // emulates GL_DECAL glTexEnv mode @@ -3174,11 +3188,16 @@ issue_texture(const TextureAttrib *attrib) { if (attrib->is_off()) { enable_texturing(false); } else { - Texture *tex = attrib->get_texture(); - nassertv(tex != (Texture *)NULL); + int num_stages = attrib->get_num_on_stages(); + //dxgsg9_cat.info() << "num_on_texture: " << num_stages << endl; + for (int i=0; iget_on_stage(i); + Texture *tex = attrib->get_on_texture(stage); + nassertv(tex != (Texture *)NULL); - TextureContext *tc = tex->prepare_now(_prepared_objects, this); - apply_texture(tc); + TextureContext *tc = tex->prepare_now(_prepared_objects, this); + apply_texture(tc, 1-i); + } } } diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index f8758f9c83..e4c7be4316 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -91,7 +91,7 @@ public: virtual void draw_sphere(GeomSphere *geom, GeomContext *gc); 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 framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr, diff --git a/panda/src/egg/eggGroupNode.cxx b/panda/src/egg/eggGroupNode.cxx index 5f090be412..65d7d84026 100644 --- a/panda/src/egg/eggGroupNode.cxx +++ b/panda/src/egg/eggGroupNode.cxx @@ -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; niget_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 // Access: Published diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index 6efeffb26b..cb10922ded 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/panda/src/egg/eggGroupNode.h @@ -141,6 +141,8 @@ PUBLISHED: int triangulate_polygons(int flags); void mesh_triangles(int flags); + int rename_nodes(vector_string strip_prefix, bool recurse); + int remove_unused_vertices(bool recurse); int remove_invalid_primitives(bool recurse); void clear_connected_shading(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 1b66b0a064..586fa368e3 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -2789,7 +2789,7 @@ prepare_texture(Texture *tex) { // rendering. //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: -apply_texture(TextureContext *tc) { +apply_texture(TextureContext *tc, int index) { CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); add_to_texture_record(gtc); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 723e32bd5b..6ca2e5c101 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -108,7 +108,7 @@ public: INLINE bool draw_display_list(GeomContext *gc); 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 GeomContext *prepare_geom(Geom *geom); diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.h b/panda/src/gsgbase/graphicsStateGuardianBase.h index eae87eff3e..9e1f4428e4 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.h +++ b/panda/src/gsgbase/graphicsStateGuardianBase.h @@ -135,7 +135,7 @@ public: virtual PreparedGraphicsObjects *get_prepared_objects()=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 GeomContext *prepare_geom(Geom *geom)=0;