Exemple #1
0
void * addFont(zoneInfo_t* info, const char* name, char* data, int dataLen)
{
	if (dataLen > 0) { Com_Error(false, "Can't add new fonts!"); return NULL; }

	Font* font = (Font*)data;

	addAsset(info, ASSET_TYPE_MATERIAL, font->image->name, addMaterial(info, font->image->name, (char*)font->image, -1));
	addAsset(info, ASSET_TYPE_MATERIAL, font->glowImage->name, addMaterial(info, font->glowImage->name, (char*)font->glowImage, -1));

	return data;
}
Exemple #2
0
void * addTracer(zoneInfo_t* info, const char* name, char* data, int dataLen)
{
	if (dataLen > 0)  { Com_Error(false, "Can only export built in Tracers!");  return NULL; }

	Tracer* t = (Tracer*)data;
	addAsset(info, ASSET_TYPE_MATERIAL, t->material->name, addMaterial(info, t->material->name, (char*)t->material, -1));

	return t;
}
Exemple #3
0
void doLastAsset(zoneInfo_t* info, const char* name)
{
	Rawfile* data = new Rawfile;
	data->name = strdup(name);
	data->compressedData = "Made With ZoneBuilder";
	data->sizeUnCompressed = 0;
	data->sizeCompressed = strlen(data->compressedData) + 1;

	addAsset(info, ASSET_TYPE_RAWFILE, name, data);
}
void addTechset(zoneInfo_t* info, const char* name, char* data, size_t dataLen)
{
	if(dataLen != 0) { Com_Error(false, "How did we get a non bulitin techset?"); return; }

	MaterialTechniqueSet* asset = (MaterialTechniqueSet*)data;

	for(int i=0; i<48; i++)
	{
		MaterialTechnique* tech = asset->techniques[i];
		if(!tech) continue;

		if(asset->techniques[i]->numPasses != 1) Com_Error(true, "Um why does this technique have more than 1 pass?");
		addAsset(info, ASSET_TYPE_VERTEXDECL, tech->passes[0].vertexDecl->name, tech->passes[0].vertexDecl);
		addAsset(info, ASSET_TYPE_VERTEXSHADER, tech->passes[0].vertexShader->name, tech->passes[0].vertexShader);
		addAsset(info, ASSET_TYPE_PIXELSHADER, tech->passes[0].pixelShader->name, tech->passes[0].pixelShader);		
	}

	addAsset(info, ASSET_TYPE_TECHSET, asset->name, asset);
}
TileAssetView::TileAssetView( QWidget *parent ) : QListView( parent )
{
    iAddAsset = new QAction(tr("&Add asset"), this);
    connect( iAddAsset, SIGNAL(triggered()), this, SLOT(addAsset()));

    iDeleteAsset = new QAction(tr("&Delete asset"), this);
    connect( iDeleteAsset, SIGNAL(triggered()), this, SLOT(deleteAsset()));

    connect(this,SIGNAL(doubleClicked(const QModelIndex &)),this,SLOT(onDoubleClicked(const QModelIndex &)));

    this->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
Exemple #6
0
//------------------------------------------------------------------------------
std::shared_ptr<ShaderAsset> ShaderMan::loadShader(const std::string& shaderFile,
                                                   GLenum shaderType)
{
  std::shared_ptr<BaseAsset> asset = findAsset(shaderFile);
  if (asset == nullptr)
  {
    // Load a new shader.
    std::shared_ptr<ShaderAsset> shaderAsset(
        new ShaderAsset(mHub, shaderFile, shaderType));

    // Add the asset to BaseAssetMan's internal weak_ptr list.
    asset = std::dynamic_pointer_cast<BaseAsset>(shaderAsset);
    addAsset(asset);
    holdAsset(asset, getDefaultHoldTime());

    return shaderAsset;
  }
  else
  {
    return std::dynamic_pointer_cast<ShaderAsset>(asset);
  }
}
GameGyrocopter::GameGyrocopter(){

	destroyed = false;

	addChild(&posBody);
	posBody.translate3d(0, -1.2, 1);
	// add a particle system
	//engineParticles = new YGEGraphics::YGEParticleSystem();
	posBody.addAsset(&engineParticles);


	// load and add the body model for the gyrocopter
	meshBody.loadFromOBJ("models/gyro_body.obj");
	posBody.addAsset(&meshBody);

	// add the top rotor
	posBody.addChild(&posRotorTop);
	posRotorTop.addAsset(&meshRotorTop);
	posRotorTop.translate3d(0,5.5,0);
	meshRotorTop.loadFromOBJ("models/gyro_rotor_top.obj");

	// add the back rotor
	posBody.addChild(&posRotorBack);
	posRotorBack.addAsset(&meshRotorBack);
	posRotorBack.translate3d(0,3,1.5);
	meshRotorBack.loadFromOBJ("models/gyro_rotor_back.obj");

	// add the h tail
	posBody.addChild(&posTailH);
	posTailH.addAsset(&meshTailH);
	posTailH.translate3d(0,1,2);
	meshTailH.loadFromOBJ("models/gyro_tail_H.obj");

	// add the v tail
	posBody.addChild(&posTailV);
	posTailV.addAsset(&meshTailV);
	posTailV.translate3d(0,3,2);
	meshTailV.loadFromOBJ("models/gyro_tail_V.obj");

	backRotorAngularVelocity = 0.0f;



	//addAsset(new YGEGraphics::YGESimpleBox());


	throttle = 100;
	tailH = 0;
	tailV = 0;
	tailX = 0;

	tailHRot = 0;
	tailVRot = 0;

	up = 0.0f;

	reload = -1;
	fireFromRight = 1;

	idleSound.setSound("sounds/prop_idle.wav");
	lowSound.setSound("sounds/prop_low.wav");
	midSound.setSound("sounds/prop_mid.wav");
	highSound.setSound("sounds/prop_high.wav");

	addAsset(&idleSound);
	addAsset(&lowSound);
	addAsset(&midSound);
	addAsset(&highSound);

	posRotorTop.addAsset(&collider);

	posRotorTop.addChild(&posColliderLeft);
	posColliderLeft.addAsset(&colliderLeft);
	posColliderLeft.translate3d(-8, 0, 0);

	posRotorTop.addChild(&posColliderRight);
	posColliderRight.addAsset(&colliderRight);
	posColliderRight.translate3d(8, 0, 0);

	collider.setRadius(1);
	collider.setCollisionListener(this);

	colliderLeft.setRadius(0.2);
	colliderLeft.setCollisionListener(this);

	colliderRight.setRadius(0.2);
	colliderRight.setCollisionListener(this);


	soundstate = -1;


	
	addAsset(&mass);
	mass.setLinearDamping(0.2 );
	mass.setAngularDamping(0.3 );
	
	mass.setSize(YGEMath::Vector3(3, 2, 4));
	mass.setMass(1);



}
Exemple #8
0
void * addWeaponVariantDef(zoneInfo_t* info, const char* name, char* data, int dataLen)
{
	WeaponVariantDef* ret;
	if (dataLen > 0) ret = BG_LoadWeaponDef_LoadObj(data);
	else ret = (WeaponVariantDef*)data;

	// now add strings to our list
	// hidetags
	for (int i = 0; i < 32; i++)
	{
		if (ret->hideTags[i] == NULL) break; // no more tags
		ret->hideTags[i] = addScriptString(info, SL_ConvertToString(ret->hideTags[i]));
	}

	// notetrackSounds
	for (int i = 0; i < 16; i++)
	{
		if (ret->WeaponDef->noteTrackSoundMap[0][i] == NULL) break; // no more tags
		ret->WeaponDef->noteTrackSoundMap[0][i] = addScriptString(info, SL_ConvertToString(ret->WeaponDef->noteTrackSoundMap[0][i]));
	}

	for (int i = 0; i < 16; i++)
	{
		if (ret->WeaponDef->noteTrackSoundMap[1][i] == NULL) break; // no more tags
		ret->WeaponDef->noteTrackSoundMap[1][i] = addScriptString(info, SL_ConvertToString(ret->WeaponDef->noteTrackSoundMap[1][i]));
	}

	// notetrackRumble
	for (int i = 0; i < 16; i++)
	{
		if (ret->WeaponDef->noteTrackRumbleMap[0][i] == NULL) break; // no more tags
		ret->WeaponDef->noteTrackRumbleMap[0][i] = addScriptString(info, SL_ConvertToString(ret->WeaponDef->noteTrackRumbleMap[0][i]));
	}

	for (int i = 0; i < 16; i++)
	{
		if (ret->WeaponDef->noteTrackSoundMap[1][i] == NULL) break; // no more tags
		ret->WeaponDef->noteTrackRumbleMap[1][i] = addScriptString(info, SL_ConvertToString(ret->WeaponDef->noteTrackRumbleMap[1][i]));
	}

	// now require all sub-assets
	// materials
#define save_material(mat) if (mat) addAsset(info, ASSET_TYPE_MATERIAL, mat->name, addMaterial(info, mat->name, (char*)mat, -1));
	save_material(ret->killIcon);
	save_material(ret->dpadIcon);
	save_material(ret->WeaponDef->reticleCenter);
	save_material(ret->WeaponDef->reticleSide);
	save_material(ret->WeaponDef->hudIcon);
	save_material(ret->WeaponDef->pickupIcon);
	save_material(ret->WeaponDef->ammoCounterIcon);
	save_material(ret->WeaponDef->AdsOverlayShader);
	save_material(ret->WeaponDef->AdsOverlayShaderLowRes);
	save_material(ret->WeaponDef->AdsOverlayShaderEMP);
	save_material(ret->WeaponDef->AdsOverlayShaderEMPLowRes);
#undef save_material

	// xmodel
#define save_model(model) if (model) addAsset(info, ASSET_TYPE_XMODEL, model->name, addXModel(info, model->name, (char*)model, -1));
	for (int i = 0; i < 16; i++)
	{
		save_model(ret->WeaponDef->gunXModel[i]);
	}

	save_model(ret->WeaponDef->handXModel);

	for (int i = 0; i < 16; i++)
	{
		save_model(ret->WeaponDef->worldModel[i]);
	}

	save_model(ret->WeaponDef->worldClipModel);
	save_model(ret->WeaponDef->rocketModel);
	save_model(ret->WeaponDef->knifeModel);
	save_model(ret->WeaponDef->worldKnifeModel);
	save_model(ret->WeaponDef->projectileModel);
#undef save_model

	if (ret->WeaponDef->collisions)
	{
		addAsset(info, ASSET_TYPE_PHYS_COLLMAP, ret->WeaponDef->collisions->name,
		addPhysCollmap(info, ret->WeaponDef->collisions->name, (char*)ret->WeaponDef->collisions, -1));
	}

	if (ret->WeaponDef->tracer)
	{
		addAsset(info, ASSET_TYPE_TRACER, ret->WeaponDef->tracer->name,
		addTracer(info, ret->WeaponDef->tracer->name, (char*)ret->WeaponDef->tracer, -1));
	}

	// fx
	// null these for now because I'm not certain effect writing works

#define save_fx(model) if (model) addAsset(info, ASSET_TYPE_FX, model->name, addFxEffectDef(info, model->name, (char*)model, -1));
	/*
	save_fx(ret->WeaponDef->viewFlashEffect);
	save_fx(ret->WeaponDef->worldFlashEffect);
	save_fx(ret->WeaponDef->viewShellEjectEffect);
	save_fx(ret->WeaponDef->worldShellEjectEffect);
	save_fx(ret->WeaponDef->viewLastShotEjectEffect);
	save_fx(ret->WeaponDef->worldLastShotEjectEffect);
	save_fx(ret->WeaponDef->projExplosionEffect);
	save_fx(ret->WeaponDef->projDudEffect);
	save_fx(ret->WeaponDef->projTrailEffect);
	save_fx(ret->WeaponDef->projBeaconEffect);
	save_fx(ret->WeaponDef->projIgnitionEffect);
	save_fx(ret->WeaponDef->turretOverheatEffect);
	*/
#undef save_fx
	
	ret->WeaponDef->viewFlashEffect = NULL;
	ret->WeaponDef->worldFlashEffect = NULL;
	ret->WeaponDef->viewShellEjectEffect = NULL;
	ret->WeaponDef->worldShellEjectEffect = NULL;
	ret->WeaponDef->viewLastShotEjectEffect = NULL;
	ret->WeaponDef->worldLastShotEjectEffect = NULL;
	ret->WeaponDef->projExplosionEffect = NULL;
	ret->WeaponDef->projDudEffect = NULL;
	ret->WeaponDef->projTrailEffect = NULL;
	ret->WeaponDef->projBeaconEffect = NULL;
	ret->WeaponDef->projIgnitionEffect = NULL;
	ret->WeaponDef->turretOverheatEffect = NULL;
	
	return ret;
}
Exemple #9
0
/*
 * Class:     com_thegaragelab_quickui_Driver
 * Method:    gfxRegisterAsset
 * Signature: (I[BII)I
 */
JNIEXPORT jint JNICALL Java_com_thegaragelab_quickui_Driver_gfxRegisterAsset (JNIEnv *pEnv, jobject obj, jint type, jbyteArray data, jint offset, jint size) {
  return (jint)addAsset(pEnv, data, offset, size);
  }
void* addXModel(zoneInfo_t* info, const char* name, char* data, size_t dataLen)
{
	if (data == NULL) return NULL;

	if(dataLen == 0)
	{
		XModel * model = (XModel*)data;
		short* boneNames = new short[model->numBones];

		for(int i=0; i<model->numBones; i++)
		{
			boneNames[i] = addScriptString(info, SL_ConvertToString(model->boneNames[i]));
		}

		model->boneNames = boneNames;

		for(int i=0; i<model->numSurfaces; i++)
		{
			// allow material overriding
			void* file;
			void* asset;

			if(int len = FS_ReadFile(va("zonebuilder/materials/%s.txt", model->materials[i]->name), &file) > 0)
			{
				asset = addMaterial(info, model->materials[i]->name, (char*)file, len);
				FS_FreeFile(file);
			}
			else
			{
				asset = addMaterial(info, model->materials[i]->name, (char*)model->materials[i], 0);
			}

			addAsset(info, ASSET_TYPE_MATERIAL, model->materials[i]->name, asset);
		}

		return data;
	}

	// copy stuff over
	XModel * base = (XModel*)DB_FindXAssetHeader(ASSET_TYPE_XMODEL, "viewmodel_mp5k");
	XModel * asset = new XModel;

	memcpy(asset, base, sizeof(XModel));
	asset->lods[0].surfaces = new XModelSurfaces;
	memcpy(asset->lods[0].surfaces, base->lods[0].surfaces, sizeof(XModelSurfaces));

	XModelSurfaces * surf = asset->lods[0].surfaces;
	surf->name = new char[strlen(name) + 6];
	sprintf((char*)surf->name, "%s_surf", name);

	BUFFER * buf = new BUFFER(data, dataLen);
	asset->name = new char[128];
	buf->readstr(asset->name, 128);
	buf->read(&asset->numBones, 4, 1);
	buf->read(&asset->numSubBones, 4, 1);
	buf->read(&asset->numSurfaces, 4, 1);
	surf->numSurfaces = asset->numSurfaces;
	asset->lods[0].numSurfs = surf->numSurfaces;

	asset->boneNames = new short[asset->numBones];

	for(int i=0; i<asset->numBones; i++)
	{
		char bone[64];
		buf->readstr(bone, 64);
		asset->boneNames[i] = addScriptString(info, bone);
	}

	// allocate stuff and load it
	if(asset->numBones - asset->numSubBones)
	{
		asset->parentList = new char[asset->numBones - asset->numSubBones];
		asset->tagAngles = new XModelAngle[asset->numBones - asset->numSubBones];
		asset->tagPositions = new XModelTagPos[asset->numBones - asset->numSubBones];

		buf->read(asset->parentList, sizeof(char), asset->numBones - asset->numSubBones);
		buf->read(asset->tagAngles, sizeof(XModelAngle), asset->numBones - asset->numSubBones);
		buf->read(asset->tagPositions, sizeof(XModelTagPos), asset->numBones - asset->numSubBones);
	}

	if(asset->numBones)
	{
		asset->partClassification = new char[asset->numBones];
		asset->animMatrix = new char[32 * asset->numBones];

		buf->read(asset->partClassification, sizeof(char), asset->numBones);
		buf->read(asset->animMatrix, 32, asset->numBones);
	}

	surf->surfaces = new XSurface[surf->numSurfaces];
	memset(surf->surfaces, 0, sizeof(XSurface) * surf->numSurfaces);
	
	for(int i=0; i<surf->numSurfaces; i++)
	{
		XSurface* s = &surf->surfaces[i];
		buf->read(&s->numVertices, 4, 1);
		buf->read(&s->numPrimitives, 4, 1);
		buf->read(&s->blendNum1, 4, 1);
		buf->read(&s->blendNum2, 4, 1);
		buf->read(&s->blendNum3, 4, 1);
		buf->read(&s->blendNum4, 4, 1);

		int blendCount = (s->blendNum4 * 7) + (s->blendNum3 * 5) + (s->blendNum2 * 3) + s->blendNum1;

		if(blendCount)
		{
			s->blendInfo = new char[blendCount * 2];
			buf->read(s->blendInfo, 2, blendCount);
		}
		else 
		{
			s->blendInfo = NULL;	
		}

		s->vertexBuffer = new GfxPackedVertex[s->numVertices];
		buf->read(s->vertexBuffer, 32, s->numVertices);

		int ct = 0;
		buf->read(&ct, 4, 1);

		if(ct)
		{
			buf->read(&s->numCT, 4, 1);
			s->ct = new XSurfaceCT[s->numCT];

			for(int j=0; j<s->numCT; j++)
			{
				XSurfaceCT* ct = &s->ct[j];
				buf->read(&ct->pad, 4, 1);
				buf->read(&ct->pad2, 4, 1);
				ct->entry = new XSurfaceCTEntry;
				buf->read(ct->entry, 24, 1);
				buf->read(&ct->entry->numNode, 4, 1);
				buf->read(&ct->entry->numLeaf, 4, 1);

				if(ct->entry->numNode)
				{
					ct->entry->node = new char[ct->entry->numNode * 16];
					buf->read(ct->entry->node, 16, ct->entry->numNode);
				}
				else
				{
					ct->entry->node = NULL;
				}

				if(ct->entry->numLeaf)
				{
					ct->entry->leaf = new short[ct->entry->numLeaf];
					buf->read(ct->entry->leaf, 2, ct->entry->numLeaf);
				}
				else
				{
					ct->entry->node = NULL;
				}
			}
		}
		else
		{
			s->ct = NULL;
			s->numCT = 0;
		}

		s->indexBuffer = new Face[s->numPrimitives];
		buf->read(s->indexBuffer, sizeof(Face), s->numPrimitives);
	}

	asset->materials = new Material*[asset->numSurfaces];

	// read the material stuff and load a material if we need it
	for(int i=0; i<asset->numSurfaces; i++)
	{
		char matName[64] = { 0 };
		char techName[64] = { 0 };
		char matFileName[78] = { 0 };

		buf->readstr(matName, 50);
		buf->readstr(techName, 64);

		char* filename = matName;

		// asset is already in db... dont re-add it
		if (containsAsset(info, ASSET_TYPE_MATERIAL, matName) > 0)
		{
			asset->materials[i] = (Material*)getAsset(info, ASSET_TYPE_MATERIAL, matName);
			continue;
		}

		if(!strncmp("mc/", matName, 3)) filename = matName + 3;

		_snprintf(matFileName, sizeof(matFileName), "materials/%s.txt", filename);

		void* matBuf;
		int len = FS_ReadFile(matFileName, &matBuf);

		if(len > 0)
		{
			asset->materials[i] = (Material*)addMaterial(info, matName, (char*)matBuf, len);
			FS_FreeFile(matBuf);
		}
		else
		{
			asset->materials[i] = (Material*)DB_FindXAssetHeader(ASSET_TYPE_MATERIAL, matName);
			addMaterial(info, matName, (char*)asset->materials[i], 0);
		}

		addAsset(info, ASSET_TYPE_MATERIAL, matName, asset->materials[i]);		
	}

	int test = 0;
	buf->read(&test, 4, 1);

	if(test) Com_Error(false, "Cause NTA said so!");

	buf->read(&test, 4, 1);

	if(!test) Com_Error(false, "Cause NTA said so!");

	asset->unknowns = new char[asset->numBones * 28];
	buf->read(asset->unknowns, 28, asset->numBones);

	return asset;
}
void addMaterial(zoneInfo_t* info, const char* name, char* data, size_t dataLen)
{
	if(parseMatFile(data, dataLen) < 0) return;

	// load up the techset
	char techsetfname [128];
	_snprintf(techsetfname, 128, "techsets/%s.techset", techsetName);
	loadAsset(info, ASSET_TYPE_TECHSET, techsetfname, techsetName);

	int asset = addAsset(info, ASSET_TYPE_MATERIAL, name, NULL, 0);

	BUFFER* buf = new BUFFER(4096);

	Material* mat = new Material;
	memset(mat, 0, sizeof(Material));
	mat->name = (char*)0xFFFFFFFF;
	if(materialUsage == MATERIAL_USAGE_UI)
	{
		mat->flags = 0x2F;
		mat->animationX = 1;
		mat->animationY = 1;
		mat->unknown2 = 0xFFFFFFFF;
		mat->unknown3 = 0xFFFFFF00;
		memset(mat->unknown4, 0xFF, sizeof(mat->unknown4));
		mat->numMaps = materialMapCount;
		mat->stateMapCount = 1;
		mat->unknown6 = 3;
		mat->unknown7 = 4;
	}

	// null dem pointers!
	mat->techniqueSet = (MaterialTechniqueSet*)0x0;//0xFFFFFFFF;
	mat->maps = (MaterialTextureDef*)0xFFFFFFFF;
	mat->stateMap = (void*)0xFFFFFFFF;

	buf->write(mat, sizeof(Material), 1);
	buf->write((void*)name, strlen(name) + 1, 1);

	// techset
	int assetPatchTo = containsAsset(info, ASSET_TYPE_TECHSET, techsetName);
	addFixup(info, asset, 80, assetPatchTo);

	// maps
	for(int i=0; i<materialMapCount; i++)
	{
		MaterialTextureDef* tex = new MaterialTextureDef;
		memset(tex, 0, sizeof(MaterialTextureDef));
		tex->firstCharacter = materialMaps[i][0];
		tex->secondLastCharacter = materialMaps[i][strlen(materialMaps[i])];
		tex->typeHash = R_HashString(materialMaps[i]);
		tex->image = (GfxImage*)0xFFFFFFFF;
		tex->textureType = 0xE2;

		buf->write(tex, sizeof(MaterialTextureDef), 1);

		GfxImage* img = new GfxImage;
		memset(img, 0, sizeof(GfxImage));
		img->depth = 1;
		img->textureType = 3; // 2d texture
		img->textureType2 = 3;
		img->texture = (GfxImageLoadDef*)0xFFFFFFFF;
		img->name = (char*)0xFFFFFFFF;
		img->width = iwiHeaders[i].xsize;
		img->height = iwiHeaders[i].ysize;

		buf->write(img, sizeof(GfxImage), 1);
		buf->write((void*)materialTextureNames[i], strlen(materialTextureNames[i]) + 1, 1);

		GfxImageLoadDef * def = new GfxImageLoadDef;
		memset(def, 0, sizeof(GfxImageLoadDef));
		int format = 0;
		switch(iwiHeaders[i].format)
		{
		case IWI_ARGB:
			format = 21;
			break;
		case IWI_RGB8:
			format = 20;
			break;
		case IWI_DXT1:
			format = 0x31545844;
			break;
		case IWI_DXT3:
			format = 0x33545844;
			break;
		case IWI_DXT5:
			format = 0x35545844;
			break;
		}
		def->format = format;
		def->mipLevels = 1;

		buf->write(def, sizeof(GfxImageLoadDef), 1);
	}

	// unknown 8 goes here whenever we use it

	// statemap
	if(materialUsage == MATERIAL_USAGE_UI)
	{
		char statemap[] = {0x65, 0x51, 0x12, 0x18, 0x02, 0x00, 0x0E, 0xE0 };
		buf->write(statemap, 8, 1);
	}

	buf->resize(-1);

	// fix the data
	setAssetData(info, asset, buf->data(), buf->getsize());
}
Exemple #12
0
void HtmlWriter::setDefaultShader(const string &s) {
    addAsset("<AssetShader id=\"default_shader_id\" src=\"" + s + "\"/>");
    m_DefaultShaderId = "default_shader_id";
}