Initial commit
This commit is contained in:
commit
ec41d3430e
292
main.cpp
Normal file
292
main.cpp
Normal file
@ -0,0 +1,292 @@
|
||||
#include <windows.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include "prim.h"
|
||||
#include "waxloader.h"
|
||||
#include <math.h>
|
||||
|
||||
class Pos
|
||||
{
|
||||
public:
|
||||
float x,y,z;
|
||||
Pos()
|
||||
{
|
||||
x=0;
|
||||
y=0;
|
||||
z=0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
static HGLRC hRC;
|
||||
static HDC hDC;
|
||||
|
||||
BOOL keys[256];
|
||||
GLsizei w,h;
|
||||
Wax * wax;
|
||||
GLfloat X, Z;
|
||||
GLfloat HeadMovement, HeadMovAngle;
|
||||
POINT mpos;
|
||||
POINT ompos;
|
||||
GLfloat camy,camx;
|
||||
Pos pos;
|
||||
|
||||
GLvoid InitGL(GLsizei Width, GLsizei Height)
|
||||
{
|
||||
glClearColor(0, 0, 0, 0.0f);
|
||||
glClearDepth(1.0);
|
||||
glDepthFunc(GL_LESS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glLoadIdentity();
|
||||
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,1000.0f);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
GLvoid ReSizeGLScene(GLsizei Width, GLsizei Height)
|
||||
{
|
||||
if (Height==0)
|
||||
Height=1;
|
||||
|
||||
glViewport(0, 0, Width, Height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,1000.0f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
GLvoid DrawGLScene()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
glRotatef(-camx, 1, 0, 0);
|
||||
glRotatef(-camy, 0, 1, 0);
|
||||
glTranslatef(pos.x,pos.y,pos.z);
|
||||
|
||||
for(int i=0; i<wax->count; i++)
|
||||
{
|
||||
wax->p[i].draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(
|
||||
HWND hWnd,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
GLuint PixelFormat;
|
||||
static PIXELFORMATDESCRIPTOR pfd=
|
||||
{
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
1,
|
||||
PFD_DRAW_TO_WINDOW |
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DOUBLEBUFFER,
|
||||
PFD_TYPE_RGBA,
|
||||
24,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
PFD_MAIN_PLANE,
|
||||
0,
|
||||
0, 0, 0
|
||||
};
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
ShowCursor(false);
|
||||
wax=new Wax((char*)"room.wax");
|
||||
hDC = GetDC(hWnd);
|
||||
PixelFormat = ChoosePixelFormat(hDC, &pfd);
|
||||
if (!PixelFormat)
|
||||
{
|
||||
MessageBox(0,"Can't Find A Suitable PixelFormat.","Error",MB_OK|MB_ICONERROR);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
if(!SetPixelFormat(hDC,PixelFormat,&pfd))
|
||||
{
|
||||
MessageBox(0,"Can't Set The PixelFormat.","Error",MB_OK|MB_ICONERROR);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
hRC = wglCreateContext(hDC);
|
||||
if(!hRC)
|
||||
{
|
||||
MessageBox(0,"Can't Create A GL Rendering Context.","Error",MB_OK|MB_ICONERROR);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
if(!wglMakeCurrent(hDC, hRC))
|
||||
{
|
||||
MessageBox(0,"Can't activate GLRC.","Error",MB_OK|MB_ICONERROR);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
InitGL(w, h);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
case WM_CLOSE:
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
|
||||
wglMakeCurrent(hDC,NULL);
|
||||
wglDeleteContext(hRC);
|
||||
ReleaseDC(hWnd,hDC);
|
||||
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
keys[wParam] = TRUE;
|
||||
break;
|
||||
|
||||
case WM_KEYUP:
|
||||
keys[wParam] = FALSE;
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));
|
||||
break;
|
||||
|
||||
default:
|
||||
return (DefWindowProc(hWnd, message, wParam, lParam));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int WINAPI WinMain(
|
||||
HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
MSG msg;
|
||||
WNDCLASS wc;
|
||||
HWND hWnd;
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wc.lpfnWndProc = (WNDPROC) WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = NULL;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = "OpenGL WinClass";
|
||||
|
||||
if(!RegisterClass(&wc))
|
||||
{
|
||||
MessageBox(0,"Failed To Register The Window Class.","Error",MB_OK|MB_ICONERROR);
|
||||
return FALSE;
|
||||
}
|
||||
w=GetSystemMetrics(SM_CXSCREEN);
|
||||
h=GetSystemMetrics(SM_CYSCREEN);
|
||||
hWnd = CreateWindow(
|
||||
"OpenGL WinClass",
|
||||
"Wax",
|
||||
|
||||
WS_POPUP |
|
||||
WS_CLIPCHILDREN |
|
||||
WS_CLIPSIBLINGS,
|
||||
|
||||
0, 0,
|
||||
w, h,
|
||||
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
||||
if(!hWnd)
|
||||
{
|
||||
MessageBox(0,"Window Creation Error.","Error",MB_OK|MB_ICONERROR);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DEVMODE dmScreenSettings; // Ðåæèì ðàáîòû
|
||||
|
||||
memset(&dmScreenSettings, 0, sizeof(DEVMODE)); // Î÷èñòêà äëÿ õðàíåíèÿ óñòàíîâîê
|
||||
dmScreenSettings.dmSize = sizeof(DEVMODE); // Ðàçìåð ñòðóêòóðû Devmode
|
||||
dmScreenSettings.dmPelsWidth = w; // Øèðèíà ýêðàíà
|
||||
dmScreenSettings.dmPelsHeight = h; // Âûñîòà ýêðàíà
|
||||
dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; // Ðåæèì Ïèêñåëà
|
||||
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
|
||||
|
||||
ShowWindow(hWnd, SW_SHOW);
|
||||
UpdateWindow(hWnd);
|
||||
SetFocus(hWnd);
|
||||
|
||||
while (1)
|
||||
{
|
||||
// Îáðàáîòêà âñåõ ñîîáùåíèé
|
||||
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
|
||||
{
|
||||
if (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
DrawGLScene(); // Íàðèñîâàòü ñöåíó
|
||||
SwapBuffers(hDC); // Ïåðåêëþ÷èòü áóôåð ýêðàíà
|
||||
GetCursorPos(&mpos);
|
||||
camy=camy-(mpos.x-ompos.x)/2;
|
||||
camx=camx-(mpos.y-ompos.y)/2;
|
||||
if(camx>90) camx=90;
|
||||
if(camx<-90) camx=-90;
|
||||
ompos=mpos;
|
||||
|
||||
if(mpos.x>w-20)
|
||||
{
|
||||
ompos.x=20;
|
||||
SetCursorPos(20,mpos.y);
|
||||
}
|
||||
if(mpos.x<20)
|
||||
{
|
||||
ompos.x=w-20;
|
||||
SetCursorPos(w-20,mpos.y);
|
||||
}
|
||||
if (keys[VK_ESCAPE]) SendMessage(hWnd,WM_CLOSE,0,0); // Åñëè ESC - âûéòè
|
||||
if(keys['w']||keys['W']||keys['ö']||keys['Ö'])
|
||||
{
|
||||
pos.x=pos.x+cos(-camy* 0.01745329F+90);
|
||||
pos.z=pos.z+sin(-camy* 0.01745329F+90);
|
||||
}
|
||||
if(keys['s']||keys['S']||keys['û']||keys['Û'])
|
||||
{
|
||||
pos.x=pos.x-cos(-camy* 0.01745329F+90);
|
||||
pos.z=pos.z-sin(-camy* 0.01745329F+90);
|
||||
}
|
||||
if(keys['a']||keys['A']||keys['ô']||keys['Ô'])
|
||||
{
|
||||
pos.x=pos.x+sin(-camy* 0.01745329F+90);
|
||||
pos.z=pos.z-cos(-camy* 0.01745329F+90);
|
||||
}
|
||||
if(keys['d']||keys['D']||keys['â']||keys['Â'])
|
||||
{
|
||||
pos.x=pos.x-sin(-camy* 0.01745329F+90);
|
||||
pos.z=pos.z+cos(-camy* 0.01745329F+90);
|
||||
}
|
||||
}
|
||||
}
|
94
prim.h
Normal file
94
prim.h
Normal file
@ -0,0 +1,94 @@
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
class Prim
|
||||
{
|
||||
public:
|
||||
float lx,ly,lz;
|
||||
float rx,ry,rz;
|
||||
float sx,sy,sz;
|
||||
float cx,cy,cz;
|
||||
int type;
|
||||
GLUquadricObj *quadObj;
|
||||
Prim() {}
|
||||
Prim(char* ttype)
|
||||
{
|
||||
if(strstr(ttype,"box")!=NULL) type=1;
|
||||
else type=2;
|
||||
quadObj = gluNewQuadric();
|
||||
}
|
||||
void draw()
|
||||
{
|
||||
GLfloat*c = new GLfloat[3];
|
||||
c[0]=cx;
|
||||
c[1]=cy;
|
||||
c[2]=cz;
|
||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, c);
|
||||
glPushMatrix();
|
||||
//glLoadIdentity();
|
||||
glTranslatef(lx, ly, lz);
|
||||
glRotatef(rx, 1.0, 0.0, 0.0);
|
||||
glRotatef(ry, 0.0, 1.0, 0.0);
|
||||
glRotatef(rz, 0.0, 0.0, 1.0);
|
||||
glScalef(sx,sy,sz);
|
||||
if(type==1)
|
||||
{
|
||||
glBegin(GL_POLYGON);
|
||||
glNormal3f(0.0, 0.0, 2.0);
|
||||
glVertex3f(2.0, 2.0, 2.0);
|
||||
glVertex3f(-2.0, 2.0, 2.0);
|
||||
glVertex3f(-2.0, -2.0, 2.0);
|
||||
glVertex3f(2.0, -2.0, 2.0);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glNormal3f(0.0, 0.0, -2.0);
|
||||
glVertex3f(2.0, 2.0, -2.0);
|
||||
glVertex3f(2.0, -2.0, -2.0);
|
||||
glVertex3f(-2.0, -2.0, -2.0);
|
||||
glVertex3f(-2.0, 2.0, -2.0);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glNormal3f(-2.0, 0.0, 0.0);
|
||||
glVertex3f(-2.0, 2.0, 2.0);
|
||||
glVertex3f(-2.0, 2.0, -2.0);
|
||||
glVertex3f(-2.0, -2.0, -2.0);
|
||||
glVertex3f(-2.0, -2.0, 2.0);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glNormal3f(2.0, 0.0, 0.0);
|
||||
glVertex3f(2.0, 2.0, 2.0);
|
||||
glVertex3f(2.0, -2.0, 2.0);
|
||||
glVertex3f(2.0, -2.0, -2.0);
|
||||
glVertex3f(2.0, 2.0, -2.0);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glNormal3f(0.0, 2.0, 0.0);
|
||||
glVertex3f(-2.0, 2.0, -2.0);
|
||||
glVertex3f(-2.0, 2.0, 2.0);
|
||||
glVertex3f(2.0, 2.0, 2.0);
|
||||
glVertex3f(2.0, 2.0, -2.0);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glNormal3f(0.0, -2.0, 0.0);
|
||||
glVertex3f(-2.0, -2.0, -2.0);
|
||||
glVertex3f(2.0, -2.0, -2.0);
|
||||
glVertex3f(2.0, -2.0, 2.0);
|
||||
glVertex3f(-2.0, -2.0, 2.0);
|
||||
glEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
gluQuadricDrawStyle(quadObj, GLU_FILL);
|
||||
gluCylinder(quadObj, 2, 2, 2, 20, 20);
|
||||
}
|
||||
glPopMatrix();
|
||||
delete c;
|
||||
}
|
||||
};
|
50
wax.cbp
Normal file
50
wax.cbp
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="wax" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="bin\Debug\wax" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj\Debug\" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="bin\Release\wax" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj\Release\" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="opengl32" />
|
||||
<Add library="glu32" />
|
||||
<Add library="gdi32" />
|
||||
</Linker>
|
||||
<Unit filename="main.cpp" />
|
||||
<Unit filename="prim.h" />
|
||||
<Unit filename="waxloader.cpp" />
|
||||
<Unit filename="waxloader.h" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
27
wax.depend
Normal file
27
wax.depend
Normal file
@ -0,0 +1,27 @@
|
||||
# depslib dependency file v1.0
|
||||
1296658495 source:c:\users\kostia\documents\codeblocks_projects\wax\prim.cpp
|
||||
"prim.h"
|
||||
|
||||
1296660979 source:c:\users\kostia\documents\codeblocks_projects\wax\waxloader.cpp
|
||||
"waxloader.h"
|
||||
|
||||
1296653771 c:\users\kostia\documents\codeblocks_projects\wax\waxloader.h
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
<string.h>
|
||||
"prim.h"
|
||||
|
||||
1296664967 c:\users\kostia\documents\codeblocks_projects\wax\prim.h
|
||||
<string.h>
|
||||
<windows.h>
|
||||
<gl\gl.h>
|
||||
<gl\glu.h>
|
||||
|
||||
1296673218 source:c:\users\kostia\documents\codeblocks_projects\wax\main.cpp
|
||||
<windows.h>
|
||||
<gl\gl.h>
|
||||
<gl\glu.h>
|
||||
"prim.h"
|
||||
"waxloader.h"
|
||||
<math.h>
|
||||
|
16
wax.layout
Normal file
16
wax.layout
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Release" />
|
||||
<File name="main.cpp" open="1" top="1" tabpos="1">
|
||||
<Cursor position="6572" topLine="257" />
|
||||
</File>
|
||||
<File name="prim.h" open="1" top="0" tabpos="2">
|
||||
<Cursor position="436" topLine="63" />
|
||||
</File>
|
||||
<File name="waxloader.cpp" open="0" top="0" tabpos="4">
|
||||
<Cursor position="2038" topLine="249" />
|
||||
</File>
|
||||
<File name="waxloader.h" open="0" top="0" tabpos="3">
|
||||
<Cursor position="109" topLine="0" />
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
305
waxloader.cpp
Normal file
305
waxloader.cpp
Normal file
@ -0,0 +1,305 @@
|
||||
#include "waxloader.h"
|
||||
void Wax::loadconfig(char*s)
|
||||
{
|
||||
char *s2;
|
||||
int i;
|
||||
char *buf;
|
||||
s=strstr(s,"root");
|
||||
s=strstr(s,"\"");
|
||||
s+=1;
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
bcx=atof(buf);
|
||||
bcx/=255.0f;
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
bcy=atof(buf);
|
||||
bcy/=255.0f;
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,"\""));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
bcz=atof(buf);
|
||||
bcz/=255.0f;
|
||||
delete buf;
|
||||
|
||||
|
||||
s=strstr(s,"angle");
|
||||
s=strstr(s,"\"");
|
||||
s+=1;
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
anglex=atof(buf);
|
||||
delete buf;
|
||||
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,"\""));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
angley=atof(buf);
|
||||
delete buf;
|
||||
|
||||
s=strstr(s,"radius");
|
||||
s=strstr(s,"\"");
|
||||
s+=1;
|
||||
s2=s;
|
||||
s2=(strstr(s2,"\""));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
radius=atof(buf);
|
||||
delete buf;
|
||||
}
|
||||
|
||||
void Wax::loadprim(char*&s,Prim& p)
|
||||
{
|
||||
char *s2;
|
||||
int i;
|
||||
char *buf;
|
||||
s=strstr(s,"object");
|
||||
s=strstr(s,"\"");
|
||||
s+=1;
|
||||
s2=s;
|
||||
s2=(strstr(s2,"\""));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
p=*new Prim(buf);
|
||||
delete buf;
|
||||
s+=i;
|
||||
s=strstr(s,"location");
|
||||
s=strstr(s,"\"");
|
||||
s+=1;
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.lx=atof(buf);
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.ly=atof(buf);
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,"\""));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.lz=atof(buf);
|
||||
delete buf;
|
||||
|
||||
|
||||
|
||||
s+=i;
|
||||
s=strstr(s,"rotation");
|
||||
s=strstr(s,"\"");
|
||||
s+=1;
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.rx=atof(buf);
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.ry=atof(buf);
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,"\""));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.rz=atof(buf);
|
||||
delete buf;
|
||||
|
||||
s+=i;
|
||||
s=strstr(s,"scale");
|
||||
s=strstr(s,"\"");
|
||||
s+=1;
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.sx=atof(buf);
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.sy=atof(buf);
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,"\""));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.sz=atof(buf);
|
||||
delete buf;
|
||||
|
||||
|
||||
s+=i;
|
||||
s=strstr(s,"color");
|
||||
s=strstr(s,"\"");
|
||||
s+=1;
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.cx=atof(buf);
|
||||
p.cx/=255.0f;
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,","));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.cy=atof(buf);
|
||||
p.cy/=255.0f;
|
||||
delete buf;
|
||||
s+=(i+1);
|
||||
s2=s;
|
||||
s2=(strstr(s2,"\""));
|
||||
i=s2-s;
|
||||
buf = new char[i];
|
||||
for(int c=0; c<i; c++)
|
||||
{
|
||||
buf[c]=*(s+c);
|
||||
}
|
||||
|
||||
p.cz=atof(buf);
|
||||
p.cz/=255.0f;
|
||||
delete buf;
|
||||
s+=i;
|
||||
}
|
||||
Wax::Wax(char* path)
|
||||
{
|
||||
FILE* f = fopen( path, "rb" );
|
||||
long len=0;
|
||||
char* string;
|
||||
fseek(f,0,SEEK_END);
|
||||
len = ftell(f);
|
||||
fclose(f);
|
||||
f = fopen( path, "rb" );
|
||||
string = new char[len];
|
||||
fread(string,1,len,f);
|
||||
fclose(f);
|
||||
count=0;
|
||||
char *s=string;
|
||||
loadconfig(s);
|
||||
while((s=strstr(s,(char*)"<object"))!=NULL)
|
||||
{
|
||||
count++;
|
||||
*s+=strlen((char*)"<object");
|
||||
}
|
||||
s=string;
|
||||
p=new Prim[count];
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
loadprim(s,p[i]);
|
||||
}
|
||||
}
|
19
waxloader.h
Normal file
19
waxloader.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "prim.h"
|
||||
|
||||
class Wax
|
||||
{
|
||||
public:
|
||||
Prim* p;
|
||||
float bcx,bcy,bcz;
|
||||
float anglex,angley;
|
||||
float radius;
|
||||
int count;
|
||||
Wax() {}
|
||||
Wax(char*path);
|
||||
void loadconfig(char*s);
|
||||
void loadprim(char*&s, Prim& p);
|
||||
};
|
Loading…
Reference in New Issue
Block a user