Torna indietro   Hardware Upgrade Forum > Software > Programmazione

iPhone 17 Pro: più di uno smartphone. È uno studio di produzione in formato tascabile
iPhone 17 Pro: più di uno smartphone. È uno studio di produzione in formato tascabile
C'è tanta sostanza nel nuovo smartphone della Mela dedicato ai creator digitali. Nuovo telaio in alluminio, sistema di raffreddamento vapor chamber e tre fotocamere da 48 megapixel: non è un semplice smartphone, ma uno studio di produzione digitale on-the-go
Intel Panther Lake: i processori per i notebook del 2026
Intel Panther Lake: i processori per i notebook del 2026
Panther Lake è il nome in codice della prossima generazione di processori Intel Core Ultra, che vedremo al debutto da inizio 2026 nei notebook e nei sistemi desktop più compatti. Nuovi core, nuove GPU e soprattutto una struttura a tile che vede per la prima volta l'utilizzo della tecnologia produttiva Intel 18A: tanta potenza in più, ma senza perdere in efficienza
Intel Xeon 6+: è tempo di Clearwater Forest
Intel Xeon 6+: è tempo di Clearwater Forest
Intel ha annunciato la prossima generazione di processori Xeon dotati di E-Core, quelli per la massima efficienza energetica e densità di elaborazione. Grazie al processo produttivo Intel 18A, i core passano a un massimo di 288 per ogni socket, con aumento della potenza di calcolo e dell'efficienza complessiva.
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 24-06-2005, 10:50   #221
mjordan
Bannato
 
L'Avatar di mjordan
 
Iscritto dal: Mar 2002
Città: Pescara - 未婚・恋人なし Moto: Honda CBR 1000 RR ‫Casco: XR1000 Diabolic 3
Messaggi: 27578
Quote:
Originariamente inviato da 71104
anche io ho fatto una casa nel lavoro per scuola: l'ho disegnata con 3D Studio Max 6, poi ho scaricato la documentazione del formato 3DS, ho salvato la casa in 3DS e l'ho caricata e visualizzata con questo mio programma MFC; ci potevi fare un bel po' di cose: la potevi ruotare col mouse, visualizzare in semitrasparenza, sezionare orizzontalmente, e ci potevi anche camminare dentro!
si trattava di una casa della quale dovevamo fare un progetto a scuola (disegno tecnico); io insieme al lavoro del progetto ho consegnato anche un floppy co sto programma

poi c'era un mio compagno che la voleva arredare cioè voleva installarsi 3D Studio Max anche lui e disegnarci la mobilia; sarebbe venuto molto carino, ma putroppo l'arredamento non si è più fatto causa maturità imminente
Perchè non posti il codice per la lettura dei file 3DS?
mjordan è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 10:57   #222
anx721
Senior Member
 
L'Avatar di anx721
 
Iscritto dal: Oct 2002
Città: Roma
Messaggi: 1502
.
__________________
Sun Certified Java Programmer
EUCIP Core Level Certified

European Certification of Informatics Professionals
anx721 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 11:07   #223
mjordan
Bannato
 
L'Avatar di mjordan
 
Iscritto dal: Mar 2002
Città: Pescara - 未婚・恋人なし Moto: Honda CBR 1000 RR ‫Casco: XR1000 Diabolic 3
Messaggi: 27578
Quote:
Originariamente inviato da 71104
anche io ho fatto una casa nel lavoro per scuola: l'ho disegnata con 3D Studio Max 6, poi ho scaricato la documentazione del formato 3DS, ho salvato la casa in 3DS e l'ho caricata e visualizzata con questo mio programma MFC; ci potevi fare un bel po' di cose: la potevi ruotare col mouse, visualizzare in semitrasparenza, sezionare orizzontalmente, e ci potevi anche camminare dentro!
si trattava di una casa della quale dovevamo fare un progetto a scuola (disegno tecnico); io insieme al lavoro del progetto ho consegnato anche un floppy co sto programma

poi c'era un mio compagno che la voleva arredare cioè voleva installarsi 3D Studio Max anche lui e disegnarci la mobilia; sarebbe venuto molto carino, ma putroppo l'arredamento non si è più fatto causa maturità imminente
Mi interesserebbe sapere anche come hai gestito (calcolato) le normali alla superfice, che tipo di lighting hai utilizzato e soprattutto come hai creato un rendering context con le MFC. Mi veniva in mente pure se una volta lette le coordinate dei vertici le hai normalizzate in qualche modo o le hai sparate su schermo in modo "raw".
mjordan è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 11:09   #224
DanieleC88
Senior Member
 
L'Avatar di DanieleC88
 
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
Quote:
Originariamente inviato da mjordan
Evidentemente non hai mai sentito parlare di glutSolidSphere(), glutSolidCube() e glutSolidTeapot()
Non uso GLUT... faccio tutto a manina, io... vi posto il codice da circa 700 linee per una stupidissima cassa? (SDL+OpenGL - la si può far ruotare col mouse, con la pressione di alcuni tasti ruota automaticamente, si possono abilitare e diabilitare alpha blending e illuminazione, cambiare texture durante l'esecuzione...)

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!
DanieleC88 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 11:44   #225
mjordan
Bannato
 
L'Avatar di mjordan
 
Iscritto dal: Mar 2002
Città: Pescara - 未婚・恋人なし Moto: Honda CBR 1000 RR ‫Casco: XR1000 Diabolic 3
Messaggi: 27578
Quote:
Originariamente inviato da DanieleC88
Non uso GLUT... faccio tutto a manina, io... vi posto il codice da circa 700 linee per una stupidissima cassa? (SDL+OpenGL - la si può far ruotare col mouse, con la pressione di alcuni tasti ruota automaticamente, si possono abilitare e diabilitare alpha blending e illuminazione, cambiare texture durante l'esecuzione...)
Ho visto che hanno fatto il sito nuovo di SDL... E hanno aggiunto parecchia documentazione... Prima o poi mi ci "espongo". Hai per caso visto com'e' la parte audio di questa libreria? (nel senso se e' ben documentata, facile da usare, molte o poche funzionalita', supporto per gli stream...)

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...
A che pagina? A me non risultava
Ho quì la versione PDF, se mi dici che pagina è gli do un'occhiata...
mjordan è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 12:06   #226
anx721
Senior Member
 
L'Avatar di anx721
 
Iscritto dal: Oct 2002
Città: Roma
Messaggi: 1502
Quote:
Originariamente inviato da DanieleC88
mjordan ha fatto una teiera, tu una sfera... possibile che io sia l'unico ad aver fatto una cassa che gira (e le fa girare)?
Io ho fatto il mazinga che esce dalla piattaforma e prende il volo

http://xoomer.virgilio.it/world721/mazinga/mazinga.html
__________________
Sun Certified Java Programmer
EUCIP Core Level Certified

European Certification of Informatics Professionals
anx721 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 12:08   #227
DanieleC88
Senior Member
 
L'Avatar di DanieleC88
 
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
Quote:
Originariamente inviato da mjordan
Ho visto che hanno fatto il sito nuovo di SDL... E hanno aggiunto parecchia documentazione... Prima o poi mi ci "espongo". Hai per caso visto com'e' la parte audio di questa libreria? (nel senso se e' ben documentata, facile da usare, molte o poche funzionalita', supporto per gli stream...)
Se devo essere sincero, con l'audio non ho mai trafficato molto, quindi non so darti un parere autorevole. In ogni caso, io non lo trovo estremamente difficile. Se vuoi, con SDL puoi anche utilizzare una funzione personalizzata per il mixing dei buffer audio prima della riproduzione da parte della scheda sonora, e grazie a SdlMixer, puoi anche caricare altri formati che non siano i comuni .wav grazie ad una sola riga di codice. Ad esempio, in un giochetto 2D che sto scrivendo, la musica di background è in formato .ogg e per caricarla mi basta questo:
Codice:
	background = Mix_LoadMUS("data/background.ogg");
Quote:
Originariamente inviato da mjordan
A che pagina? A me non risultava
Ho quì la versione PDF, se mi dici che pagina è gli do un'occhiata...
Io ho la versione in CHM, non so dirti a che pagina del PDF puoi trovarla. Comunque, nell'ottavo tutorial di NeHe, c'è questo (ricordavo male io, dovrebbe funzionare lo stesso, ma... leggi):
Quote:
Originariamente inviato da Jeff Molofee (NeHe)
Blending in OpenGL
We enable blending just like everything else. Then we set the equation, and turn off depth buffer writing when drawing transparent objects, since we still want objects behind the translucent shapes to be drawn. This isn't the proper way to blend, but most the time in simple projects it will work fine. Rui Martins Adds: The correct way is to draw all the transparent (with alpha < 1.0) polys after you have drawn the entire scene, and to draw them in reverse depth order (farthest first). This is due to the fact that blending two polygons (1 and 2) in different order gives different results, i.e. (assuming poly 1 is nearest to the viewer, the correct way would be to draw poly 2 first and then poly 1. If you look at it, like in reality, all the light comming from behind these two polys (which are transparent) has to pass poly 2 first and then poly 1 before it reaches the eye of the viewer. You should SORT THE TRANSPARENT POLYGONS BY DEPTH and draw them AFTER THE ENTIRE SCENE HAS BEEN DRAWN, with the DEPTH BUFFER ENABLED, or you will get incorrect results. I know this sometimes is a pain, but this is the correct way to do it.
L'unico problema è che nel mio programmino il blending non va se non disabilito prima il depth testing.
__________________

C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai!
DanieleC88 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 12:11   #228
DanieleC88
Senior Member
 
L'Avatar di DanieleC88
 
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
Quote:
Originariamente inviato da anx721
Io ho fatto il mazinga che esce dalla piattaforma e prende il volo

http://xoomer.virgilio.it/world721/mazinga/mazinga.html
Davvero bello, complimenti!
__________________

C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai!
DanieleC88 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 12:16   #229
anx721
Senior Member
 
L'Avatar di anx721
 
Iscritto dal: Oct 2002
Città: Roma
Messaggi: 1502
Quote:
Originariamente inviato da DanieleC88
Davvero bello, complimenti!

grazie...comuqnue siamo totalmente in off topic..
__________________
Sun Certified Java Programmer
EUCIP Core Level Certified

European Certification of Informatics Professionals
anx721 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 12:21   #230
DanieleC88
Senior Member
 
L'Avatar di DanieleC88
 
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
Quote:
Originariamente inviato da anx721
siamo totalmente off topic..
Hai ragione. Diamoci un taglio (come la focacceria, così facciamo anche contento fek ).
__________________

C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai!
DanieleC88 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 12:48   #231
mjordan
Bannato
 
L'Avatar di mjordan
 
Iscritto dal: Mar 2002
Città: Pescara - 未婚・恋人なし Moto: Honda CBR 1000 RR ‫Casco: XR1000 Diabolic 3
Messaggi: 27578
Quote:
Originariamente inviato da anx721
grazie...comuqnue siamo totalmente in off topic..
Veramente carino. Potevi postare il codice però...
mjordan è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 14:03   #232
71104
Bannato
 
L'Avatar di 71104
 
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
Quote:
Originariamente inviato da mjordan
Mi interesserebbe sapere anche come hai gestito (calcolato) le normali alla superfice,
per il calcolo vettoriale ho guardato un esempio di codice che ho trovato in Internet (più precisamente l'ho chiesto a un tizio che ho incontrato su Usenet su it.comp.programmare.win32); la formula per effettuare il calcolo non me la ricordo, ma la trovi nel codice.

Quote:
che tipo di lighting hai utilizzato
e che ne so io semplicemente ho abilitato le luci (una sola se non ricordo male) e ho specificato le normali; il resto l'ha fatto OpenGL

Quote:
e soprattutto come hai creato un rendering context con le MFC.
nulla di difficile: siccome ho utilizzato il modello Document/View, nella mia classe CChildView personalizzata ci ho messo un campo HGLRC e un campo CClientDC*; creato il device context (CClientDC altro non fa che chiamare GetDC) gli ho associato il rendering context, ho usato le normali API wglXxx insomma.

Quote:
Mi veniva in mente pure se una volta lette le coordinate dei vertici le hai normalizzate in qualche modo o le hai sparate su schermo in modo "raw".
ho lavorato parecchio per "normalizzarle" (è stata la parte più ardua se ben ricordo; il resto tutto sommato è stato semplice): in pratica se non ricordo male, prima ho calcolato la "bounding box" dell'intero modello memorizzandola con due vettori, poi ho calcolato il centro della bounding box e ho sottratto le sue componenti a tutti i vertici del modello (in modo da centrarlo), e infine l'ho scalato adeguatamente (qui ho fatto anche un po' di taratura).

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? ).
71104 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 14:04   #233
71104
Bannato
 
L'Avatar di 71104
 
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_)
71104 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 14:05   #234
71104
Bannato
 
L'Avatar di 71104
 
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;
}
71104 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 14:05   #235
71104
Bannato
 
L'Avatar di 71104
 
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_)
71104 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 14:06   #236
71104
Bannato
 
L'Avatar di 71104
 
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
uffaaaaaaa, non mi fa postare ChildView.cpp!!!

EDIT: allegato; tiè!
Allegati
File Type: txt View.txt (10.1 KB, 6 visite)

Ultima modifica di 71104 : 24-06-2005 alle 14:08.
71104 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 14:07   #237
71104
Bannato
 
L'Avatar di 71104
 
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_)
71104 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 14:07   #238
71104
Bannato
 
L'Avatar di 71104
 
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;
}
71104 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 14:12   #239
71104
Bannato
 
L'Avatar di 71104
 
Iscritto dal: Feb 2005
Città: Roma
Messaggi: 7029
Quote:
Originariamente inviato da DanieleC88
Altro P.S.: 71104, è vero, il codice per i .3ds ci interessa, posta tutto!
se volete posso anche allegarvi la documentazione del formato, che comunque trovate su www.wotsit.org
71104 è offline   Rispondi citando il messaggio o parte di esso
Old 24-06-2005, 14:24   #240
71104
Bannato
 
L'Avatar di 71104
 
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ò )
71104 è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


iPhone 17 Pro: più di uno smartphone. È uno studio di produzione in formato tascabile iPhone 17 Pro: più di uno smartphone. &Eg...
Intel Panther Lake: i processori per i notebook del 2026 Intel Panther Lake: i processori per i notebook ...
Intel Xeon 6+: è tempo di Clearwater Forest Intel Xeon 6+: è tempo di Clearwater Fore...
4K a 160Hz o Full HD a 320Hz? Titan Army P2712V, a un prezzo molto basso 4K a 160Hz o Full HD a 320Hz? Titan Army P2712V,...
Recensione Google Pixel Watch 4: basta sollevarlo e si ha Gemini sempre al polso Recensione Google Pixel Watch 4: basta sollevarl...
Elgato Embrace: una sedia ergonomica pro...
Brad Pitt torna in pista: F1 – Il Film a...
Hitachi Vantara annuncia la sua AI Facto...
Brembo passa all'alluminio riciclato al ...
HONOR pronta a sfidare gli iPad Pro con ...
OpenAI esce allo scoperto: confermati i ...
In arrivo altri due prodotti da Apple en...
Il tool per aggiornare da Windows 10 a W...
Rishi Sunak entra in Microsoft e Anthrop...
Porsche in poche ore chiude la formazion...
iPhone 17 disponibili su Amazon al prezz...
La Ferrari Elettrica non è la cau...
Ricarica da record: Zeekr supera i 1.300...
Un 'capezzolo' con feedback aptico al po...
Porsche Taycan Rush a Misano: prima al v...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 21:07.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Served by www3v