📄 icezcbbreaker.cpp
字号:
gParams->mMin = 0;
gParams->mMax = mNbTextures;
gParams->mRequestCode = RQ_SET_RANGE_PROGRESS_BAR1;
GetCallbacksManager()->ExecCallbacks(ICCB_REQUEST, ICCB_REQUEST, gParams);
#endif
// Are there any textures to import?
if(mNbTextures)
{
// Find TEXM chunk
if(importer.GetChunk(mZCBGlobalVersion ? "TEXMCHUNK" : "TEXM"))
{
// Get version number back
mTEXMVersion = importer.GetDword();
ZCB_CHECKVERSION(mTEXMVersion, CHUNK_TEXM_VER, "TEXM");
// Log message
ZCBLog("Importing %d textures...\n", mNbTextures);
// Import all textures
for(udword n=0;n<mNbTextures;n++)
{
// Fill a texture structure
ZCBTextureInfo CurTexture;
// Database information
CurTexture.mName.Set((const char*)importer.GetString()); // Texture path
CurTexture.mID = importer.GetDword(); // Texture ID
PatchTextureID(CurTexture.mID);
// Get bitmap data
ubyte Code = 1; // Default for version <=1
if(mTEXMVersion>1) Code = importer.GetByte();
// CurTexture.mIsBitmapIncluded = Version>1 ? (importer.GetByte()!=0) : true;
CurTexture.mIsBitmapIncluded = Code!=0;
if(Code)
{
// Get texture information back
CurTexture.mWidth = importer.GetDword();
CurTexture.mHeight = importer.GetDword();
CurTexture.mHasAlpha = importer.GetByte()!=0;
// Get bytes for a RGBA texture
CurTexture.mBitmap = new ubyte[CurTexture.mWidth*CurTexture.mHeight*4];
ZCB_CHECKALLOC(CurTexture.mBitmap);
if(Code==1)
{
// => RGBA texture
for(udword i=0;i<CurTexture.mWidth*CurTexture.mHeight;i++)
{
CurTexture.mBitmap[i*4+0] = importer.GetByte(); // Red
CurTexture.mBitmap[i*4+1] = importer.GetByte(); // Green
CurTexture.mBitmap[i*4+2] = importer.GetByte(); // Blue
CurTexture.mBitmap[i*4+3] = CurTexture.mHasAlpha ? importer.GetByte() : PIXEL_OPAQUE;
}
}
else
{
// => Quantized RGB texture
ubyte Palette[768];
for(udword i=0;i<768;i++) Palette[i] = importer.GetByte();
//
for(udword i=0;i<CurTexture.mWidth*CurTexture.mHeight;i++)
{
ubyte ColorIndex = importer.GetByte();
CurTexture.mBitmap[i*4+0] = Palette[ColorIndex*3+0];
CurTexture.mBitmap[i*4+1] = Palette[ColorIndex*3+1];
CurTexture.mBitmap[i*4+2] = Palette[ColorIndex*3+2];
CurTexture.mBitmap[i*4+3] = PIXEL_OPAQUE;
}
}
}
// Cropping values & texture matrix
ImportCroppingValues(CurTexture.mCValues, CurTexture.mTMtx, importer, CurTexture.mWrapU, CurTexture.mMirrorU, CurTexture.mWrapV, CurTexture.mMirrorV);
// Call the app
NewTexture(CurTexture);
UpdateProgressBar1();
}
}
else
{
ZCBImportError("Chunk TEXM not found!", ZCB_ERROR_CHUNK_NOT_FOUND);
return false;
}
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Imports the meshes.
* \param importer [in] the imported array.
* \return true if success.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool ZCBBreaker::ImportMeshes(CustomArray& importer)
{
// Are there any meshes to import?
udword Total = mNbMeshes + mNbDerived;
#ifdef ZCB_PROGRESS_BAR
gParams->mText = "Importing meshes...";
gParams->mRequestCode = RQ_SET_TEXT_PROGRESS_BAR1;
GetCallbacksManager()->ExecCallbacks(ICCB_REQUEST, ICCB_REQUEST, gParams);
gParams->mMin = 0;
gParams->mMax = Total;
gParams->mRequestCode = RQ_SET_RANGE_PROGRESS_BAR1;
GetCallbacksManager()->ExecCallbacks(ICCB_REQUEST, ICCB_REQUEST, gParams);
#endif
if(Total)
{
// Find MESH chunk
if(importer.GetChunk(mZCBGlobalVersion ? "MESHCHUNK" : "MESH"))
{
// Get version number back
mMESHVersion = importer.GetDword();
ZCB_CHECKVERSION(mMESHVersion, CHUNK_MESH_VER, "MESH");
// Log message
ZCBLog("Importing %d meshes...\n", Total);
// Import all meshes
for(udword n=0;n<Total;n++)
{
// Fill a mesh structure
ZCBMeshInfo CurMesh;
// Base info
CurMesh.Import(importer);
// Get mesh information back
CurMesh.mIsCollapsed = importer.GetByte()!=0; // true if the object has been collapsed
CurMesh.mIsSkeleton = importer.GetByte()!=0; // true for BIPED parts
CurMesh.mIsInstance = importer.GetByte()!=0; // true for instances
CurMesh.mIsTarget = importer.GetByte()!=0; // true for target objects
CurMesh.mIsConvertible = importer.GetByte()!=0; // true for valid objects
CurMesh.mIsSkin = importer.GetByte()!=0; // true for PHYSIQUE skins
if(mMESHVersion>=4)
CurMesh.mCastShadows= importer.GetByte()!=0; // true if the mesh can cast its shadow
if(mMESHVersion>=9)
{
CurMesh.mReceiveShadows = importer.GetByte()!=0;
CurMesh.mMotionBlur = importer.GetByte()!=0;
}
// Get skin's character ID
if(mMESHVersion>=5 && CurMesh.mIsSkin)
{
CurMesh.mCharID = importer.GetDword(); // the owner's character ID
}
// Get BIPED parts information if needed
if(CurMesh.mIsSkeleton)
{
CurMesh.mCharID = importer.GetDword(); // the owner's character ID
CurMesh.mCSID = importer.GetDword(); // the CSID
}
// Get data back for non-instance meshes
if(!CurMesh.mIsInstance)
{
// Get primitive parameters
if(mMESHVersion>=8)
{
udword PrimitiveType = importer.GetDword();
switch(PrimitiveType)
{
case ZCB_PRIM_BOX:
{
ZCBBoxParams* BP = new ZCBBoxParams;
CurMesh.mPrimParams = BP;
BP->mLength = importer.GetFloat();
BP->mWidth = importer.GetFloat();
BP->mHeight = importer.GetFloat();
BP->mWSegs = importer.GetDword();
BP->mLSegs = importer.GetDword();
BP->mHSegs = importer.GetDword();
BP->mGenUVS = importer.GetDword();
}
break;
case ZCB_PRIM_SPHERE:
{
ZCBSphereParams* SP = new ZCBSphereParams;
CurMesh.mPrimParams = SP;
SP->mRadius = importer.GetFloat();
SP->mSegments = importer.GetDword();
SP->mSmooth = importer.GetDword();
SP->mHemisphere = importer.GetFloat();
SP->mSquash = importer.GetDword();
SP->mSliceFrom = importer.GetFloat();
SP->mSliceTo = importer.GetFloat();
SP->mSliceOn = importer.GetDword();
SP->mRecenter = importer.GetDword();
SP->mGenUVS = importer.GetDword();
}
break;
case ZCB_PRIM_GEOSPHERE:
{
ZCBGeosphereParams* GP = new ZCBGeosphereParams;
CurMesh.mPrimParams = GP;
GP->mRadius = importer.GetFloat();
GP->mSegments = importer.GetDword();
GP->mGenType = importer.GetDword();
GP->mHemisphere = importer.GetDword();
GP->mSmooth = importer.GetDword();
GP->mRecenter = importer.GetDword();
GP->mGenUVS = importer.GetDword();
}
break;
case ZCB_PRIM_CYLINDER:
{
ZCBCylinderParams* CP = new ZCBCylinderParams;
CurMesh.mPrimParams = CP;
CP->mRadius = importer.GetFloat();
CP->mHeight = importer.GetFloat();
CP->mHSegs = importer.GetDword();
CP->mCapSegs = importer.GetDword();
CP->mSides = importer.GetDword();
CP->mSmooth = importer.GetDword();
CP->mSliceOn = importer.GetDword();
CP->mSliceFrom = importer.GetFloat();
CP->mSliceTo = importer.GetFloat();
CP->mGenUVS = importer.GetDword();
}
break;
case ZCB_PRIM_CONE:
{
ZCBConeParams* CP = new ZCBConeParams;
CurMesh.mPrimParams = CP;
CP->mRadius1 = importer.GetFloat();
CP->mRadius2 = importer.GetFloat();
CP->mHeight = importer.GetFloat();
CP->mHSegs = importer.GetDword();
CP->mCapSegs = importer.GetDword();
CP->mSides = importer.GetDword();
CP->mSmooth = importer.GetDword();
CP->mSliceOn = importer.GetDword();
CP->mSliceFrom = importer.GetFloat();
CP->mSliceTo = importer.GetFloat();
CP->mGenUVS = importer.GetDword();
}
break;
case ZCB_PRIM_TORUS:
{
ZCBTorusParams* TP = new ZCBTorusParams;
CurMesh.mPrimParams = TP;
TP->mRadius1 = importer.GetFloat();
TP->mRadius2 = importer.GetFloat();
TP->mRotation = importer.GetFloat();
TP->mTwist = importer.GetFloat();
TP->mSegments = importer.GetDword();
TP->mSides = importer.GetDword();
TP->mSmooth = importer.GetDword();
TP->mSliceOn = importer.GetDword();
TP->mSliceFrom = importer.GetFloat();
TP->mSliceTo = importer.GetFloat();
TP->mGenUVS = importer.GetDword();
}
break;
case ZCB_PRIM_TUBE:
{
ZCBTubeParams* TP = new ZCBTubeParams;
CurMesh.mPrimParams = TP;
TP->mRadius1 = importer.GetFloat();
TP->mRadius2 = importer.GetFloat();
TP->mHeight = importer.GetFloat();
TP->mSegments = importer.GetDword();
TP->mCapSegs = importer.GetDword();
TP->mSides = importer.GetDword();
TP->mSmooth = importer.GetDword();
TP->mSliceOn = importer.GetDword();
TP->mSliceFrom = importer.GetFloat();
TP->mSliceTo = importer.GetFloat();
TP->mGenUVS = importer.GetDword();
}
break;
case ZCB_PRIM_TEAPOT:
{
}
break;
case ZCB_PRIM_PLANE:
{
ZCBPlaneParams* PP = new ZCBPlaneParams;
CurMesh.mPrimParams = PP;
PP->mLength = importer.GetFloat();
PP->mWidth = importer.GetFloat();
PP->mWidthSegs = importer.GetDword();
PP->mLengthSegs = importer.GetDword();
PP->mDensity = importer.GetFloat();
PP->mScale = importer.GetFloat();
PP->mGenUVS = importer.GetDword();
}
break;
case ZCB_PRIM_HEDRA:
{
ZCBHedraParams* HP = new ZCBHedraParams;
CurMesh.mPrimParams = HP;
HP->mRadius = importer.GetFloat();
HP->mFamily = importer.GetDword();
HP->mP = importer.GetFloat();
HP->mQ = importer.GetFloat();
HP->mScaleP = importer.GetFloat();
HP->mScaleQ = importer.GetFloat();
HP->mScaleR = importer.GetFloat();
HP->mVertices = importer.GetDword();
HP->mGenUVS = importer.GetDword();
}
break;
case ZCB_PRIM_CAPSULE:
{
ZCBCapsuleParams* CP = new ZCBCapsuleParams;
CurMesh.mPrimParams = CP;
CP->mRadius = importer.GetFloat();
CP->mHeight = importer.GetFloat();
CP->mCenters = importer.GetDword();
CP->mSides = importer.GetDword();
CP->mHSegs = importer.GetDword();
CP->mSmooth = importer.GetDword();
CP->mSliceOn = importer.GetDword();
CP->mSliceFrom = importer.GetFloat();
CP->mSliceTo = importer.GetFloat();
CP->mGenUVS = importer.GetDword();
}
break;
}
}
CurMesh.m
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -