Files
2026-06-01 12:46:52 +02:00

102 lines
2.0 KiB
C++

#include "stdafx.h"
/*
SMorphedMesh.cpp
Dynamic-vertexed mesh for vertex changing
Created 2006/05, by JiYoung
*/
//#include <stdafx.h>
#include "SMorphedMesh.h"
#include "KViewPort.h"
#include "SDebug_Util.h"
//======================================================
// MorphedModel
//======================================================
MorphedModel::MorphedModel() : KSeqForm() // KSeqForm()
{
primitive=NULL;
K3DMatrixIdentity(m_matResult);
K3DMatrixIdentity(m_matRoot);
K3DMatrixIdentity(matLocal);
K3DMatrixIdentity(m_matWorld);
}
MorphedModel::~MorphedModel()
{
this->close();
}
void MorphedModel::close()
{
if (primitive!=NULL) {
delete primitive;
primitive=NULL;
}
K3DMatrixIdentity(m_matResult);
K3DMatrixIdentity(matLocal);
K3DMatrixIdentity(m_matWorld);
}
void MorphedModel::init(KMeshPrimitive *source)
{
assert(primitive==NULL);
MorphedPrimitive *p=new MorphedPrimitive();
p->init(source);
primitive=p;
// Copy transform matrix
if (source->GetTransform()!=NULL) {
setLocalMatrix(source->GetTransform());
} else {
K3DMatrixIdentity(matLocal);
}
//
// NOTE :
// Mesh가 bone에 붙을때와 그냥 표시될 때, matLocal(?)의 역할이 다르다?
// bone에 붙일 수 있는 구조로 변경이 필요할 지도 모름
// 하여간 게임 본체에 잘 붙여 볼 것.
//
//
// Model initialize example
// Set origin-position of each vertexes
// if (source->GetTransform()!=NULL) {
// K3DMatrix out;
// float determinant;
// if (NULL != K3DMatrixInverse( &out, &determinant, source->GetTransform())) {
// matLocal=out;
// }
// }
//matLocal._43+=10.f;
//
}
//
// Inherits
//
int MorphedModel::Process( DWORD dwTime )
{
K3DMatrixMultiply( m_matResult, matLocal, m_matTransform);
return 0;
}
void MorphedModel::Render( KViewportObject *viewport, DWORD flag , const K3DMatrix * pAttachMat )
{
if (primitive!=NULL) {
primitive->SetTransform(&m_matResult, &m_matWorld);
viewport->Register( primitive, 0 );
}
}