![dev.gamez.lv Forum Index](templates/subSilver/images/logo_phpBB.gif) |
dev.gamez.lv Latvian Game Developers Community
|
View previous topic :: View next topic |
Author |
Message |
elvman Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 09 Apr 2003 Posts: 1278 Location: Kuldiga
|
Posted: Mon Jan 16, 2006 10:54 pm Post subject: Sphere |
|
Izmeklejos googlee bet neko sakariigu neatradu.Varbuut kaads zin kaa no triistuuriem (poligoniem) var uzdabuut sfeeru.Doma taada,ka ievadot detalizaacijas pakaapi,dabuu kaukaadu basiivu vai kauko tamliidziigu ar vertexiem.Luudzu paliidizet-pasham shausmiigi negribaas ar PI,radiusiem un diametriem rekjinaat.Ludzu paliidziet! _________________ long time; /* know C */ |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
bubu Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
elvman Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 09 Apr 2003 Posts: 1278 Location: Kuldiga
|
Posted: Mon Jan 16, 2006 11:11 pm Post subject: |
|
Viss ko esmu atradis pagaidam ir - Drawing an Icosahedron [ 20 sided sphere ].Bet tam ir tikai 20 skaldnes,tachu es gribeetu lai skaldnju skaitu kaukaa vareetu reguleet (kaa tas ir 3DS maxii). _________________ long time; /* know C */ |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
elvman Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 09 Apr 2003 Posts: 1278 Location: Kuldiga
|
Posted: Mon Jan 16, 2006 11:12 pm Post subject: |
|
Aaa paldies!Neidomaajos GLUT sourci apstiities.Gan jau izlobiishu un paarlikshu uz DX. _________________ long time; /* know C */ |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
bubu Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Mon Jan 16, 2006 11:19 pm Post subject: |
|
Hm, GLUT kodā gan nav sfēras uzmodelēšanas kods, cik es esmu tur skatījies. Viņš izmanto GLU kodu - gluSphere. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
elvman Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 09 Apr 2003 Posts: 1278 Location: Kuldiga
|
Posted: Mon Jan 16, 2006 11:43 pm Post subject: |
|
Code: | void FGAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
{
int i,j;
/* Adjust z and radius as stacks are drawn. */
double z0,z1;
double r0,r1;
/* Pre-computed circle */
double *sint1,*cost1;
double *sint2,*cost2;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSphere" );
fghCircleTable(&sint1,&cost1,-slices);
fghCircleTable(&sint2,&cost2,stacks*2);
/* The top stack is covered with a triangle fan */
z0 = 1.0;
z1 = cost2[(stacks>0)?1:0];
r0 = 0.0;
r1 = sint2[(stacks>0)?1:0];
glBegin(GL_TRIANGLE_FAN);
glNormal3d(0,0,1);
glVertex3d(0,0,radius);
for (j=slices; j>=0; j--)
{
glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 );
glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
}
glEnd();
/* Cover each stack with a quad strip, except the top and bottom stacks */
for( i=1; i<stacks-1; i++ )
{
z0 = z1; z1 = cost2[i+1];
r0 = r1; r1 = sint2[i+1];
glBegin(GL_QUAD_STRIP);
for(j=0; j<=slices; j++)
{
glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 );
glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
glNormal3d(cost1[j]*r0, sint1[j]*r0, z0 );
glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
}
glEnd();
}
/* The bottom stack is covered with a triangle fan */
z0 = z1;
r0 = r1;
glBegin(GL_TRIANGLE_FAN);
glNormal3d(0,0,-1);
glVertex3d(0,0,-radius);
for (j=0; j<=slices; j++)
{
glNormal3d(cost1[j]*r0, sint1[j]*r0, z0 );
glVertex3d(cost1[j]*r0*radius, sint1[j]*r0*radius, z0*radius);
}
glEnd();
/* Release sin and cos tables */
free(sint1);
free(cost1);
free(sint2);
free(cost2);
} |
Ir gan.Un diezgan logjiski visu var izvilkt.Shii funkcija izmanto funkciju fghCircleTable,kas manuprat ari izdara visu galveno matematiku. _________________ long time; /* know C */ |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
bubu Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Mon Jan 16, 2006 11:55 pm Post subject: |
|
Vai tu gadījumā nejauc FreeGLUT ar GLUT? Tas kods taču ir no FreeGLUT.
Lūdzu tev kods no GLUT (3.7 versijas):
Code: | void APIENTRY
glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
} |
dwn urlis
fghCircleTable dara visai primitīvu nevis galveno matemātiku - vienkārša sin/cos lookup table :) Lai nav atkārtoti vienas un tās pašas sin/cos vērtības jārēķina.
Last edited by bubu on Mon Jan 16, 2006 11:59 pm; edited 1 time in total |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
elvman Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 09 Apr 2003 Posts: 1278 Location: Kuldiga
|
Posted: Mon Jan 16, 2006 11:58 pm Post subject: |
|
Jaa chist tas bija no FreeGLUT. _________________ long time; /* know C */ |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
elvman Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 09 Apr 2003 Posts: 1278 Location: Kuldiga
|
Posted: Fri Apr 14, 2006 4:41 pm Post subject: |
|
Atkal savajadzeejaas to sfeeru,bet ieksh Direct3D.Ko dariit? Njemto to kodu no FreeGlut,vai arii kaadam ir kaads labaaks algoritms? _________________ long time; /* know C */ |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
bubu Indago Uzvarētājs
![Indago Uzvarētājs Indago Uzvarētājs](https://forums.gamedev.lv/images/ranks/cup1.gif)
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Sat Apr 15, 2006 7:41 pm Post subject: |
|
A kas tam vainas? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|