mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
Support materials in bam2egg
This commit is contained in:
parent
c0e4de3df7
commit
46ddd46c5c
@ -22,6 +22,7 @@
|
|||||||
#include "transformState.h"
|
#include "transformState.h"
|
||||||
#include "colorScaleAttrib.h"
|
#include "colorScaleAttrib.h"
|
||||||
#include "colorAttrib.h"
|
#include "colorAttrib.h"
|
||||||
|
#include "materialAttrib.h"
|
||||||
#include "textureAttrib.h"
|
#include "textureAttrib.h"
|
||||||
#include "cullFaceAttrib.h"
|
#include "cullFaceAttrib.h"
|
||||||
#include "transparencyAttrib.h"
|
#include "transparencyAttrib.h"
|
||||||
@ -577,6 +578,13 @@ convert_primitive(const GeomVertexData *vertex_data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for a material.
|
||||||
|
EggMaterial *egg_mat = (EggMaterial *)NULL;
|
||||||
|
const MaterialAttrib *ma = DCAST(MaterialAttrib, net_state->get_attrib(MaterialAttrib::get_class_type()));
|
||||||
|
if (ma != (const MaterialAttrib *)NULL) {
|
||||||
|
egg_mat = get_egg_material(ma->get_material());
|
||||||
|
}
|
||||||
|
|
||||||
// Check for a texture.
|
// Check for a texture.
|
||||||
EggTexture *egg_tex = (EggTexture *)NULL;
|
EggTexture *egg_tex = (EggTexture *)NULL;
|
||||||
const TextureAttrib *ta = DCAST(TextureAttrib, net_state->get_attrib(TextureAttrib::get_class_type()));
|
const TextureAttrib *ta = DCAST(TextureAttrib, net_state->get_attrib(TextureAttrib::get_class_type()));
|
||||||
@ -708,6 +716,10 @@ convert_primitive(const GeomVertexData *vertex_data,
|
|||||||
PT(EggPrimitive) egg_prim = (*make_func)();
|
PT(EggPrimitive) egg_prim = (*make_func)();
|
||||||
|
|
||||||
egg_parent->add_child(egg_prim);
|
egg_parent->add_child(egg_prim);
|
||||||
|
|
||||||
|
if (egg_mat != (EggMaterial *)NULL) {
|
||||||
|
egg_prim->set_material(egg_mat);
|
||||||
|
}
|
||||||
if (egg_tex != (EggTexture *)NULL) {
|
if (egg_tex != (EggTexture *)NULL) {
|
||||||
egg_prim->set_texture(egg_tex);
|
egg_prim->set_texture(egg_tex);
|
||||||
}
|
}
|
||||||
@ -947,6 +959,41 @@ apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggSaver::get_egg_material
|
||||||
|
// Access: Private
|
||||||
|
// Description: Returns an EggMaterial pointer that corresponds to
|
||||||
|
// the indicated Material.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
EggMaterial *EggSaver::
|
||||||
|
get_egg_material(Material *mat) {
|
||||||
|
if (mat != (Material *)NULL) {
|
||||||
|
EggMaterial temp(mat->get_name());
|
||||||
|
if (mat->has_ambient()) {
|
||||||
|
temp.set_amb(mat->get_ambient());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mat->has_diffuse()) {
|
||||||
|
temp.set_diff(mat->get_diffuse());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mat->has_specular()) {
|
||||||
|
temp.set_spec(mat->get_specular());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mat->has_emission()) {
|
||||||
|
temp.set_emit(mat->get_emission());
|
||||||
|
}
|
||||||
|
|
||||||
|
temp.set_shininess(mat->get_shininess());
|
||||||
|
temp.set_local(mat->get_local());
|
||||||
|
|
||||||
|
return _materials.create_unique_material(temp, ~EggMaterial::E_mref_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggSaver::get_egg_texture
|
// Function: EggSaver::get_egg_texture
|
||||||
// Access: Private
|
// Access: Private
|
||||||
|
@ -92,6 +92,7 @@ private:
|
|||||||
bool apply_tags(EggGroup *egg_group, PandaNode *node);
|
bool apply_tags(EggGroup *egg_group, PandaNode *node);
|
||||||
bool apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag);
|
bool apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag);
|
||||||
|
|
||||||
|
EggMaterial *get_egg_material(Material *tex);
|
||||||
EggTexture *get_egg_texture(Texture *tex);
|
EggTexture *get_egg_texture(Texture *tex);
|
||||||
|
|
||||||
static EggPrimitive *make_egg_polygon();
|
static EggPrimitive *make_egg_polygon();
|
||||||
@ -102,8 +103,8 @@ private:
|
|||||||
PT(EggData) _data;
|
PT(EggData) _data;
|
||||||
|
|
||||||
PT(EggVertexPool) _vpool;
|
PT(EggVertexPool) _vpool;
|
||||||
EggTextureCollection _textures;
|
|
||||||
EggMaterialCollection _materials;
|
EggMaterialCollection _materials;
|
||||||
|
EggTextureCollection _textures;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "eggSaver.I"
|
#include "eggSaver.I"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user