29 _sopen_s(&handle,
filename, _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
33 strerror_s(strerr, 99, errno);
34 sprintf_s(msg,
sizeof(msg),
"LoadDAW() could not load file \"%s\": %s",
filename, strerr);
41 _lseek(handle, 0L, SEEK_SET);
42 _read(handle, &polyobject.
vertices, 2);
43 sprintf_s(msg,
sizeof(msg),
"LoadDAW() loading \"%s\"...",
filename);
48 sprintf_s(msg,
sizeof(msg),
"LoadDAW() creating memory for %i vertices...", polyobject.
vertices);
51 if (FAILED(hr = DXUTGetD3D9Device()->CreateVertexBuffer(static_cast<long>(polyobject.
vertices) *
sizeof(
D3DVERTEX),
53 D3DPOOL_MANAGED, &polyobject.
VB, NULL)))
55 sprintf_s(msg,
sizeof(msg),
"LoadDAW() could not create memory for %i vertices! %x", polyobject.
vertices, hr);
61 V(polyobject.
VB->Lock(0, 0, reinterpret_cast<void**>(&vtx), 0));
63 D3DXVECTOR3 tempnormal;
64 for (
long s = 0; s < polyobject.
vertices; s++)
66 _lseek(handle, 2L + s * 32L + 0L, SEEK_SET);
67 _read(handle, &tempnormal, 12);
68 (*vtx).x = tempnormal.x;
69 (*vtx).y = tempnormal.y;
70 (*vtx).z = tempnormal.z;
71 _lseek(handle, 2L + s * 32L + 12L, SEEK_SET);
72 _read(handle, &tempnormal, 12);
73 (*vtx).nx = tempnormal.x;
74 (*vtx).ny = tempnormal.y;
75 (*vtx).nz = tempnormal.z;
76 _lseek(handle, 2L + s * 32L + 24L, SEEK_SET);
77 _read(handle, &tempnormal.x, 4);
78 _read(handle, &tempnormal.y, 4);
79 (*vtx).tu = tempnormal.x;
80 (*vtx).tv = tempnormal.y;
84 V(polyobject.
VB->Unlock());
99 _sopen_s(&handle,
filename, _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
102 sprintf_s(msg,
sizeof(msg),
"LoadDIX() could not open \"%s\"!",
filename);
106 _lseek(handle, 0, SEEK_SET);
110 _read(handle, &version, 4);
112 sprintf_s(msg,
sizeof msg,
"PolyObj %s CA",
filename);
121 sprintf_s(msg,
sizeof(msg),
"LoadDIX() could not open \"%s\"!",
filename);
128 sprintf_s(msg,
sizeof(msg),
"LoadDIX() initialized %i component(s)...",
componentTotal);
133 _lseek(handle, (
long)s * 100L + 99L, SEEK_SET);
134 _read(handle, &i_temp, 2);
136 _read(handle, &i_temp, 2);
160 if (version == 2.44f)
179 sprintf_s(msg,
sizeof(msg),
"LoadDIX() finished component list");
192 logger->
Log(
"PolyObj::GetComponent out-of-bound array value!", Logger::Level::Fatal);
202 sprintf_s(msg,
sizeof msg,
"PolyObj %s CA",
filename);
void LoadDIX(const char *prmFilename)
unsigned short componentTotal
LPDIRECT3DVERTEXBUFFER9 VB
s_mesh_component GetComponent(short i) const
s_mesh_component * componentarray
void Log(const char *msg, Level level=Info, int errorCode=0)
void AddTrackedResource(const char *name, _D3DPOOL pool=D3DPOOL_MANAGED)
s_polygon_object LoadDAW(const char *filename) const
void UpdateTrackedResource(const char *name, int status)
unsigned short GetComponents() const