mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
added eggRename tool support
This commit is contained in:
parent
7cb711d9bc
commit
cb673496b5
@ -271,7 +271,7 @@ prepare_texture(Texture *) {
|
||||
// the given texture.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
apply_texture(TextureContext *) {
|
||||
apply_texture(TextureContext *, int index) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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; 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);
|
||||
apply_texture(tc);
|
||||
TextureContext *tc = tex->prepare_now(_prepared_objects, this);
|
||||
apply_texture(tc, 1-i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
// Access: Published
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user