|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#221 | |
|
Bannato
Iscritto dal: Mar 2002
Città: Pescara - 未婚・恋人なし Moto: Honda CBR 1000 RR Casco: XR1000 Diabolic 3
Messaggi: 27578
|
Quote:
|
|
|
|
|
|
|
#222 |
|
Senior Member
Iscritto dal: Oct 2002
Città: Roma
Messaggi: 1502
|
.
__________________
Sun Certified Java Programmer EUCIP Core Level Certified European Certification of Informatics Professionals |
|
|
|
|
|
#223 | |
|
Bannato
Iscritto dal: Mar 2002
Città: Pescara - 未婚・恋人なし Moto: Honda CBR 1000 RR Casco: XR1000 Diabolic 3
Messaggi: 27578
|
Quote:
|
|
|
|
|
|
|
#224 | |
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
Quote:
P.S.: da quanto ho visto (e letto da NeHe), "glEnable(GL_BLEND);" non he effetti senza "glDisable(GL_DEPTH_TEST);". Non posso proprio utilizzare il depth testing con il blending attivo? Con il depth testing disattivato, vedo i lati sovrapposti... Altro P.S.: 71104, è vero, il codice per i .3ds ci interessa, posta tutto!
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|
|
|
|
|
|
#225 | ||
|
Bannato
Iscritto dal: Mar 2002
Città: Pescara - 未婚・恋人なし Moto: Honda CBR 1000 RR Casco: XR1000 Diabolic 3
Messaggi: 27578
|
Quote:
Quote:
Ho quì la versione PDF, se mi dici che pagina è gli do un'occhiata...
|
||
|
|
|
|
|
#226 | |
|
Senior Member
Iscritto dal: Oct 2002
Città: Roma
Messaggi: 1502
|
Quote:
http://xoomer.virgilio.it/world721/mazinga/mazinga.html
__________________
Sun Certified Java Programmer EUCIP Core Level Certified European Certification of Informatics Professionals |
|
|
|
|
|
|
#227 | |||
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
Quote:
Codice:
background = Mix_LoadMUS("data/background.ogg");
Quote:
Quote:
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|||
|
|
|
|
|
#228 | |
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
Quote:
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|
|
|
|
|
|
#229 | |
|
Senior Member
Iscritto dal: Oct 2002
Città: Roma
Messaggi: 1502
|
Quote:
grazie...comuqnue siamo totalmente in off topic..
__________________
Sun Certified Java Programmer EUCIP Core Level Certified European Certification of Informatics Professionals |
|
|
|
|
|
|
#230 | |
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
Quote:
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|
|
|
|
|
|
#231 | |
|
Bannato
Iscritto dal: Mar 2002
Città: Pescara - 未婚・恋人なし Moto: Honda CBR 1000 RR Casco: XR1000 Diabolic 3
Messaggi: 27578
|
Quote:
|
|
|
|
|
|
|
#232 | ||||
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
Quote:
Quote:
Quote:
Quote:
ma eccoti il codice; ora ti posto i files più interessanti uno alla volta (se quoto direttamente il codice, alcuni doppi punti mi vengono interpretati come faccine e non mi permette di inviare il messaggio per le troppe faccine; staff di HWU: ancora non avete sistemato questa cosa? |
||||
|
|
|
|
|
#233 |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
questo è Model.h, che contiene la dichiarazione delle classi del motore grafico (eeeeehhhhh, parolone!!!!!!
Codice:
// Model.h: interface for the CModel class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MODEL_H__C7AEA5BE_D39D_490E_B0CD_58715846EB97__INCLUDED_)
#define AFX_MODEL_H__C7AEA5BE_D39D_490E_B0CD_58715846EB97__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CVector : public CObject
{
DECLARE_DYNAMIC(CVector)
public:
float x, y, z, u, v;
CVector();
CVector(float x, float y, float z);
CVector(CVector a, CVector b);
CVector(const CVector &src);
void operator = (const CVector &src);
void operator *= (float f);
void operator /= (float f);
void Specify();
};
class CMaterial : public CObject
{
DECLARE_DYNAMIC(CMaterial)
public:
CString name;
COLORREF color;
CMaterial();
};
class CFace : public CObject
{
DECLARE_DYNAMIC(CFace)
public:
WORD a, b, c;
WORD flag;
CString materialName;
CMaterial *pMaterial;
float nx, ny, nz;
CFace();
CFace(const CFace &src);
void operator = (const CFace &src);
};
class CStudioObject : public CObject
{
DECLARE_DYNAMIC(CStudioObject)
public:
CString name;
bool bHidden;
CArray<CVector, CVector&> vertices;
CArray<CFace, CFace&> faces;
CTypedPtrList<CObList, CStudioObject*> children;
CStudioObject();
CStudioObject(const CStudioObject &src);
~CStudioObject();
void operator = (const CStudioObject &src);
void SetupNormals();
void MakeList();
};
class CModel : public CObject
{
DECLARE_DYNAMIC(CModel)
private:
GLuint gluiListIndex;
public:
CTypedPtrList<CObList, CStudioObject*> objects;
CTypedPtrList<CObList, CMaterial*> materials;
CVector min, max;
double matrix[16];
CModel();
virtual ~CModel();
bool LoadFromFile(LPCTSTR pszFileName);
void AssignMaterials();
void GetBoundingBox();
void Center();
void SetupNormals();
void MakeList(GLuint gluiIndex);
void Render();
void Reset();
};
#endif // !defined(AFX_MODEL_H__C7AEA5BE_D39D_490E_B0CD_58715846EB97__INCLUDED_)
|
|
|
|
|
|
#234 |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
Model.cpp:
Codice:
// Model.cpp: implementation of the CModel class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Casetta.h"
#include "Model.h"
#include "StudioFile.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
// CVector
IMPLEMENT_DYNAMIC(CVector, CObject)
CVector::CVector() {
x = 0;
y = 0;
z = 0;
u = 0;
v = 0;
}
CVector::CVector(float x, float y, float z) {
this->x = x;
this->y = y;
this->z = z;
u = 0;
v = 0;
}
CVector::CVector(CVector a, CVector b) {
x = b.x - a.x;
y = b.y - a.y;
z = b.z - a.z;
u = 0;
v = 0;
}
CVector::CVector(const CVector &src) {
operator = (src);
}
void CVector::operator = (const CVector &src) {
x = src.x;
y = src.y;
z = src.z;
u = src.u;
v = src.v;
}
void CVector::operator *= (float f) {
x *= f;
y *= f;
z *= f;
}
void CVector::operator /= (float f) {
x /= f;
y /= f;
z /= f;
}
void CVector::Specify() {
glTexCoord2f(u, v);
glVertex3f(x, y, z);
}
// CMaterial
IMPLEMENT_DYNAMIC(CMaterial, CObject)
CMaterial::CMaterial() {
color = 0x7F000000;
}
// CFace
IMPLEMENT_DYNAMIC(CFace, CObject)
CFace::CFace() {
pMaterial = NULL;
}
CFace::CFace(const CFace &src) {
operator = (src);
}
void CFace::operator = (const CFace &src) {
a = src.a;
b = src.b;
c = src.c;
flag = src.flag;
pMaterial = src.pMaterial;
}
// CStudioObject
IMPLEMENT_DYNAMIC(CStudioObject, CObject)
CStudioObject::CStudioObject() {
bHidden = false;
}
CStudioObject::~CStudioObject() {
for (POSITION p = children.GetHeadPosition(); p != NULL; ) {
delete children.GetNext(p);
}
children.RemoveAll();
}
void CStudioObject::operator = (const CStudioObject &src) {
name = src.name;
bHidden = src.bHidden;
vertices.Copy(src.vertices);
faces.Copy(src.faces);
}
void CStudioObject::SetupNormals() {
for (int i = 0; i < faces.GetSize(); i++) {
CVector v1(vertices[faces[i].a], vertices[faces[i].b]),
v2(vertices[faces[i].b], vertices[faces[i].c]);
float x = (v1.y * v2.z) - (v1.z * v2.y),
y = (v1.z * v2.x) - (v1.x * v2.z),
z = (v1.x * v2.y) - (v1.y * v2.x),
h = (float)sqrt(x * x + y * y + z * z);
faces[i].nx = x / h;
faces[i].ny = y / h;
faces[i].nz = z / h;
}
}
void CStudioObject::MakeList() {
for (int i = 0; i < faces.GetSize(); i++) {
glBegin(GL_POLYGON);
if (faces[i].pMaterial) {
glColor4ubv((GLubyte*)&faces[i].pMaterial->color);
}
else {
glColor3f(1, 1, 1);
}
CVector *a = &vertices[faces[i].a],
*b = &vertices[faces[i].b],
*c = &vertices[faces[i].c];
glNormal3f(faces[i].nx, faces[i].ny, faces[i].nz);
a->Specify();
b->Specify();
c->Specify();
glEnd();
}
for (POSITION p = children.GetHeadPosition(); p != NULL; ) {
children.GetNext(p)->MakeList();
}
}
// CModel
IMPLEMENT_DYNAMIC(CModel, CObject)
CModel::CModel() {
gluiListIndex = -1;
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glGetDoublev(GL_MODELVIEW_MATRIX, matrix);
glPopMatrix();
}
CModel::~CModel() {
Reset();
}
bool CModel::LoadFromFile(LPCTSTR pszFileName) {
CStudioFile file;
if (!file.Open(pszFileName, CFile::modeRead | CFile::shareDenyWrite)) {
return false;
}
Reset();
if (-1 == file.ProcessChunk(this)) {
AfxGetMainWnd()->MessageBox(_T("Bad file format."), NULL, MB_ICONERROR);
}
file.Close();
AssignMaterials();
SetupNormals();
GetBoundingBox();
return true;
}
void CModel::AssignMaterials() {
for (POSITION p = objects.GetHeadPosition(); p != NULL; ) {
CStudioObject *pObj = objects.GetNext(p);
for (int i = 0; i < pObj->faces.GetSize(); i++) {
for (POSITION q = materials.GetHeadPosition(); q != NULL; ) {
CMaterial *pMat = materials.GetNext(q);
if (pMat->name == pObj->faces[i].materialName) {
pObj->faces[i].pMaterial = pMat;
break;
}
}
}
}
}
void CModel::GetBoundingBox() {
min = CVector();
max = CVector();
for (POSITION p = objects.GetHeadPosition(); p != NULL; ) {
CStudioObject *pObj = objects.GetNext(p);
for (int i = 0; i < pObj->vertices.GetSize(); i++) {
if (pObj->vertices[i].x < min.x) {
min.x = pObj->vertices[i].x;
}
if (pObj->vertices[i].y < min.y) {
min.y = pObj->vertices[i].y;
}
if (pObj->vertices[i].z < min.z) {
min.z = pObj->vertices[i].z;
}
if (pObj->vertices[i].x > max.x) {
max.x = pObj->vertices[i].x;
}
if (pObj->vertices[i].y > max.y) {
max.y = pObj->vertices[i].y;
}
if (pObj->vertices[i].z > max.z) {
max.z = pObj->vertices[i].z;
}
}
}
}
void CModel::Center() {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
double x = 20 / (double)(max.x - min.x),
y = 20 / (double)(max.y - min.y),
z = 20 / (double)(max.z - min.z);
if ((z < x) && (z < y)) {
glScaled(z, z, z);
}
else {
if (x < y) {
glScaled(x, x, x);
}
else {
glScaled(y, y, y);
}
}
glTranslated(-(min.x + max.x) / 2, -(min.y + max.y) / 2, -(min.z + max.z) / 2);
glGetDoublev(GL_MODELVIEW_MATRIX, matrix);
glPopMatrix();
}
void CModel::SetupNormals() {
for (POSITION p = objects.GetHeadPosition(); p != NULL; ) {
objects.GetNext(p)->SetupNormals();
}
}
void CModel::MakeList(GLuint gluiIndex) {
gluiListIndex = gluiIndex;
glNewList(gluiIndex, GL_COMPILE);
glMultMatrixd(matrix);
for (POSITION p = objects.GetHeadPosition(); p != NULL; ) {
objects.GetNext(p)->MakeList();
}
glEndList();
}
void CModel::Render() {
glCallList(gluiListIndex);
}
void CModel::Reset() {
if (glIsList(gluiListIndex)) {
glDeleteLists(gluiListIndex, 1);
}
for (POSITION p = objects.GetHeadPosition(); p != NULL; ) {
delete objects.GetNext(p);
}
objects.RemoveAll();
for (p = materials.GetHeadPosition(); p != NULL; ) {
delete materials.GetNext(p);
}
materials.RemoveAll();
min = CVector(0, 0, 0);
max = min;
}
|
|
|
|
|
|
#235 |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
ChildView.h, contenente la dichiarazione della view:
Codice:
// ChildView.h : interface of the CChildView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_CHILDVIEW_H__444E212B_C6EF_49A2_9AB2_BC5478BDE438__INCLUDED_)
#define AFX_CHILDVIEW_H__444E212B_C6EF_49A2_9AB2_BC5478BDE438__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Model.h"
/////////////////////////////////////////////////////////////////////////////
// CChildView window
class CChildView : public CWnd
{
// Construction
public:
CChildView();
// Attributes
public:
// Operations
public:
void Draw();
void ResetParams();
void Reset();
void ResetAll();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CChildView)
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
CClientDC *pDC;
HGLRC hglrc;
int cx, cy;
double fov;
enum Graphics {grPoint, grLine, grFill} graphics;
enum Modes {mdWalkThrough, mdPerspective, mdOrthographic} mode;
bool bClip, bTextures, bBlending;
CModel model;
bool bUp, bLeft, bRight, bDown;
bool bDragging;
CPoint prevPos;
double rx, ry;
double angle, vx, vy, x, y, speed;
double plane[4];
virtual ~CChildView();
// Generated message map functions
protected:
//{{AFX_MSG(CChildView)
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnProgramReset();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnToolsGraphicsPoint();
afx_msg void OnUpdateToolsGraphicsPoint(CCmdUI* pCmdUI);
afx_msg void OnToolsGraphicsLine();
afx_msg void OnUpdateToolsGraphicsLine(CCmdUI* pCmdUI);
afx_msg void OnToolsGraphicsFill();
afx_msg void OnUpdateToolsGraphicsFill(CCmdUI* pCmdUI);
afx_msg void OnToolsGraphicsTextures();
afx_msg void OnUpdateToolsGraphicsTextures(CCmdUI* pCmdUI);
afx_msg void OnToolsGraphicsBlending();
afx_msg void OnUpdateToolsGraphicsBlending(CCmdUI* pCmdUI);
afx_msg void OnToolsModeWalkthrough();
afx_msg void OnUpdateToolsModeWalkthrough(CCmdUI* pCmdUI);
afx_msg void OnToolsModePerspective();
afx_msg void OnUpdateToolsModePerspective(CCmdUI* pCmdUI);
afx_msg void OnToolsModeOrthographic();
afx_msg void OnUpdateToolsModeOrthographic(CCmdUI* pCmdUI);
afx_msg void OnToolsModeClip();
afx_msg void OnUpdateToolsModeClip(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHILDVIEW_H__444E212B_C6EF_49A2_9AB2_BC5478BDE438__INCLUDED_)
|
|
|
|
|
|
#236 |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
uffaaaaaaa, non mi fa postare ChildView.cpp!!!
EDIT: allegato; tiè! Ultima modifica di 71104 : 24-06-2005 alle 14:08. |
|
|
|
|
|
#237 |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
StudioFile.h, dichiarazione della classe per leggere il formato 3DS:
Codice:
// StudioFile.h: interface for the CStudioFile class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_STUDIOFILE_H__AFC5E371_CFC0_4A08_9878_EF5E325EE3F6__INCLUDED_)
#define AFX_STUDIOFILE_H__AFC5E371_CFC0_4A08_9878_EF5E325EE3F6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CVector;
class CFace;
class CStudioObject;
class CModel;
class CStudioFile : public CFile
{
public:
bool bError;
float fUnit;
UINT ReadColor(COLORREF &result);
BYTE ReadByte(UINT &uLength);
WORD ReadWord(UINT &uLength);
DWORD ReadDWord(UINT &uLength);
float ReadFloat(UINT &uLength);
CString ReadString(UINT &uLength);
void SkipString(UINT &uLength);
CVector ReadVertex(UINT &uLength);
CFace ReadFace(UINT &uLength);
UINT ProcessChunk(CObject *pCookie);
void ReadSubChunks(UINT &uLength, CObject *pCookie);
void SkipChunk(UINT &uLength);
CStudioFile();
};
#endif // !defined(AFX_STUDIOFILE_H__AFC5E371_CFC0_4A08_9878_EF5E325EE3F6__INCLUDED_)
|
|
|
|
|
|
#238 |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
StudioFile.cpp, la relativa implementazione:
Codice:
// StudioFile.cpp: implementation of the CStudioFile class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Casetta.h"
#include "StudioFile.h"
#include "Model.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
// CStudioFile
UINT CStudioFile::ReadColor(COLORREF &result) {
WORD wChunkID;
UINT uResult, uLength;
Read(&wChunkID, 2);
Read(&uLength, 4);
uResult = uLength;
uLength -= 6;
switch (wChunkID) {
case 0x0010: // rgb float format
{
float b = ReadFloat(uLength),
g = ReadFloat(uLength),
r = ReadFloat(uLength);
result = ((char)(r * 0xFF) << 16) + ((char)(g * 0xFF) << 8) + (char)(b * 0xFF);
}
break;
case 0x0011: // rgb byte format
{
BYTE b = ReadByte(uLength),
g = ReadByte(uLength),
r = ReadByte(uLength);
result = (r << 16) + (g << 8) + b;
}
break;
case 0x0012: // rgbg byte format
case 0x0013: // rgbg float format
default: // unknown format
TRACE("skipping color chunk; chunk ID: 0x%X\n", (int)wChunkID);
SkipChunk(uLength);
break;
}
return uResult;
}
BYTE CStudioFile::ReadByte(UINT &uLength) {
BYTE bResult;
Read(&bResult, 1);
uLength--;
return bResult;
}
WORD CStudioFile::ReadWord(UINT &uLength) {
WORD wResult;
Read(&wResult, 2);
uLength -= 2;
return wResult;
}
DWORD CStudioFile::ReadDWord(UINT &uLength) {
DWORD dwResult;
Read(&dwResult, 4);
uLength -= 4;
return dwResult;
}
float CStudioFile::ReadFloat(UINT &uLength) {
float fResult;
Read(&fResult, 4);
uLength -= 4;
return fResult;
}
CString CStudioFile::ReadString(UINT &uLength) {
CString result;
int nCount = 0;
char byte;
do {
Read(&byte, 1);
result += byte;
nCount++;
} while (byte != 0);
uLength -= nCount;
return result;
}
void CStudioFile::SkipString(UINT &uLength) {
char byte;
do {
Read(&byte, 1);
uLength--;
} while (byte != 0);
}
CVector CStudioFile::ReadVertex(UINT &uLength) {
CVector result;
Read(&result.x, sizeof(float));
Read(&result.z, sizeof(float));
result.z = -result.z;
Read(&result.y, sizeof(float));
result /= fUnit;
uLength -= sizeof(float) * 3;
return result;
}
CFace CStudioFile::ReadFace(UINT &uLength) {
CFace result;
Read(&result.a, 2);
Read(&result.b, 2);
Read(&result.c, 2);
Read(&result.flag, 2);
uLength -= 2 * 4;
return result;
}
UINT CStudioFile::ProcessChunk(CObject *pCookie) {
WORD wChunkID;
UINT uResult, uLength;
Read(&wChunkID, 2);
Read(&uLength, 4);
uResult = uLength;
uLength -= 6;
if (pCookie->IsKindOf(RUNTIME_CLASS(CModel))) {
CModel *pModel = (CModel*)pCookie;
switch (wChunkID) {
case 0x4D4D: // main chunk
case 0x3D3D: // 3D editor
break;
case 0x0100: // one unit
fUnit = ReadFloat(uLength);
break;
case 0x4000: // object block
{
CStudioObject *pNew = new CStudioObject();
pModel->objects.AddTail(pNew);
pNew->name = ReadString(uLength);
ReadSubChunks(uLength, pNew);
}
break;
case 0xAFFF: // material block
{
CMaterial *pNew = new CMaterial();
pModel->materials.AddTail(pNew);
ReadSubChunks(uLength, pNew);
}
break;
default:
SkipChunk(uLength);
break;
}
}
else if (pCookie->IsKindOf(RUNTIME_CLASS(CStudioObject))) {
CStudioObject *pObj = (CStudioObject*)pCookie;
switch (wChunkID) {
case 0x4000: // object block
{
CStudioObject *pNew = new CStudioObject();
pObj->children.AddTail(pNew);
pNew->name = ReadString(uLength);
ReadSubChunks(uLength, pNew);
}
break;
case 0x4010: // object hidden
pObj->bHidden = true;
break;
case 0x4100: // triangular mesh
break;
case 0x4110: // vertices list
{
WORD wVertices = ReadWord(uLength);
while (wVertices > 0) {
pObj->vertices.Add(ReadVertex(uLength));
wVertices--;
}
}
break;
case 0x4120: // faces description
{
WORD wFaces = ReadWord(uLength);
while (wFaces > 0) {
pObj->faces.Add(ReadFace(uLength));
wFaces--;
}
}
break;
case 0x4130: // faces material list
{
CString materialName = ReadString(uLength);
WORD wFaces = ReadWord(uLength);
while (wFaces > 0) {
WORD wFaceIndex = ReadWord(uLength);
pObj->faces[wFaceIndex].materialName = materialName;
wFaces--;
}
}
break;
case 0x4140: // mapping coordinates list for each vertex
{
WORD wVertices = ReadWord(uLength);
int i = 0;
while (wVertices > 0) {
pObj->vertices[i].u = ReadFloat(uLength);
pObj->vertices[i].v = ReadFloat(uLength);
wVertices--;
i++;
}
}
break;
default:
SkipChunk(uLength);
break;
}
}
else if (pCookie->IsKindOf(RUNTIME_CLASS(CMaterial))) {
CMaterial *pMat = (CMaterial*)pCookie;
switch (wChunkID) {
case 0xA000: // material name
pMat->name = ReadString(uLength);
break;
case 0xA020: // material color
uLength -= ReadColor(pMat->color);
break;
default:
SkipChunk(uLength);
break;
}
}
else {
bError = true;
}
if (bError) {
return -1;
}
ReadSubChunks(uLength, pCookie);
return uResult;
}
void CStudioFile::ReadSubChunks(UINT &uLength, CObject *pCookie) {
while (uLength >= 6) {
uLength -= ProcessChunk(pCookie);
}
#ifdef _DEBUG
if (uLength > 0) {
TRACE("Checksum bad!\n");
}
#endif
}
void CStudioFile::SkipChunk(UINT &uLength) {
Seek(uLength, current);
uLength = 0;
}
CStudioFile::CStudioFile() {
bError = false;
fUnit = 1;
}
|
|
|
|
|
|
#239 | |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
Quote:
|
|
|
|
|
|
|
#240 |
|
Bannato
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
|
ATTENZIONE: sarò onesto; rileggendo il mio codice per il caricamento del formato 3DS ho notato diverse possibili falle di sicurezza nonché qualche mancanza dovuta alla fretta che avevo quando l'ho scritto; prendetelo solo come "esempio didattico", è meglio che non lo usate così com'è
come organizzazione mi sembra buono, ma necessita di numerose correzioni/aggiunte (forse un giorno se lavorerò di nuovo con la grafica 3D le farò |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 01:21.



















