Esempio n. 1
0
void ModelEditor::newTexAnimLookup() {
	_Tn("newTexAnimLookup");
	if (header_m->nTexAnims != 0) {
		int newSize = FileSize + header_m->nTexAnims * sizeof(short);
		char *n = f;
		f = SMemNew(newSize);
		memcpy(f, n, FileSize);
		SetStructure();
		header_m->nTexAnimLookup = header_m->nTextures;
		header_m->ofsTexAnimLookup = FileSize;
		FileSize = newSize;
		SetStructure();
		for (int i = 0; i < header_m->nTexLookup; i++) {
			texanimlookup_m[i] = i;
		}
		FillLine();
	} else {
		int newSize = FileSize + sizeof(short);
		char *n = f;
		f = SMemNew(newSize);
		memcpy(f, n, FileSize);
		SetStructure();
		header_m->nTexAnimLookup = 1;
		header_m->ofsTexAnimLookup = FileSize;
		FileSize = newSize;
		SetStructure();
		texanimlookup_m[0] = -1;
		FillLine();
	}
}
Esempio n. 2
0
void ModelEditor::newTexReplace() {
	_Tn("newTexReplace");
	int newSize = FileSize + sizeof(short);
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->nTexReplace = 1;
	header_m->ofsTexReplace = FileSize;
	FileSize = newSize;
	SetStructure();
	texreplacelookup_m[0] = 0;
	FillLine();
}
Esempio n. 3
0
/**
 * Just some dummy to have the keylookup in the file...
 */
void ModelEditor::newKeyBoneLookup() {
	_Tn("newKeyBoneLookup");
	int newSize = FileSize + sizeof(short);
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->nKeyBoneLookup = 1;
	header_m->ofsKeyBoneLookup = FileSize;
	FileSize = newSize;
	SetStructure();
	keybonelookup_m[0] = -1;
	FillLine();
}
Esempio n. 4
0
void ModelEditor::newAttachments(ModelAttachmentDef*attachments, int num) {
	_Tn("newAttachments");
	FillLine();
	int newSize = FileSize + sizeof(ModelAttachmentDef) * num;
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->nAttachments = num;
	header_m->ofsAttachments = FileSize;
	FileSize = newSize;
	memcpy(f + header_m->ofsAttachments, attachments, num
			* sizeof(ModelAttachmentDef));
	SetStructure();
	for (int i = 0; i < header_m->nAttachments; i++) {
		//I null this because I saw no difference,
		//and without animblocks it is much easier
		attach_m[i].unk.nKeys = 0;
		attach_m[i].unk.nTimes = 0;
		attach_m[i].unk.ofsKeys = 0;
		attach_m[i].unk.ofsTimes = 0;
	}
	FillLine();
	//Now we create the lookup!

	//40 should be enough atm
	//maybe we need later more?
	int nLook = 40;
	newSize = FileSize + nLook * sizeof(short);
	n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->nAttachLookup = nLook;
	header_m->ofsAttachLookup = FileSize;
	FileSize = newSize;
	SetStructure();
	for (int i = 0; i < header_m->nAttachLookup; i++) {
		for (int j = 0; j < header_m->nAttachments; j++) {
			if (attach_m[j].id = i) {
				attachlookup_m[i] = j;
				break;
			} else {
				attachlookup_m[i] = -1;
			}
		}
	}
	FillLine();

}
Esempio n. 5
0
/**
 *Note: This will not add any animated bones!
 *only Animationsdef will be added!
 **/
void ModelEditor::newAnimations(ModelAnimation *anim, int nanim) {
	_Tn("newAnimations");
	FillLine();
	int newSize = FileSize + sizeof(ModelAnimation) * (nanim);
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	memcpy(f + FileSize, anim, nanim * sizeof(ModelAnimation));
	header_m->ofsAnimations = FileSize;
	header_m->nAnimations = nanim;
	FileSize = newSize;
	FillLine();
	SetStructure();
}
Esempio n. 6
0
void ModelEditor::newVertices(ModelVertex * vert, int nvert) {
	_Tn("newVertices");
	FillLine();
	int newSize = FileSize + sizeof(ModelVertex) * (nvert);
	char *newc = SMemNew(newSize);
	memcpy(newc, f, FileSize);
	f = newc;
	SetStructure();
	memcpy(f + FileSize, vert, nvert * sizeof(ModelVertex));
	header_m->ofsVertices = FileSize;
	header_m->nVertices = nvert;
	FileSize = newSize;
	FillLine();
	SetStructure();
}
Esempio n. 7
0
void ModelEditor::writeAnimation(AnimationBlock *ablock,
		AnimationHelper<T> help) {
	_TDn("void ModelEditor::writeAnimation(AnimationBlock *ablock,AnimationHelper<T>help)");
	ablock->nKeys = help.nAnims;
	ablock->nTimes = help.nAnims;
	ablock->seq = help.GlobalSequence;
	ablock->type = help.Interpolation;
	if (help.nAnims != 0) {
		ablock->ofsTimes = FileSize;
		ablock->ofsKeys = FileSize + sizeof(AnimSubStructure);
		AnimSubStructure *timesub = new AnimSubStructure[help.nAnims];
		AnimSubStructure *keysub = new AnimSubStructure[help.nAnims];
		for (int k = 0; k < help.nAnims; k++) {
			timesub[k].n = help.helper[k].nValues;
			keysub[k].n = help.helper[k].nValues;
		}
		int newSize = FileSize + 2 * sizeof(AnimSubStructure)*help.nAnims;
		char *n = f;
		f = SMemNew(newSize);
		memcpy(f, n, FileSize);
		SetStructure();
		memcpy(f + FileSize, timesub, sizeof(AnimSubStructure) * help.nAnims);
		memcpy(f + FileSize + sizeof(AnimSubStructure)*help.nAnims, keysub,
				sizeof(AnimSubStructure) * help.nAnims);
		int ofsSize = FileSize;
		FileSize = newSize;
		FillLine();
		//we need to reset the pointers whenever FileSize has changed..
		for (int j = 0; j < help.nAnims; j++) {
			//n was set before.. I think xD
			if (help.helper[j].nValues != 0 && !help.helper[j].inAnim) {
				timesub = (AnimSubStructure *) (f + ofsSize);
				timesub[j].ofs = FileSize;
				uint32 *time = new uint32[help.helper[j].nValues];
				for (int k = 0; k < help.helper[j].nValues; k++) {
					time[k] = help.helper[j].help[k].timestamp;
				}
				writeAnimblockData(time, help.helper[j].nValues);
				keysub = (AnimSubStructure *) (f + ofsSize
						+ sizeof(AnimSubStructure)*help.nAnims);
				keysub[j].ofs = FileSize;
				T *val = new T[help.helper[j].nValues];
				for (int k = 0; k < help.helper[j].nValues; k++) {
					val[k] = help.helper[j].help[k].value;
				}
				writeAnimblockData(val, help.helper[j].nValues);
			} else {
				timesub = (AnimSubStructure *) (f + ofsSize);
				timesub[j].ofs = help.helper[j].ofsTime;
				keysub = (AnimSubStructure *) (f + ofsSize
						+ sizeof(AnimSubStructure)*help.nAnims);
				keysub[j].ofs = help.helper[j].ofsKey;
			}
		}
		FillLine();
	} else {
		ablock->ofsTimes = 0;
		ablock->ofsKeys = 0;
	}
}
Esempio n. 8
0
void ModelEditor::newTextures(TextureHelper help) {
	_Tn("newTextures");
	FillLine();
	int newSize = FileSize + help.nTextures * sizeof(ModelTextureDef);
	for (int i = 0; i < help.nTextures; i++) {
		help.texdefs[i].nameOfs = newSize;
		newSize += help.texdefs[i].nameLen + (16 - ((help.texdefs[i].nameLen)
				% 16));
	}
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->ofsTextures = FileSize;
	header_m->nTextures = help.nTextures;
	texture_m = (ModelTextureDef *) (f + header_m->ofsTextures);
	for (int i = 0; i < help.nTextures; i++) {
		texture_m[i] = help.texdefs[i];
		char *texname = (char *) (f + texture_m[i].nameOfs);
		for (int k = 0; k < texture_m[i].nameLen; k++) {
			texname[k] = help.Texnames[i][k];
		}
	}
	FileSize = newSize;
	FillLine();
}
Esempio n. 9
0
//we need an alternative for this but well xD
//it's the easiest one :D
void ModelEditor::newBoneLookup() {
	_Tn("newBoneLookup");
	int newSize = FileSize + header_m->nBones * sizeof(short);
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->nBoneLookupTable = header_m->nBones;
	header_m->ofsBoneLookupTable = FileSize;
	FileSize = newSize;
	SetStructure();
	for (int i = 0; i < header_m->nBoneLookupTable; i++) {
		bonelookup_m[i] = i;
	}
	FillLine();
}
Esempio n. 10
0
void SkinEditor::newIndices(int num){
	_Tn("newIndices_n");
	FillLine();
	int newSize=FileSize+sizeof(Index)*num;
	char *n=f;
	f=(char*)malloc(newSize);
	memcpy(f,n,FileSize);
	SetStructure();
	header_s->nIndices=num;
	header_s->ofsIndices=FileSize;
	SetStructure();
	for(int i=0;i<header_s->nIndices;i++){
		index_s[i].Vertex=i;
	}
	FileSize=newSize;
	FillLine();

}
Esempio n. 11
0
void SkinEditor::FillLine(){
	_TDn("FillLine");
	int newSize=FileSize+(16-((FileSize)%16));
	char *n=(char*)malloc(newSize);
	memcpy(n,f,FileSize);
	f=n;
	FileSize=newSize;
	SetStructure();
}
Esempio n. 12
0
/**
 *This fills up the file to 0x10 bytes
 *so we get a nice filestruct :D
 **/
void ModelEditor::FillLine() {
	_TDn("FillLine()");
	int newSize = FileSize + (16 - ((FileSize) % 16));
	char *n = f;
	f=SMemNew(newSize);
	memcpy(f, n, FileSize);
	FileSize = newSize;
	SetStructure();
}
Esempio n. 13
0
void ModelEditor::newTransparencyLookup() {
	_Tn("newTransparencyLookup()");
	FillLine();
	int newSize = FileSize + header_m->nTransparency * sizeof(short);
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->nTransparencyLookup = header_m->nTransparency;
	header_m->ofsTransparencyLookup = FileSize;
	printf("Setted Offsets\n");
	SetStructure();
	FileSize = newSize;
	for (int i = 0; i < header_m->nTransparencyLookup; i++) {
		translookup_m[i] = i;
	}
	FillLine();
}
Esempio n. 14
0
void ModelEditor::addTexture(ModelTextureDef tex, const char * texname) {
	_Tn("addTexture");
	FillLine();
	//let's calc the needed space
	int newSize = FileSize + sizeof(ModelTextureDef)
			* (header_m->nTextures + 1) +
	//(16-((sizeof(ModelTextureDef)*(header_m->nTextures+1))%16))+ //we don't need this as (sizeof(ModelTextureDef)==0x10
			tex.nameLen + (16 - (tex.nameLen) % 16) + sizeof(uint16)
			* (header_m->nTexLookup + 1) + (16 - ((sizeof(uint16)
			* (header_m->nTexLookup + 1)) % 16));
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	memcpy(f + FileSize, (f + header_m->ofsTextures), sizeof(ModelTextureDef)
			* header_m->nTextures);
	memcpy(f + FileSize + sizeof(ModelTextureDef) * (header_m->nTextures + 1),
			texname, tex.nameLen);
	memcpy(f + FileSize + sizeof(ModelTextureDef) * (header_m->nTextures + 1)
			+ tex.nameLen + (16 - (sizeof(tex.nameLen)) % 16), (f
			+ header_m->ofsTexLookup), sizeof(short) * header_m->nTexLookup);
	header_m = (ModelHeader *) (f);

	header_m->ofsTextures = FileSize;
	texture_m = (ModelTextureDef *) (f + header_m->ofsTextures);
	texture_m[header_m->nTextures].flags = tex.flags;
	texture_m[header_m->nTextures].type = tex.type;
	texture_m[header_m->nTextures].nameLen = tex.nameLen;
	texture_m[header_m->nTextures].nameOfs = FileSize + sizeof(ModelTextureDef)
			* (header_m->nTextures + 1);

	header_m->ofsTexLookup = FileSize + sizeof(ModelTextureDef)
			* (header_m->nTextures + 1) + tex.nameLen + (16 - (tex.nameLen)
			% 16);
	texturelookup_m = (uint16 *) (f + header_m->ofsTexLookup);
	texturelookup_m[header_m->nTexLookup] = header_m->nTextures;

	header_m->nTextures++;
	header_m->nTexLookup++;

	FileSize = newSize;
	FillLine();
	SetStructure();
}
Esempio n. 15
0
CResizer::CResizer(const char *file): c4_Storage(file, 1), _refSize(0), _prop(
  "p1"), _seed(0) {
  SetStructure("a[p1:I]");

  _refData = new char[kMaxData];

  _attached = View("a");

  Verify();
}
Esempio n. 16
0
void ModelEditor::newBounds(BoundVolumeHelper help) {
	_Tn("void ModelEditor::newBounds(BoundVolumeHelper help)");
	//normals
	int newSize = FileSize + sizeof(Vec3D) * help.nBNormals;
	char *n = f;
	f = new char[newSize];
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->ofsBoundingNormals = FileSize;
	header_m->nBoundingNormals = help.nBNormals;
	memcpy(f + FileSize, help.BNormals, help.nBNormals * sizeof(Vec3D));
	FileSize = newSize;
	FillLine();

	//vertices
	newSize = FileSize + sizeof(Vec3D) * help.nBVertices;
	n = f;
	f = new char[newSize];
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->ofsBoundingVertices = FileSize;
	header_m->nBoundingVertices = help.nBVertices;
	memcpy(f + FileSize, help.BVertices, sizeof(Vec3D) * help.nBVertices);
	FileSize = newSize;
	FillLine();

	//triangles
	newSize = FileSize + sizeof(ModelBoundTriangle) * help.nBTriangles;
	n = f;
	f = new char[newSize];
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->ofsBoundingTriangles = FileSize;
	header_m->nBoundingTriangles = help.nBTriangles;
	memcpy(f + FileSize, help.BTriangles, sizeof(ModelBoundTriangle)
			* help.nBTriangles);
	FileSize = newSize;
	FillLine();

	calcBoundingBox();

}
Esempio n. 17
0
void ModelEditor::setModelName(char *name, int length) {
	int newSize = FileSize + length;
	char*n = f;
	f = new char[newSize];
	memcpy(f, n, FileSize);
	memcpy(f + FileSize, name, length);
	SetStructure();
	header_m->nameOfs = FileSize;
	header_m->nameLength = length;
	FillLine();
}
Esempio n. 18
0
int ModelEditor::writeAnimblockData(T *data, int nValues) {
	_TDn("writeAnimblockData");
	int newSize = FileSize + sizeof(T) * nValues;
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	memcpy(f + FileSize, data, sizeof(T) * nValues);
	FileSize = newSize;
	FillLine();
	return 0;
}
Esempio n. 19
0
void ModelEditor::newCameras(CamHelper help) {
	_Tn("newCameras");
	int newSize = FileSize + sizeof(ModelCameraDef) * help.nCameras;
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	memcpy(f + FileSize, help.camera, sizeof(ModelCameraDef) * help.nCameras);
	SetStructure();
	header_m->ofsCameras = FileSize;
	header_m->nCameras = help.nCameras;
	FileSize = newSize;
	FillLine();
	for (int i = 0; i < header_m->nCameras; i++) {
		writeAnimation(&(cam_m[i].rot), help.rotation[i]);
		writeAnimation(&(cam_m[i].transTarget), help.translationtar[i]);
		writeAnimation(&(cam_m[i].transPos), help.translationpos[i]);
	}
	FillLine();
	//I only know about two different cameras...
	int nCamLookup = 2;
	newSize = FileSize + sizeof(short) * nCamLookup;
	n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->ofsCameraLookup = FileSize;
	header_m->nCameraLookup = nCamLookup;
	SetStructure();
	for (int i = 0; i < header_m->nCameraLookup; i++) {
		for (int j = 0; j < header_m->nCameras; j++) {
			if (cam_m[j].id == i) {
				camlookup_m[i] = j;
				break;
			} else
				camlookup_m[i] = -1;
		}
	}
	FileSize = newSize;
	FillLine();
}
Esempio n. 20
0
void SkinEditor::newProperties(int num){
	_Tn("newProps_n");
	FillLine();
	int newSize=FileSize+sizeof(VProp)*num;
	char *n=f;
	f=(char*)malloc(newSize);
	memcpy(f,n,FileSize);
	SetStructure();
	header_s->nProperties=num;
	header_s->ofsProperties=FileSize;
	FileSize=newSize;
	FillLine();
}
Esempio n. 21
0
void SkinEditor::newSubmeshes(Submesh* sub,int num){
	_Tn("newSubmeshes");
	FillLine();
	int newSize=FileSize+sizeof(Submesh)*num;
	char *n=f;
	f=(char*)malloc(newSize);
	memcpy(f,n,FileSize);
	SetStructure();
	header_s->nSubmeshes=num;
	header_s->ofsSubmeshes=FileSize;
	memcpy(f+FileSize,sub,sizeof(Submesh)*num);
	FileSize=newSize;
	FillLine();
}
Esempio n. 22
0
void ModelEditor::newRenderflags(ModelRenderFlags *flags, int num) {
	_Tn("new Renderflags");
	FillLine();
	int newSize = FileSize + sizeof(ModelRenderFlags) * num;
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->ofsRenderFlags = FileSize;
	header_m->nRenderFlags = num;
	memcpy(f + FileSize, flags, num * sizeof(ModelRenderFlags));
	FileSize = newSize;
	FillLine();
}
Esempio n. 23
0
/**
 *in fact..this is bullshit oO
 *
 *it should be more like:
 *read in the animations and check for which animation they are...
 **/
void ModelEditor::addAnimationLookup(int nanim) {
	_Tn("addAnimLookup");
	FillLine();
	int newSize = FileSize + sizeof(uint16) * (header_m->nAnimationLookup
			+ nanim);
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	memcpy(f + FileSize, (f + header_m->ofsAnimationLookup), sizeof(uint16)
			* (header_m->nAnimationLookup));
	header_m->ofsAnimationLookup = FileSize;
	animlookup_m = (int16*) (f + header_m->ofsAnimationLookup);
	for (int i = 0; i < nanim; i++) {
		//not really...
		animlookup_m[i + header_m->nAnimationLookup] = i
				+ header_m->nAnimationLookup;
	}
	header_m->nAnimationLookup += nanim;
	FileSize = newSize;
	FillLine();
	SetStructure();
}
Esempio n. 24
0
void SkinEditor::newTexUnits(TexUnit* tex, int num){
	_Tn("newTexUnits");
	FillLine();
	int newSize=FileSize+sizeof(TexUnit)*num;
	char *n=f;
	f=(char*)malloc(newSize);
	memcpy(f,n,FileSize);
	SetStructure();
	header_s->nTextureUnits=num;
	header_s->ofsTextureUnits=FileSize;
	memcpy(f+FileSize,tex,sizeof(TexUnit)*num);
	FileSize=newSize;
	FillLine();
}
Esempio n. 25
0
void SkinEditor::newIndices(Index *ind,int num){
	_Tn("newIndices");
	FillLine();
	int newSize=FileSize+sizeof(Index)*num;
	char *n=f;
	f=(char*)malloc(newSize);
	memcpy(f,n,FileSize);
	SetStructure();
	header_s->nIndices=num;
	header_s->ofsIndices=FileSize;
	memcpy(f+FileSize,ind,sizeof(Index)*num);
	FileSize=newSize;
	FillLine();
}
Esempio n. 26
0
SkinEditor::SkinEditor(){
	_Tn("Skin()-COnstructor");
	f=(char*)malloc(sizeof(SkinHeader));
	FileSize=sizeof(SkinHeader);
	for(int i=0;i<FileSize;i++){
		f[i]=0;
	}
	SetStructure();
	header_s->ID[0]='S';
	header_s->ID[1]='K';
	header_s->ID[2]='I';
	header_s->ID[3]='N';
	header_s->LOD=0x15;
}
Esempio n. 27
0
void ModelEditor::newGlobalSequences(uint32 *sequ, int nSequ) {
	_Tn("newGlobalSequences()");
	FillLine();
	int newSize = FileSize + sizeof(uint32) + nSequ;
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->ofsGlobalSequences = FileSize;
	header_m->nGlobalSequences = nSequ;
	memcpy(f + FileSize, sequ, sizeof(uint32) * nSequ);
	FileSize = newSize;
	FillLine();
}
Esempio n. 28
0
void SkinEditor::newTriangles(Triangle *tri,int num){
	_Tn("newTriangles");
	FillLine();
	int newSize=FileSize+sizeof(Triangle)*num;
	char *n=f;
	f=(char*)malloc(newSize);
	memcpy(f,n,FileSize);
	SetStructure();
	header_s->nTriangles=num;
	header_s->ofsTriangles=FileSize;
	memcpy(f+FileSize,tri,sizeof(Triangle)*num);
	FileSize=newSize;
	FillLine();
}
Esempio n. 29
0
File: store.cpp Progetto: aosm/tcl
/// Load contents from the specified input stream
bool c4_Storage::LoadFrom(c4_Stream &stream_) {
  c4_HandlerSeq *newRoot = c4_Persist::Load(&stream_);
  if (newRoot == 0)
    return false;

  // fix commit-after-load bug, by using a full view copy
  // this is inefficient, but avoids mapping/strategy problems
  c4_View temp(newRoot);

  SetSize(0);
  SetStructure(temp.Description());
  InsertAt(0, temp);

  return true;
}
Esempio n. 30
0
void ModelEditor::newTransparency(AnimationHelper<short> *help, int nTrans) {
	_Tn("void ModelEditor::newTransparency(AnimationHelper<short> *help,int nTrans)");
	int newSize = FileSize + sizeof(AnimationBlock) * nTrans;
	char *n = f;
	f = SMemNew(newSize);
	memcpy(f, n, FileSize);
	SetStructure();
	header_m->ofsTransparency = FileSize;
	header_m->nTransparency = nTrans;
	FileSize = newSize;
	FillLine();
	for (int i = 0; i < nTrans; i++) {
		writeAnimation(&(trans_m[i].trans), help[i]);
	}
}