Flash i trzeci wymiar

Technologia Flash, czyli animacja na potrzeby stron WWW to świat daleko odbiegły od zwykłego programowania i kodu. Zapytaj o pomoc i podziel się z nami Twoimi problemami z zakresu Flasha.
petercave
Posty: 3
Rejestracja: wt lis 02, 2004 11:14 am
Kontakt:

Flash i trzeci wymiar

Post autor: petercave »

Co myślicie o wykorzystaniu "trzeciego wymiaru" we Flashu? Na http://www.galeria-3d.prv.pl/ znajdują się moje próby wdrożenia 3d do Flasha. Zrobilem taki mikro silnik 3d... Jak na razie zauważam jedną wielką wadę użycia trzeciego wymiaru: takie animacje potrzebują dość szybkich komputerów:(. Powoduje to, że takie bajery są dostepne tylko dla internautów z dość szybkimi maszynami. Co Wy o tym myślicie?
Dawid Kulbaka
Administrator
Posty: 951
Rejestracja: śr cze 05, 2002 9:48 pm
Lokalizacja: Bydgoszcz
Kontakt:

Re: Flash i trzeci wymiar

Post autor: Dawid Kulbaka »

niezle wrazenie robi, ale trzeba sie z Toba zgodzic, ponadto wydaje mi się, że zbyt "zabajerowana", tj. efektom nic nie bede ujmował, bo sa bardzo dobre, ale chyba nie praktyczne - jesli chodzi o np. postawienie swojej galerii zdjec?
petercave
Posty: 3
Rejestracja: wt lis 02, 2004 11:14 am
Kontakt:

Re: Flash i trzeci wymiar

Post autor: petercave »

Tez mi sie wydaje, ze efekty troche nie bardzo pasuja do galerii zdjec, ale najpierw zrobilem animacje (www.flash3d.prv.pl) a potem musialem do niej dodac jakąś treść, żeby wystartować w konkursie...
burek
Nowy
Nowy
Posty: 128
Rejestracja: pn cze 07, 2004 2:43 pm
Lokalizacja: Krk/Zgc

Re: Flash i trzeci wymiar

Post autor: burek »

Na pewno nie opłaca sie robić galerii 3d we Flashu gdyż zajedzie to procka. Oczywiście jest to możliwe - do każdego duplikatu mc ładujesz zdjęcie z odpowiednim indeksem, dodajesz preloader jako funkcje i jest ok. Tylko nie wiem jaki procek musiałbys mieć, aby przy dosyć wysokim fps np 30 i załóżmy 40 zdjęciach widocznych na raz na scenie (czyli bez unload ani remove) mogło Ci to płynnie chodzić. Ogólnie efekty 3d we flashu pozostawiają wiele do życzenia pod względem wydajności, ale przecież od tego mamy inne programy.
LHT
Posty: 13
Rejestracja: sob maja 10, 2003 12:46 am

Re: Flash i trzeci wymiar

Post autor: LHT »

Fajne, u mnie działa w miare dobrze (tak na oko 20 klatek na sekunde:) mam atlona2500 dla porównania) nie znam się za bardzo na flashu ale robiłem stronke w cult 3d i spodobało mnie się :) ( przykładzik http://lht.w.interia.pl/file_01.html )
na moim kompie działa bardzo dobrze ale u kolegi zarywa niemiłosiernie
myslę że jakbyś udeżył z tym swoim pomysłem w ten deseń to mogło by być ciekawie (nie wiem na ile to możliwe)
Pozdrawiam
burek
Nowy
Nowy
Posty: 128
Rejestracja: pn cze 07, 2004 2:43 pm
Lokalizacja: Krk/Zgc

Re: Flash i trzeci wymiar

Post autor: burek »

Ostatnio też coś się zainteresowałem 3D ale uznałem, że we Flashu nie ma on praktycznie sensu. Powód? Wklej sobie w pierwszej klatce taki kod:

Kod: Zaznacz cały

Matrix = new Array(4);
Rot = new Array(4);
for (iter=0; iter<4; iter++) {
	Matrix[iter] = new Array(4);
	Rot[iter] = new Array(4);
}
function MMatrix() {
	var Element = new Array(4);
	for (iter=0; iter<4; iter++) {
		Element[iter] = new Array(4);
	}
	for (iter=0; iter<4; iter++) {
		for (jter=0; jter<4; jter++) {
			Element[iter][jter] = 0.0;
			for (kter=0; kter<4; kter++) {
				Element[iter][jter] += Matrix[iter][kter]*Rot[kter][jter];
			}
		}
	}
	Matrix = Element;
}
function loadIdentity() {
	Matrix[0][0] = 1.0;
	Matrix[0][1] = 0.0;
	Matrix[0][2] = 0.0;
	Matrix[0][3] = 0.0;
	Matrix[1][0] = 0.0;
	Matrix[1][1] = 1.0;
	Matrix[1][2] = 0.0;
	Matrix[1][3] = 0.0;
	Matrix[2][0] = 0.0;
	Matrix[2][1] = 0.0;
	Matrix[2][2] = 1.0;
	Matrix[2][3] = 0.0;
	Matrix[3][0] = 0.0;
	Matrix[3][1] = 0.0;
	Matrix[3][2] = 0.0;
	Matrix[3][3] = 1.0;
}
function rotateX(angle) {
	cos = Math.cos(angle);
	sin = Math.sin(angle);
	Rot[0][0] = 1.0;
	Rot[0][1] = 0.0;
	Rot[0][2] = 0.0;
	Rot[0][3] = 0.0;
	Rot[1][0] = 0.0;
	Rot[1][1] = cos;
	Rot[1][2] = -sin;
	Rot[1][3] = 0.0;
	Rot[2][0] = 0.0;
	Rot[2][1] = sin;
	Rot[2][2] = cos;
	Rot[2][3] = 0.0;
	Rot[3][0] = 0.0;
	Rot[3][1] = 0.0;
	Rot[3][2] = 0.0;
	Rot[3][3] = 1.0;
	MMatrix();
}
function rotateY(angle) {
	cos = Math.cos(angle);
	sin = Math.sin(angle);
	Rot[0][0] = cos;
	Rot[0][1] = 0.0;
	Rot[0][2] = sin;
	Rot[0][3] = 0.0;
	Rot[1][0] = 0.0;
	Rot[1][1] = 1.0;
	Rot[1][2] = 0.0;
	Rot[1][3] = 0.0;
	Rot[2][0] = -sin;
	Rot[2][1] = 0.0;
	Rot[2][2] = cos;
	Rot[2][3] = 0.0;
	Rot[3][0] = 0.0;
	Rot[3][1] = 0.0;
	Rot[3][2] = 0.0;
	Rot[3][3] = 1.0;
	MMatrix();
}
function rotateZ(angle) {
	cos = Math.cos(angle);
	sin = Math.sin(angle);
	Rot[0][0] = cos;
	Rot[0][1] = -sin;
	Rot[0][2] = 0.0;
	Rot[0][3] = 0.0;
	Rot[1][0] = sin;
	Rot[1][1] = cos;
	Rot[1][2] = 0.0;
	Rot[1][3] = 0.0;
	Rot[2][0] = 0.0;
	Rot[2][1] = 0.0;
	Rot[2][2] = 1.0;
	Rot[2][3] = 0.0;
	Rot[3][0] = 0.0;
	Rot[3][1] = 0.0;
	Rot[3][2] = 0.0;
	Rot[3][3] = 1.0;
	MMatrix();
}
function translate(_pX, _pY, _pZ) {
	Rot[0][0] = 1.0;
	Rot[0][1] = 0.0;
	Rot[0][2] = 0.0;
	Rot[0][3] = _pX;
	Rot[1][0] = 0.0;
	Rot[1][1] = 1.0;
	Rot[1][2] = 0.0;
	Rot[1][3] = _pY;
	Rot[2][0] = 0.0;
	Rot[2][1] = 0.0;
	Rot[2][2] = 1.0;
	Rot[2][3] = _pZ;
	Rot[3][0] = 0.0;
	Rot[3][1] = 0.0;
	Rot[3][2] = 0.0;
	Rot[3][3] = 1.0;
	MMatrix();
}
function scale(_sX, _sY, _sZ) {
	Rot[0][0] = _sX;
	Rot[0][1] = 0.0;
	Rot[0][2] = 0.0;
	Rot[0][3] = 0.0;
	Rot[1][0] = 0.0;
	Rot[1][1] = _sY;
	Rot[1][2] = 0.0;
	Rot[1][3] = 0.0;
	Rot[2][0] = 0.0;
	Rot[2][1] = 0.0;
	Rot[2][2] = _sZ;
	Rot[2][3] = 0.0;
	Rot[3][0] = 0.0;
	Rot[3][1] = 0.0;
	Rot[3][2] = 0.0;
	Rot[3][3] = 1.0;
	MMatrix();
}
Dist = 300.0;
Xmin = Ymin=-500.0;
Xmax = Ymax=500.0;
Umin = Vmin=0;
Umax = Stage.width;
Vmax = Stage.height;
Obszar = new Object();
Obszar.onResize = function() {
	Umax = Stage.width;
	Vmax = Stage.height;
};
Stage.addListener(Obszar);
Stage.scaleMode = "noBorder";
function WXTSU(worldX) {
	return (Xmin-worldX)*(UMax-UMin)/(Xmin-Xmax)+Umin+0.5;
}
function WYTSV(worldY) {
	return (Ymax-worldY)*(Vmax-VMin)/(Ymax-Ymin)+Vmin+0.5;
}
function Model3D(nazwa, layer) {
	this.Vertex = new Array(8);
	for (iter=0; iter<8; iter++) {
		this.Vertex[iter] = new Array(3);
	}
	this.Vertex[0][0] = -100;
	this.Vertex[0][1] = -100;
	this.Vertex[0][2] = -100;
	this.Vertex[1][0] = 100;
	this.Vertex[1][1] = -100;
	this.Vertex[1][2] = -100;
	this.Vertex[2][0] = 100;
	this.Vertex[2][1] = 100;
	this.Vertex[2][2] = -100;
	this.Vertex[3][0] = -100;
	this.Vertex[3][1] = 100;
	this.Vertex[3][2] = -100;
	this.Vertex[4][0] = -100;
	this.Vertex[4][1] = -100;
	this.Vertex[4][2] = 100;
	this.Vertex[5][0] = 100;
	this.Vertex[5][1] = -100;
	this.Vertex[5][2] = 100;
	this.Vertex[6][0] = 100;
	this.Vertex[6][1] = 100;
	this.Vertex[6][2] = 100;
	this.Vertex[7][0] = -100;
	this.Vertex[7][1] = 100;
	this.Vertex[7][2] = 100;
	this.Edge = new Array(12);
	for (iter=0; iter<12; iter++) {
		this.Edge[iter] = new Array(2);
	}
	this.Edge[0][0] = 0;
	this.Edge[0][1] = 1;
	this.Edge[1][0] = 1;
	this.Edge[1][1] = 2;
	this.Edge[2][0] = 2;
	this.Edge[2][1] = 3;
	this.Edge[3][0] = 3;
	this.Edge[3][1] = 0;
	this.Edge[4][0] = 4;
	this.Edge[4][1] = 5;
	this.Edge[5][0] = 5;
	this.Edge[5][1] = 6;
	this.Edge[6][0] = 6;
	this.Edge[6][1] = 7;
	this.Edge[7][0] = 7;
	this.Edge[7][1] = 4;
	this.Edge[8][0] = 0;
	this.Edge[8][1] = 4;
	this.Edge[9][0] = 1;
	this.Edge[9][1] = 5;
	this.Edge[10][0] = 2;
	this.Edge[10][1] = 6;
	this.Edge[11][0] = 3;
	this.Edge[11][1] = 7;
	this.Name = nazwa;
	_root.createEmptyMovieClip(this.Name, layer);
}
Model3D.prototype.renderView = function() {
	with (eval(this.Name)) {
		Clear();
		lineStyle(1, 0x000000, 100);
		var TransX = new Array(8);
		var TransY = new Array(8);
		var TransZ = new Array(8);
		for (iter=0; iter<8; iter++) {
			TransX[iter] = Matrix[0][0]*this.Vertex[iter][0]+Matrix[0][1]*this.Vertex[iter][1]+Matrix[0][2]*this.Vertex[iter][2]+Matrix[0][3];
			TransY[iter] = Matrix[1][0]*this.Vertex[iter][0]+Matrix[1][1]*this.Vertex[iter][1]+Matrix[1][2]*this.Vertex[iter][2]+Matrix[1][3];
			TransZ[iter] = Matrix[2][0]*this.Vertex[iter][0]+Matrix[2][1]*this.Vertex[iter][1]+Matrix[2][2]*this.Vertex[iter][2]+Matrix[2][3];
			TransX[iter] = TransX[iter]*Dist/TransZ[iter];
			TransY[iter] = TransY[iter]*Dist/TransZ[iter];
		}
		for (iter=0; iter<12; iter++) {
			screenX = WXTSU(TransX[this.Edge[iter][0]]);
			screenY = WYTSV(TransY[this.Edge[iter][0]]);
			moveTo(screenX, screenY);
			screenX = WXTSU(TransX[this.Edge[iter][1]]);
			screenY = WYTSV(TransY[this.Edge[iter][1]]);
			lineTo(screenX, screenY);
		}
	}
};
Model = new Model3D("Test", 1);
loadIdentity();
translate(0.0, 0.0, 350.0);
uruchom i zobacz jak Ci śmiga. Nawet jeśli chodzi dobrze, to spójrz, ile trzeba się napisać a praktycznie gówno z tego mamy. Flash sam w sobie nie nadaje się do 3D i koniec :twisted:
paszczak
Nowy
Nowy
Posty: 123
Rejestracja: ndz paź 03, 2004 2:21 pm
Lokalizacja: Sopot
Kontakt:

Re: Flash i trzeci wymiar

Post autor: paszczak »

nieco off-topic ale nie tak do konca...

do 3d znacznie lepsze sa inne narzedzia,
np. Viewpoint daje niesamowite mozliwosci (podobnie jak Cult3D)
niestety wymagaja swoich plug-in'ow...

troche sie tym pierwszym bawilem narazie z dosc miernymi rezultatami:
jacht Lea w 3d
ale na pewno jeszcze do tego wroce.

swietne efekty daje mozliwosc uzywania plikow Flash'a jako tekstur....
ODPOWIEDZ