Made billbord flag handled and textures with alpha channel correctly converted

This commit is contained in:
Gyedo Jeon 2009-03-25 17:37:53 +00:00
parent f0d3e65d98
commit 7134e62cfb
2 changed files with 37 additions and 11 deletions

View File

@ -10,7 +10,7 @@
linmath:c putil:c panda:m \ linmath:c putil:c panda:m \
express:c pandaexpress:m \ express:c pandaexpress:m \
dtoolutil:c dtoolbase:c prc:c dconfig:c dtoolconfig:m dtool:m pystub \ dtoolutil:c dtoolbase:c prc:c dconfig:c dtoolconfig:m dtool:m pystub \
pipeline:c interrogatedb:c pipeline:c interrogatedb:c gobj:c
#define UNIX_SYS_LIBS \ #define UNIX_SYS_LIBS \
m m

View File

@ -34,6 +34,8 @@
#include "eggVertexPool.h" #include "eggVertexPool.h"
#include "eggPolysetMaker.h" #include "eggPolysetMaker.h"
#include "eggNurbsSurface.h" #include "eggNurbsSurface.h"
#include "texture.h"
#include "texturePool.h"
#include "pre_maya_include.h" #include "pre_maya_include.h"
#include <maya/MStatus.h> #include <maya/MStatus.h>
@ -97,7 +99,7 @@ public:
MayaEggJoint *MakeJoint(EggGroup *joint, EggGroup *context); MayaEggJoint *MakeJoint(EggGroup *joint, EggGroup *context);
MayaEggGroup *FindGroup(EggGroup *group); MayaEggGroup *FindGroup(EggGroup *group);
MayaEggGroup *MakeGroup(EggGroup *group, EggGroup *context); MayaEggGroup *MakeGroup(EggGroup *group, EggGroup *context);
MayaEggTex *GetTex(const string &name, const string &fn); MayaEggTex *GetTex(EggTexture *etex);
void CreateSkinCluster(MayaEggGeom *M); void CreateSkinCluster(MayaEggGeom *M);
MayaAnim *GetAnim(EggXfmSAnim *pool); MayaAnim *GetAnim(EggXfmSAnim *pool);
@ -230,8 +232,15 @@ void MayaEggTex::AssignNames(void)
} }
} }
MayaEggTex *MayaEggLoader::GetTex(const string &name, const string &fn) MayaEggTex *MayaEggLoader::GetTex(EggTexture* etex)
{ {
string name = "";
string fn = "";
if (etex != NULL) {
name = etex->get_name();
fn = etex->get_fullpath().to_os_specific();
}
if (_tex_tab.count(fn)) { if (_tex_tab.count(fn)) {
return _tex_tab[fn]; return _tex_tab[fn];
} }
@ -283,10 +292,10 @@ MayaEggTex *MayaEggLoader::GetTex(const string &name, const string &fn)
dgmod.connect(filetex.findPlug("outColor"),shader.findPlug("color")); dgmod.connect(filetex.findPlug("outColor"),shader.findPlug("color"));
// [gjeon] to create alpha channel connection // [gjeon] to create alpha channel connection
unsigned len_fn = fn_str.length(); LoaderOptions options;
if ((len_fn > 5) && (fn_str.toLowerCase().substring(len_fn - 5, len_fn-1) == ".rgba")) { PT(Texture) tex = TexturePool::load_texture(etex->get_fullpath(), 0, false, options);
if ((tex != NULL) && (tex->get_num_components() == 4))
dgmod.connect(filetex.findPlug("outTransparency"),shader.findPlug("transparency")); dgmod.connect(filetex.findPlug("outTransparency"),shader.findPlug("transparency"));
}
} }
status = dgmod.doIt(); status = dgmod.doIt();
if (status != MStatus::kSuccess) { if (status != MStatus::kSuccess) {
@ -1352,11 +1361,14 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del
if (poly->has_texture()) { if (poly->has_texture()) {
EggTexture *etex = poly->get_texture(0); EggTexture *etex = poly->get_texture(0);
tex = GetTex(etex->get_name(), etex->get_fullpath().to_os_specific()); if (mayaloader_cat.is_spam()) {
mayaloader_cat.spam() << "Texture format : " << etex->get_format() << endl;
}
tex = GetTex(etex);
if (etex->has_transform()) if (etex->has_transform())
uvtrans = etex->get_transform2d(); uvtrans = etex->get_transform2d();
} else { } else {
tex = GetTex("",""); tex = GetTex(NULL);
} }
EggPolygon::const_iterator ci; EggPolygon::const_iterator ci;
@ -1411,7 +1423,21 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del
if (context->get_model_flag()) { if (context->get_model_flag()) {
mesh->AddEggFlag("model"); mesh->AddEggFlag("model");
} }
// [gjeon] to handle billboard flag
switch (context->get_billboard_type()) {
case EggGroup::BT_axis:
mesh->AddEggFlag("billboard");
break;
case EggGroup::BT_point_camera_relative:
mesh->AddEggFlag("billboard-point");
break;
default:
;
}
// [gjeon] to handle other flags // [gjeon] to handle other flags
for (int i = 0; i < context->get_num_object_types(); i++) { for (int i = 0; i < context->get_num_object_types(); i++) {
mesh->AddEggFlag(MString(context->get_object_type(i).c_str())); mesh->AddEggFlag(MString(context->get_object_type(i).c_str()));
@ -1436,14 +1462,14 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del
if (eggNurbsSurface->has_texture()) { if (eggNurbsSurface->has_texture()) {
EggTexture *etex = eggNurbsSurface->get_texture(0); EggTexture *etex = eggNurbsSurface->get_texture(0);
tex = GetTex(etex->get_name(), etex->get_fullpath().to_os_specific()); tex = GetTex(etex);
if (etex->has_transform()) if (etex->has_transform())
{ {
mayaloader_cat.debug() << "uvtrans?" << endl; mayaloader_cat.debug() << "uvtrans?" << endl;
uvtrans = etex->get_transform2d(); uvtrans = etex->get_transform2d();
} }
} else { } else {
tex = GetTex("",""); tex = GetTex(NULL);
} }
surface->_tex = tex; surface->_tex = tex;