home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
MEDIT.LZH
/
RENDEXEC.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-17
|
3KB
|
117 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 "profile.h"
#include "motion.h"
#include "mecha.h"
#include "files.h"
#include "log.h"
static char *indfile = "_temp1.ind";
static char *frmfile = "_temp.frm";
static char *cRend = "rendwin.exe";
static char *cWire = "wireview.exe";
void WireView(Motion *motion, CameraMotion *camera, Vector& light)
{
char str[128];
sprintf(str, "%s%s", tempdir.c_str(), frmfile);
Motion::FileWrite(motion, camera, light, str);
sprintf(str, "%s%s %s%s", pathdir.c_str(), cWire, tempdir.c_str(), frmfile);
WinExec(str, SW_SHOW);
}
#define MAXPARTS 1024
void RendNowMotion(Motion *motion, CameraMotion *camera, Vector& light, int frame)
{
Object *objlist[MAXPARTS];
int nobj = 0;
char str[128];
FILE *fp;
FILE *frmfp;
sprintf(str, "%s%s", tempdir.c_str(), indfile);
if ((fp = fopen(str, "w")) == NULL) {
return;
}
sprintf(str, "%s%s", tempdir.c_str(), frmfile);
if ((frmfp = fopen(str, "w")) == NULL) {
fclose(fp);
return;
}
fprintf(frmfp,
"/* Motion Editor\n"
" Version 1.00γ\n"
"Frame: %d\n"
"*/\n", frame);
fprintf(frmfp, "fram\n{\n"
"\tlight pal( rgb ( 1.00 1.00 1.00 ) %4.0lf %4.0lf %4.0lf)\n",
100.0 * light.x, 100.0 * light.y, 100.0 * light.z);
fprintf(frmfp,
"\t{\tmov ( %5.0lf %5.0lf %5.0lf ) "
"rotz( %7.3lf ) roty( %7.3lf ) rotx( %7.3lf ) "
"eye deg ( %d ) }\n",
camera->position.x, camera->position.y, camera->position.z,
rad(camera->rotation.z), rad(camera->rotation.y), rad(camera->rotation.x),
int(rad(camera->angle)+0.5)
);
fprintf(fp, "%s\n", atrfile.c_str());
fprintf(fp, "%s%s\n", tempdir.c_str(), frmfile);
for (Motion *m = motion; m != NULL; m = m->next) {
if (m->beginframe <= frame && frame <= m->endframe) {
m->GetName(str);
fprintf(frmfp,
" {\t/*%s*/\n"
"\tmov ( %5.0lf %5.0lf %5.0lf ) "
"rotz( %7.3lf ) roty( %7.3lf ) rotx( %7.3lf ) "
"scal( %7.3lf %7.3lf %7.3lf )\n",
str,
m->position.x, m->position.y, m->position.z,
rad(m->rotation.z), rad(m->rotation.y), rad(m->rotation.x),
m->scale.x, m->scale.y, m->scale.z);
for (Parts *p = m->mecha->parts; p != NULL; p = p->next) {
p->PartsWrite(frmfp, NULL, 0);
for (int no = 0; no < nobj; ++no) {
if (objlist[no] == p->object) {
break;
}
}
if (no == nobj) {
objlist[nobj++] = p->object;
char *f = p->object->filename;
if (strncmpi(f, simplepartsdir.c_str(), simplepartsdir.length()) == 0) {
fprintf(fp, "%s%s\n", partsdir.c_str(), f+simplepartsdir.length());
} else if (f[1] == ':' || f[0] == '\\') {
fprintf(fp, "%s\n", f);
} else {
fprintf(fp, "%s%s\n", partsdir.c_str(), f);
}
}
}
fprintf(frmfp, " }\n");
}
}
fprintf(frmfp, "}\n");
if (rendoption == "") {
fprintf(fp, "-c512x384 -n -g\n");
} else {
fprintf(fp, "%s\n", rendoption.c_str());
}
fclose(fp);
fclose(frmfp);
sprintf(str, "%s%s @%s%s", pathdir.c_str(), cRend, tempdir.c_str(), indfile);
WinExec(str, SW_SHOW);
}