home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
MEDIT.LZH
/
FXG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-05
|
5KB
|
169 lines
#include <owl\owlpch.h>
#pragma hdrstop
#include <stdio.h>
#include <string.h>
#include <dos.h>
#include <cstring.h>
#include <dir.h>
#include "matrix.h"
#include "suflib.h"
#include "parts.h"
#include "motion.h"
#include "mecha.h"
#include "profile.h"
#include "files.h"
#include "log.h"
#define MaxHistory (int)(64)
static Mechanic *convertmecha[MaxHistory];
static int nconvertmecha = 0;
static char *apindfile = "_temp1.ind";
static char *f2aindfile = "_temp2.ind";
static char *frmfile = "_temp.frm";
static char *afmfile = "_temp.afm";
static char *cMotionView = "_aplay.bat";
static char *cSuf2Agc = "suf2agc.exe";
static char *cFrm2Afm = "frm2afm.exe";
static char *cBGload = "bgldexec.exe";
static char *cAfmView = "afmpexec.exe";
//static char *iSuf2Agc = "s2a%d.ind";
static char *fScaleDat = "scale.dat";
int FXG_MakeAGC(Mechanic *mecha, FILE *batfp, FILE *apfp, FILE *f2afp, int count)
{
char str[128];
FILE *fp;
for (int i = 0; i < nconvertmecha; ++i) {
if (convertmecha[i] == mecha) {
strcpy(str, mecha->name);
int l = strlen(str);
if (l > 4 && str[l-4] == '.') {
str[l-4] = '\0';
}
fprintf(f2afp, "%s%s.agc\n", fxg_agcdir.c_str(), str);
fprintf(apfp, "%s%s.agc\n", fxg_agcdir.c_str(), str);
return TRUE;
}
}
if (nconvertmecha < MaxHistory-1) {
convertmecha[nconvertmecha++] = mecha;
}
sprintf(str, "%ss2a%d.ind", fxg_agcdir.c_str(), count);
fprintf(batfp, "%s%s @%s\n", fxgdir.c_str(), cSuf2Agc, str);
//logprintf("open %s\n", str);
if ((fp = fopen(str, "w")) == NULL) {
return FALSE;
}
fprintf(fp, "%s\n", mecha->filename);
fprintf(fp, "%s\n", fxg_atrfile.c_str());
for (Parts *p = mecha->parts; p != NULL; p = p->next) {
for (Parts *op = mecha->parts; op != p && op != NULL; op = op->next) {
if (op->object == p->object) {
break;
}
}
if (op == p || op == NULL) {
char *f = p->object->filename;
if (strncmpi(f, partsdir.c_str(), partsdir.length()) == 0) {
fprintf(fp, "%s%s\n", simplepartsdir.c_str(), f+partsdir.length());
} else if (f[1] == ':' || f[0] == '\\') {
fprintf(fp, "%s\n", f);
} else {
fprintf(fp, "%s%s\n", simplepartsdir.c_str(), f);
}
}
}
strcpy(str, mecha->name);
int l = strlen(str);
if (l > 4 && str[l-4] == '.') {
str[l-4] = '\0';
}
fprintf(fp, "-o%s%s.agc\n", fxg_agcdir.c_str(), str);
fprintf(fp, "-z%s%s\n", fxg_agcdir.c_str(), fScaleDat);
fprintf(f2afp, "%s%s.agc\n", fxg_agcdir.c_str(), str);
fprintf(apfp, "%s%s.agc\n", fxg_agcdir.c_str(), str);
fclose(fp);
return TRUE;
}
void FXGA_ShowMotion(Motion* motion, CameraMotion* camera, Vector& light)
{
char str[128];
FILE *batfp;
FILE *apfp, *f2afp;
static int first = FALSE;
if (nconvertmecha == 0) {
sprintf(str, "%s%s", fxg_agcdir.c_str(), fScaleDat);
unlink(str);
}
sprintf(str, "%s%s", fxgdir.c_str(), cMotionView);
//logprintf("open %s\n", str);
if ((batfp = fopen(str, "w")) == NULL) {
return;
}
sprintf(str, "%s%s", fxgdir.c_str(), apindfile);
//logprintf("open %s\n", str);
if ((apfp = fopen(str, "w")) == NULL) {
fclose(batfp);
return;
}
sprintf(str, "%s%s", fxgdir.c_str(), f2aindfile);
//logprintf("open %s\n", str);
if ((f2afp = fopen(str, "w")) == NULL) {
fclose(batfp);
fclose(apfp);
return;
}
sprintf(str, "%s%s", fxgdir.c_str(), frmfile);
Motion::FileWrite(motion, camera, light, str);
fprintf(f2afp, "%s\n", str);
int mechanics = 0;
for (Motion *m = motion; m != NULL; m = m->next) {
for (Motion *om = motion; om != m && om != NULL; om = om->next) {
if (om->mecha == m->mecha) {
break;
}
}
if (m->mecha != NULL && (om == m || om == NULL)) {
if (FXG_MakeAGC(m->mecha, batfp, apfp, f2afp, mechanics++) == FALSE) {
fclose(batfp);
fclose(apfp);
fclose(f2afp);
return;
}
}
}
fprintf(f2afp, "-o%s%s\n", fxgdir.c_str(), afmfile);
fprintf(f2afp, "-z%s%s\n", fxg_agcdir.c_str(), fScaleDat);
fclose(f2afp);
fprintf(apfp, "%s%s\n", fxgdir.c_str(), afmfile);
fprintf(apfp, "%s\n", fxg_colfile.c_str());
fclose(apfp);
fprintf(batfp, "%s%s @%s%s\n", fxgdir.c_str(), cFrm2Afm, fxgdir.c_str(), f2aindfile);
// fprintf(batfp, "%s%s %s_a.TN8 %s_b.TN8 %s.TCO\n", fxgdir.c_str(), cBGload, bgfile, bgfile, bgfile);
if (first == FALSE) {
fprintf(batfp, "%s%s __star.bg8\n", fxgdir.c_str(), cBGload);
first = TRUE;
}
fprintf(batfp, "%s%s @%s%s\n", fxgdir.c_str(), cAfmView, fxgdir.c_str(), apindfile);
fclose(batfp);
sprintf(str, "%s%s", fxgdir.c_str(), cMotionView);
WinExec(str, SW_SHOWMINIMIZED);
}