this should fix the texture repeat problem on some files

This commit is contained in:
Asad M. Zaman 2003-12-23 21:28:37 +00:00
parent 569758a0f6
commit 208cb7aa8d
4 changed files with 30 additions and 20 deletions

View File

@ -675,6 +675,8 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) {
uOffset = new float[numTri];
vOffset = new float[numTri];
texNameArray = new char *[numTri];
uRepeat = new int[numTri];
vRepeat = new int[numTri];
// ASSUME only one texture per material
textures = new SAA_Elem[numTri];
@ -686,6 +688,8 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) {
// initialize the array value
texNameArray[i] = NULL;
// initialize the repeats
uRepeat[i] = vRepeat[i] = 0;
// see if this triangle has texture info
if (numTexTri[i] == 0)
@ -718,8 +722,8 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) {
softegg_cat.spam() << "tritex[" << i << "] uScale: " << uScale[i] << " vScale: " << vScale[i] << endl;
softegg_cat.spam() << " uOffset: " << uOffset[i] << " vOffset: " << vOffset[i] << endl;
SAA_texture2DGetRepeats( scene, &textures[i], &uRepeat, &vRepeat );
softegg_cat.spam() << "uRepeat = " << uRepeat << ", vRepeat = " << vRepeat << endl;
SAA_texture2DGetRepeats( scene, &textures[i], &uRepeat[i], &vRepeat[i] );
softegg_cat.spam() << "uRepeat = " << uRepeat[i] << ", vRepeat = " << vRepeat[i] << endl;
}
else {
softegg_cat.spam() << "Invalid texture...\n";
@ -749,6 +753,9 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) {
// panda can now read the .pic files.
texNameArray = new char *[1];
*texNameArray = stec.GetTextureName(scene, textures);
uRepeat = new int;
vRepeat = new int;
softegg_cat.spam() << " global tex named: " << *texNameArray << endl;
@ -766,8 +773,8 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) {
softegg_cat.spam() << " global tex uScale: " << *uScale << " vScale: " << *vScale << endl;
softegg_cat.spam() << " uOffset: " << *uOffset << " vOffset: " << *vOffset << endl;
SAA_texture2DGetRepeats( scene, textures, &uRepeat, &vRepeat );
softegg_cat.spam() << "uRepeat = " << uRepeat << ", vRepeat = " << vRepeat << endl;
SAA_texture2DGetRepeats( scene, textures, uRepeat, vRepeat );
softegg_cat.spam() << "uRepeat = " << *uRepeat << ", vRepeat = " << *vRepeat << endl;
}
else {
softegg_cat.spam() << "Invalid Texture...\n";
@ -863,6 +870,8 @@ load_nurbs_model(SAA_Scene *scene, SAA_ModelType type) {
vScale = new float;
uOffset = new float;
vOffset = new float;
uRepeat = new int;
vRepeat = new int;
// check to see if texture is present
result = SAA_elementIsValid( scene, &textures[0], &valid );
@ -883,16 +892,16 @@ load_nurbs_model(SAA_Scene *scene, SAA_ModelType type) {
if ( uv_swap == TRUE )
softegg_cat.spam() << " swapping u and v...\n" ;
SAA_texture2DGetUScale( scene, &textures[0], &uScale[0] );
SAA_texture2DGetVScale( scene, &textures[0], &vScale[0] );
SAA_texture2DGetUOffset( scene, &textures[0], &uOffset[0] );
SAA_texture2DGetVOffset( scene, &textures[0], &vOffset[0] );
SAA_texture2DGetUScale( scene, &textures[0], uScale );
SAA_texture2DGetVScale( scene, &textures[0], vScale );
SAA_texture2DGetUOffset( scene, &textures[0], uOffset );
SAA_texture2DGetVOffset( scene, &textures[0], vOffset );
softegg_cat.spam() << "tritex[0] uScale: " << uScale[0] << " vScale: " << vScale[0] << endl;
softegg_cat.spam() << " uOffset: " << uOffset[0] << " vOffset: " << vOffset[0] << endl;
softegg_cat.spam() << "tritex[0] uScale: " << *uScale << " vScale: " << *vScale << endl;
softegg_cat.spam() << " uOffset: " << *uOffset << " vOffset: " << *vOffset << endl;
SAA_texture2DGetRepeats( scene, &textures[0], &uRepeat, &vRepeat );
softegg_cat.spam() << "uRepeat = " << uRepeat << ", vRepeat = " << vRepeat << endl;
SAA_texture2DGetRepeats( scene, &textures[0], uRepeat, vRepeat );
softegg_cat.spam() << "uRepeat = " << *uRepeat << ", vRepeat = " << *vRepeat << endl;
}
else {
softegg_cat.spam() << "Invalid texture...\n";

View File

@ -99,7 +99,7 @@ private:
public:
char **texNameArray;
int uRepeat, vRepeat;
int *uRepeat, *vRepeat;
float matrix[4][4];
const char *fullname;

View File

@ -1211,13 +1211,13 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) {
if (node_desc->textures != NULL) {
if (node_desc->numTexLoc && node_desc->numTexTri[idx]) {
if (!strstr(node_desc->texNameArray[idx], "noIcon"))
set_shader_attributes(node_desc, *egg_poly, node_desc->texNameArray[idx]);
set_shader_attributes(node_desc, *egg_poly, idx);
else
softegg_cat.spam() << "texname :" << node_desc->texNameArray[idx] << endl;
}
else {
if (!strstr(node_desc->texNameArray[0], "noIcon"))
set_shader_attributes(node_desc, *egg_poly, node_desc->texNameArray[0]);
set_shader_attributes(node_desc, *egg_poly, 0);
else
softegg_cat.spam() << "texname :" << node_desc->texNameArray[0] << endl;
}
@ -1493,7 +1493,7 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty
// Now apply the shader.
if (node_desc->textures != NULL) {
if (!strstr(node_desc->texNameArray[0], "noIcon"))
set_shader_attributes(node_desc, *eggNurbs, node_desc->texNameArray[0]);
set_shader_attributes(node_desc, *eggNurbs, 0);
else
softegg_cat.spam() << "texname :" << node_desc->texNameArray[0] << endl;
}
@ -2017,7 +2017,8 @@ cleanup_soft_skin()
// egg primitive.
////////////////////////////////////////////////////////////////////
void SoftToEggConverter::
set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, char *texName) {
set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, int idx) {
char *texName = node_desc->texNameArray[idx];
EggTexture tex(texName, "");
Filename filename = Filename::from_os_specific(texName);
@ -2025,7 +2026,7 @@ set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, char *te
tex.set_filename(_path_replace->store_path(fullpath));
tex.set_fullpath(fullpath);
// tex.set_format(EggTexture::F_rgb);
apply_texture_properties(tex, node_desc->uRepeat, node_desc->vRepeat);
apply_texture_properties(tex, node_desc->uRepeat[idx], node_desc->vRepeat[idx]);
EggTexture *new_tex = _textures.create_unique_texture(tex, ~EggTexture::E_tref_name);
primitive.set_texture(new_tex);
@ -2045,7 +2046,7 @@ apply_texture_properties(EggTexture &tex, int uRepeat, int vRepeat) {
tex.set_magfilter(EggTexture::FT_linear);
EggTexture::WrapMode wrap_u = uRepeat > 0 ? EggTexture::WM_repeat : EggTexture::WM_clamp;
EggTexture::WrapMode wrap_v = vRepeat > 1 ? EggTexture::WM_repeat : EggTexture::WM_clamp;
EggTexture::WrapMode wrap_v = vRepeat > 0 ? EggTexture::WM_repeat : EggTexture::WM_clamp;
tex.set_wrap_u(wrap_u);
tex.set_wrap_v(wrap_v);

View File

@ -94,7 +94,7 @@ private:
void make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type);
void add_knots( vector <double> &eggKnots, double *knots, int numKnots, SAA_Boolean closed, int degree );
void set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, char *texName);
void set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, int idx);
void apply_texture_properties(EggTexture &tex, int uRepeat, int vRepeat);
bool reparent_decals(EggGroupNode *egg_parent);