Historique des modifications - Message

Message #3327

Sujet: Générer une galaxie....


Type Date Auteur Contenu
Dernière modification 09-12-2007 20:49:11 diOxy
Pas de problèmes, voila :

Vue de dessus :


Vue de l'intérieur :


Partie du code qui génère le placement des soleils.

            Random rnd = new Random(1500);
			SceneNode sun = new SceneNode();

            // L'algorithme suivant provient d'un exemple de l'OpenSceneGraph
            // Pour ceux qui veulent voir l'original, c'est la Demo : osgpointsprite
            for (uint i = 0; i < nbetoiles/2; i++)
            {
                val = (i * 2.0f / (float)nbetoiles * 2.0f * 3.14159265359f);

                // Bras 1
                modx1 = rnd.Next(short.MaxValue) / (float)short.MaxValue*2;
                mody1 = rnd.Next(short.MaxValue) / (float)short.MaxValue*2;
                modz1 = ((rnd.Next(short.MaxValue) - (float)short.MaxValue / 2) / (float)(short.MaxValue)) * 3 / (val + 1);

                sunX = ((float)Math.Cos(val) * val + modx1) * etendue;
                sunZ = ((float)Math.Sin(val) * val + mody1) * etendue;
                sunY = modz1 * etendue;

                sun = smgr.AddBillboardSceneNode(smgr.RootSceneNode, new Dimension2Df(tailleDesSoleils, tailleDesSoleils), -1);
                sun.Position = new Vector3D(sunX, sunY, sunZ);
                sun.SetMaterialType(MaterialType.TransparentAddColor);
                sun.SetMaterialTexture(0, textures_soleils[rnd.Next(NbTexturesSoleils)]);
                sun.SetMaterialFlag(MaterialFlag.Lighting, false);

                // Bras 2
                modx2 = rnd.Next(short.MaxValue) / (float)short.MaxValue * 2;
                mody2 = rnd.Next(short.MaxValue) / (float)short.MaxValue * 2;
                modz2 = ((rnd.Next(short.MaxValue) - (float)short.MaxValue / 2) / (float)(short.MaxValue)) * 3 / (val + 1);

                sunX = (-(float)Math.Cos(val) * val + modx2) * etendue;
                sunZ = (-(float)Math.Sin(val) * val + mody2) * etendue;
                sunY = modz2 * etendue;

                sun = smgr.AddBillboardSceneNode(smgr.RootSceneNode, new Dimension2Df(tailleDesSoleils, tailleDesSoleils), -1);
                sun.Position = new Vector3D(sunX, sunY, sunZ);
                sun.SetMaterialType(MaterialType.TransparentAddColor);
                sun.SetMaterialTexture(0, textures_soleils[rnd.Next(NbTexturesSoleils)]);
                sun.SetMaterialFlag(MaterialFlag.Lighting, false);
            }
Création du message 09-12-2007 20:44:15 diOxy
Pas de problèmes, voila :

Vue de dessus :


Vue de l'intérieur :


Partie du code qui génère le placement des soleils.

            Random rnd = new Random(1500);
			SceneNode sun = new SceneNode();

            // L'algorithme suivant provient d'un exemple de l'OpenSceneGraph
            // Pour ceux qui veulent voir l'original, c'est la Demo : osgpointsprite
            for (uint i = 0; i < nbetoiles/2; i++)
            {
                val = (i * 2.0f / (float)nbetoiles * 2.0f * 3.14159265359f);

                // Bras 1
                modx1 = rnd.Next(short.MaxValue) / (float)short.MaxValue*2;
                mody1 = rnd.Next(short.MaxValue) / (float)short.MaxValue*2;
                modz1 = ((rnd.Next(short.MaxValue) - (float)short.MaxValue / 2) / (float)(short.MaxValue)) * 3 / (val + 1);

                sunX = ((float)Math.Cos(val) * val + modx1) * etendue;
                sunZ = ((float)Math.Sin(val) * val + mody1) * etendue;
                sunY = modz1 * etendue;

                sun = smgr.AddBillboardSceneNode(smgr.RootSceneNode, new Dimension2Df(tailleDesSoleils, tailleDesSoleils), -1);
                sun.Position = new Vector3D(sunX, sunY, sunZ);
                sun.SetMaterialType(MaterialType.TransparentAddColor);
                sun.SetMaterialTexture(0, textures_soleils[rnd.Next(NbTexturesSoleils)]);
                sun.SetMaterialFlag(MaterialFlag.Lighting, false);

                // Bras 2
                modx2 = rnd.Next(short.MaxValue) / (float)short.MaxValue * 2;
                mody2 = rnd.Next(short.MaxValue) / (float)short.MaxValue * 2;
                modz2 = ((rnd.Next(short.MaxValue) - (float)short.MaxValue / 2) / (float)(short.MaxValue)) * 3 / (val + 1);

                sunX = (-(float)Math.Cos(val) * val + modx2) * etendue;
                sunZ = (-(float)Math.Sin(val) * val + mody2) * etendue;
                sunY = modz2 * etendue;

                sun = smgr.AddBillboardSceneNode(smgr.RootSceneNode, new Dimension2Df(tailleDesSoleils, tailleDesSoleils), -1);
                sun.Position = new Vector3D(sunX, sunY, sunZ);
                sun.SetMaterialType(MaterialType.TransparentAddColor);
                sun.SetMaterialTexture(0, textures_soleils[rnd.Next(NbTexturesSoleils)]);
                sun.SetMaterialFlag(MaterialFlag.Lighting, false);
            }

Retour

Options Liens officiels Caractéristiques Statistiques Communauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1440 sujets
11337 messages
Dernier membre inscrit: Saidov17
156 invités en ligne
membre en ligne: -
RSS Feed