コード例 #1
0
ファイル: cl_sequence.cpp プロジェクト: jklemmack/ufoai
/**
 * @brief Parse values for a sequence model
 * @return 1 - increase the command position of the sequence by one
 * @sa seqEnt_vals
 * @sa CL_SequenceFindEnt
 */
static int SEQ_ExecuteModel (sequenceContext_t *context, const char *name, const char *data)
{
	/* get sequence entity */
	seqEnt_t *se = SEQ_FindEnt(context, name);
	if (!se) {
		int i;
		/* create new sequence entity */
		for (i = 0, se = context->ents; i < context->numEnts; i++, se++)
			if (!se->inuse)
				break;
		if (i >= context->numEnts) {
			if (context->numEnts >= MAX_SEQENTS)
				Com_Error(ERR_FATAL, "Too many sequence entities");
			se = &context->ents[context->numEnts++];
		}
		/* allocate */
		OBJZERO(*se);
		se->inuse = true;
		Q_strncpyz(se->name, name, sizeof(se->name));
		VectorSet(se->color, 0.7, 0.7, 0.7);
	}

	/* get values */
	while (*data) {
		const value_t *vp;
		for (vp = seqEnt_vals; vp->string; vp++)
			if (Q_streq(data, vp->string)) {
				data += strlen(data) + 1;
				Com_EParseValue(se, data, vp->type, vp->ofs, vp->size);
				break;
			}
		if (!vp->string) {
			if (Q_streq(data, "model")) {
				data += strlen(data) + 1;
				Com_DPrintf(DEBUG_CLIENT, "Registering model: %s\n", data);
				se->model = R_FindModel(data);
				if (se->model == NULL)
					se->inuse = false;
			} else if (Q_streq(data, "anim")) {
				if (se->model == NULL)
					Com_Error(ERR_FATAL, "could not change the animation - no model loaded yet");
				data += strlen(data) + 1;
				Com_DPrintf(DEBUG_CLIENT, "Change anim to: %s\n", data);
				R_AnimChange(&se->as, se->model, data);
			} else
				Com_Printf("SEQ_ExecuteModel: unknown token '%s'\n", data);
		}

		data += strlen(data) + 1;
	}
	return 1;
}
コード例 #2
0
ファイル: cl_sequence.cpp プロジェクト: ufoai/ufoai
/**
 * @brief Removed a sequence entity from the current sequence
 * @return 1 - increase the command position of the sequence by one
 * @sa CL_SequenceFind2D
 * @sa CL_SequenceFindEnt
 */
static int SEQ_ExecuteDelete (sequenceContext_t* context, const char* name, const char* data)
{
	seqEnt_t* se = SEQ_FindEnt(context, name);
	if (se)
		se->inuse = false;

	seq2D_t* s2d = SEQ_Find2D(context, name);
	if (s2d) {
		s2d->inuse = false;

		Mem_Free(s2d->text);
		s2d->text = nullptr;
	}

	if (!se && !s2d)
		Com_Printf("SEQ_ExecuteDelete: couldn't find '%s'\n", name);
	return 1;
}
コード例 #3
0
ファイル: cl_sequence.cpp プロジェクト: jklemmack/ufoai
/**
 * @sa CL_Sequence2D
 * @sa CL_ViewRender
 * @sa CL_SequenceEnd_f
 * @sa UI_PopWindow
 * @sa CL_SequenceFindEnt
 */
static void SEQ_Render3D (sequenceContext_t *context)
{
	entity_t ent;
	seqEnt_t *se;
	int i;

	if (context->numEnts == 0)
		return;

	/* set camera */
	SEQ_SetCamera(context);

	refdef.numEntities = 0;
	refdef.mapTiles = cl.mapTiles;

	/* render sequence */
	for (i = 0, se = context->ents; i < context->numEnts; i++, se++) {
		if (!se->inuse)
			continue;

		/* advance in time */
		VectorMA(se->origin, cls.frametime, se->speed, se->origin);
		VectorMA(se->angles, cls.frametime, se->omega, se->angles);
		R_AnimRun(&se->as, se->model, context->animspeed * cls.frametime);

		/* add to scene */
		OBJZERO(ent);
		ent.model = se->model;
		ent.skinnum = se->skin;
		ent.as = se->as;
		ent.alpha = se->alpha;

		R_EntitySetOrigin(&ent, se->origin);
		VectorCopy(se->origin, ent.oldorigin);
		VectorCopy(se->angles, ent.angles);

		if (se->parent && se->tag) {
			seqEnt_t *parent;

			parent = SEQ_FindEnt(context, se->parent);
			if (parent)
				ent.tagent = parent->ep;
			ent.tagname = se->tag;
		}

		/* add to render list */
		se->ep = R_GetFreeEntity();
		R_AddEntity(&ent);
	}

	refdef.rendererFlags |= RDF_NOWORLDMODEL;

	/* use a relative fixed size */
	viddef.x = context->pos[0];
	viddef.y = context->pos[1];
	viddef.viewWidth = context->size[0];
	viddef.viewHeight = context->size[1];

	/* update refdef */
	CL_ViewUpdateRenderData();

	/** @todo Models are not at the right position (relative to the node position). Maybe R_SetupFrustum erase matrix. Not a trivialous task. */
	/* render the world */
	R_PushMatrix();
	R_RenderFrame();
	R_PopMatrix();
}