mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
New Egg API
This commit is contained in:
parent
35455f504b
commit
dd730b98ca
@ -643,7 +643,6 @@ bool MaxEggExpOptions::DoExport(IObjParam *ip, bool autoOverwrite, bool saveLog)
|
|||||||
char *apcParameters[64];
|
char *apcParameters[64];
|
||||||
char pszSF[10], pszEF[10];
|
char pszSF[10], pszEF[10];
|
||||||
char acOutputFilename[MAX_PATH];
|
char acOutputFilename[MAX_PATH];
|
||||||
char curFilename[MAX_PATH];
|
|
||||||
int iParameterCount=0;
|
int iParameterCount=0;
|
||||||
|
|
||||||
//Initialize our global error logger
|
//Initialize our global error logger
|
||||||
|
|||||||
@ -338,7 +338,7 @@ void Logger::WriteToPipe( char *textToPipe )
|
|||||||
case PIPE_TO_FILE:
|
case PIPE_TO_FILE:
|
||||||
if ( myFileOutputLog.is_open() )
|
if ( myFileOutputLog.is_open() )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < myHierarchyLevel; ++i )
|
for (unsigned int i = 0; i < myHierarchyLevel; ++i )
|
||||||
myFileOutputLog << " ";
|
myFileOutputLog << " ";
|
||||||
myFileOutputLog << textToPipe << endl;
|
myFileOutputLog << textToPipe << endl;
|
||||||
myFileOutputLog.flush();
|
myFileOutputLog.flush();
|
||||||
|
|||||||
@ -413,7 +413,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
EggXfmSAnim *anim = _tree.get_egg_anim(node_desc);
|
EggXfmSAnim *anim = _tree.get_egg_anim(node_desc);
|
||||||
if (!anim->add_data(tgroup->get_transform())) {
|
if (!anim->add_data(tgroup->get_transform3d())) {
|
||||||
// *** log an error
|
// *** log an error
|
||||||
}
|
}
|
||||||
delete tgroup;
|
delete tgroup;
|
||||||
@ -528,21 +528,21 @@ process_model_node(MaxNodeDesc *node_desc) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SHAPE_CLASS_ID:
|
case SHAPE_CLASS_ID:
|
||||||
if (state.obj->ClassID() == EDITABLE_SURF_CLASS_ID) {
|
if (state.obj->ClassID() == EDITABLE_SURF_CLASS_ID) {
|
||||||
Logger::Log( MTEC, Logger::SAT_HIGH_LEVEL,
|
Logger::Log( MTEC, Logger::SAT_HIGH_LEVEL,
|
||||||
"Found a NURB object in the hierarchy!" );
|
"Found a NURB object in the hierarchy!" );
|
||||||
NURBSSet getSet;
|
NURBSSet getSet;
|
||||||
if (GetNURBSSet(state.obj, time, getSet, TRUE)) {
|
if (GetNURBSSet(state.obj, time, getSet, TRUE)) {
|
||||||
NURBSObject *nObj = getSet.GetNURBSObject(0);
|
NURBSObject *nObj = getSet.GetNURBSObject(0);
|
||||||
if (nObj->GetType() == kNCVCurve) {
|
if (nObj->GetType() == kNCVCurve) {
|
||||||
//It's a CV Curve, process it
|
//It's a CV Curve, process it
|
||||||
egg_group = _tree.get_egg_group(node_desc);
|
egg_group = _tree.get_egg_group(node_desc);
|
||||||
get_transform(max_node, egg_group);
|
get_transform(max_node, egg_group);
|
||||||
make_nurbs_curve((NURBSCVCurve *)nObj, string(max_node->GetName()),
|
make_nurbs_curve((NURBSCVCurve *)nObj, string(max_node->GetName()),
|
||||||
time, egg_group);
|
time, egg_group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAMERA_CLASS_ID:
|
case CAMERA_CLASS_ID:
|
||||||
@ -781,7 +781,7 @@ get_transform(INode *max_node, EggGroup *egg_group) {
|
|||||||
// node's parent
|
// node's parent
|
||||||
m4d = m4d * egg_group->get_node_frame_inv();
|
m4d = m4d * egg_group->get_node_frame_inv();
|
||||||
if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) {
|
if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) {
|
||||||
egg_group->add_matrix(m4d);
|
egg_group->add_matrix4(m4d);
|
||||||
Logger::Log( MNEG_GEOMETRY_GENERATION, Logger::SAT_DEBUG_SPAM_LEVEL,
|
Logger::Log( MNEG_GEOMETRY_GENERATION, Logger::SAT_DEBUG_SPAM_LEVEL,
|
||||||
"Non-identity matrix applied to node!" );
|
"Non-identity matrix applied to node!" );
|
||||||
} else {
|
} else {
|
||||||
@ -877,7 +877,7 @@ get_joint_transform(INode *max_node, EggGroup *egg_group) {
|
|||||||
// node's parent
|
// node's parent
|
||||||
m4d = m4d * egg_group->get_node_frame_inv();
|
m4d = m4d * egg_group->get_node_frame_inv();
|
||||||
if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) {
|
if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) {
|
||||||
egg_group->add_matrix(m4d);
|
egg_group->add_matrix4(m4d);
|
||||||
Logger::Log( MNEG_GEOMETRY_GENERATION, Logger::SAT_DEBUG_SPAM_LEVEL,
|
Logger::Log( MNEG_GEOMETRY_GENERATION, Logger::SAT_DEBUG_SPAM_LEVEL,
|
||||||
"Non-identity matrix applied to node!" );
|
"Non-identity matrix applied to node!" );
|
||||||
} else {
|
} else {
|
||||||
@ -953,7 +953,7 @@ if (parent_node) {
|
|||||||
m4d = m4d * pi_m4d;
|
m4d = m4d * pi_m4d;
|
||||||
}
|
}
|
||||||
if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) {
|
if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) {
|
||||||
egg_group->add_matrix(m4d);
|
egg_group->add_matrix4(m4d);
|
||||||
Logger::Log( MNEG_GEOMETRY_GENERATION, Logger::SAT_DEBUG_SPAM_LEVEL,
|
Logger::Log( MNEG_GEOMETRY_GENERATION, Logger::SAT_DEBUG_SPAM_LEVEL,
|
||||||
"Non-identity matrix applied to node!" );
|
"Non-identity matrix applied to node!" );
|
||||||
} else {
|
} else {
|
||||||
@ -1600,14 +1600,14 @@ make_polyset(INode *max_node, Mesh *mesh,
|
|||||||
|
|
||||||
LVector3d realNorm = ((points[1] - points[0]).cross(
|
LVector3d realNorm = ((points[1] - points[0]).cross(
|
||||||
points[2] - points[0]));
|
points[2] - points[0]));
|
||||||
Point3 maxNormTemp = mesh->getFaceNormal(iFace);
|
Point3 maxNormTemp = mesh->getFaceNormal(iFace);
|
||||||
LVector3d maxNorm = (LVector3d(maxNormTemp.x, maxNormTemp.y, maxNormTemp.z) *
|
LVector3d maxNorm = (LVector3d(maxNormTemp.x, maxNormTemp.y, maxNormTemp.z) *
|
||||||
vertex_frame);
|
vertex_frame);
|
||||||
|
|
||||||
if (realNorm.dot(maxNorm) < 0.0) {
|
if (realNorm.dot(maxNorm) < 0.0) {
|
||||||
egg_poly->set_vertex(0, verts[2]);
|
egg_poly->set_vertex(0, verts[2]);
|
||||||
egg_poly->set_vertex(2, verts[0]);
|
egg_poly->set_vertex(2, verts[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// *** More shader stuff to ignore
|
// *** More shader stuff to ignore
|
||||||
/*
|
/*
|
||||||
@ -1745,31 +1745,31 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) {
|
|||||||
EggVertexPool::iterator vi;
|
EggVertexPool::iterator vi;
|
||||||
|
|
||||||
if (mod) {
|
if (mod) {
|
||||||
// create a physique export interface
|
// create a physique export interface
|
||||||
IPhysiqueExport *pPhysiqueExport = (IPhysiqueExport *)mod->GetInterface(I_PHYINTERFACE);
|
IPhysiqueExport *pPhysiqueExport = (IPhysiqueExport *)mod->GetInterface(I_PHYINTERFACE);
|
||||||
if (pPhysiqueExport) {
|
if (pPhysiqueExport) {
|
||||||
// create a context export interface
|
// create a context export interface
|
||||||
IPhyContextExport *pContextExport =
|
IPhyContextExport *pContextExport =
|
||||||
(IPhyContextExport *)pPhysiqueExport->GetContextInterface(max_node);
|
(IPhyContextExport *)pPhysiqueExport->GetContextInterface(max_node);
|
||||||
if (pContextExport) {
|
if (pContextExport) {
|
||||||
// set the flags in the context export interface
|
// set the flags in the context export interface
|
||||||
pContextExport->ConvertToRigid(TRUE);
|
pContextExport->ConvertToRigid(TRUE);
|
||||||
pContextExport->AllowBlending(TRUE);
|
pContextExport->AllowBlending(TRUE);
|
||||||
|
|
||||||
for (vi = vpool->begin(); vi != vpool->end(); ++vi) {
|
for (vi = vpool->begin(); vi != vpool->end(); ++vi) {
|
||||||
EggVertex *vert = (*vi);
|
EggVertex *vert = (*vi);
|
||||||
int max_vi = vert->get_external_index();
|
int max_vi = vert->get_external_index();
|
||||||
|
|
||||||
// get the vertex export interface
|
// get the vertex export interface
|
||||||
IPhyVertexExport *pVertexExport =
|
IPhyVertexExport *pVertexExport =
|
||||||
(IPhyVertexExport *)pContextExport->GetVertexInterface(max_vi);
|
(IPhyVertexExport *)pContextExport->GetVertexInterface(max_vi);
|
||||||
if (pVertexExport) {
|
if (pVertexExport) {
|
||||||
int vertexType = pVertexExport->GetVertexType();
|
int vertexType = pVertexExport->GetVertexType();
|
||||||
|
|
||||||
// handle the specific vertex type
|
// handle the specific vertex type
|
||||||
if(vertexType == RIGID_TYPE) {
|
if(vertexType == RIGID_TYPE) {
|
||||||
// typecast to rigid vertex
|
// typecast to rigid vertex
|
||||||
IPhyRigidVertex *pTypeVertex = (IPhyRigidVertex *)pVertexExport;
|
IPhyRigidVertex *pTypeVertex = (IPhyRigidVertex *)pVertexExport;
|
||||||
INode *bone_node = pTypeVertex->GetNode();
|
INode *bone_node = pTypeVertex->GetNode();
|
||||||
MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node);
|
MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node);
|
||||||
if (joint_node_desc){
|
if (joint_node_desc){
|
||||||
@ -1780,10 +1780,10 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) {
|
|||||||
Logger::Log( MTEC, Logger::SAT_MEDIUM_LEVEL, bone_node->GetName() );
|
Logger::Log( MTEC, Logger::SAT_MEDIUM_LEVEL, bone_node->GetName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(vertexType == RIGID_BLENDED_TYPE) {
|
else if(vertexType == RIGID_BLENDED_TYPE) {
|
||||||
// typecast to blended vertex
|
// typecast to blended vertex
|
||||||
IPhyBlendedRigidVertex *pTypeVertex = (IPhyBlendedRigidVertex *)pVertexExport;
|
IPhyBlendedRigidVertex *pTypeVertex = (IPhyBlendedRigidVertex *)pVertexExport;
|
||||||
|
|
||||||
for (int ji = 0; ji < pTypeVertex->GetNumberNodes(); ++ji) {
|
for (int ji = 0; ji < pTypeVertex->GetNumberNodes(); ++ji) {
|
||||||
float weight = pTypeVertex->GetWeight(ji);
|
float weight = pTypeVertex->GetWeight(ji);
|
||||||
if (weight > 0.0f) {
|
if (weight > 0.0f) {
|
||||||
@ -1804,11 +1804,11 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Release the context interface
|
//Release the context interface
|
||||||
pPhysiqueExport->ReleaseContextInterface(pContextExport);
|
pPhysiqueExport->ReleaseContextInterface(pContextExport);
|
||||||
}
|
}
|
||||||
//Release the physique export interface
|
//Release the physique export interface
|
||||||
mod->ReleaseInterface(I_PHYINTERFACE, pPhysiqueExport);
|
mod->ReleaseInterface(I_PHYINTERFACE, pPhysiqueExport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//No physique, try to find a skin
|
//No physique, try to find a skin
|
||||||
|
|||||||
@ -172,7 +172,7 @@ MaxEggJoint *MaxEggLoader::MakeJoint(EggGroup *joint, EggGroup *context)
|
|||||||
{
|
{
|
||||||
MaxEggJoint *parent = FindJoint(context);
|
MaxEggJoint *parent = FindJoint(context);
|
||||||
MaxEggJoint *result = new MaxEggJoint;
|
MaxEggJoint *result = new MaxEggJoint;
|
||||||
LMatrix4d t = joint->get_transform();
|
LMatrix4d t = joint->get_transform3d();
|
||||||
if (parent) {
|
if (parent) {
|
||||||
result->_trans = t * parent->_trans;
|
result->_trans = t * parent->_trans;
|
||||||
} else {
|
} else {
|
||||||
@ -575,7 +575,7 @@ void MaxEggLoader::TraverseEggNode(EggNode *node, EggGroup *context)
|
|||||||
EggTexture *tex = poly->get_texture(0);
|
EggTexture *tex = poly->get_texture(0);
|
||||||
texid = GetTex(tex->get_fullpath().to_os_specific())->_id;
|
texid = GetTex(tex->get_fullpath().to_os_specific())->_id;
|
||||||
if (tex->has_transform())
|
if (tex->has_transform())
|
||||||
uvtrans = tex->get_transform();
|
uvtrans = tex->get_transform2d();
|
||||||
} else {
|
} else {
|
||||||
texid = GetTex("")->_id;
|
texid = GetTex("")->_id;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user