cs_amjad
Messages postés1Date d'inscriptionlundi 6 janvier 2003StatutMembreDernière intervention24 mai 2003
-
24 mai 2003 à 16:22
cs_Duss
Messages postés890Date d'inscriptionlundi 8 avril 2002StatutMembreDernière intervention29 juillet 2004
-
25 mai 2003 à 15:07
A la compilation d'un projet java3D j'obtient le message d'erreur suivant :
Exception in thread "main" java.lang.NullPointerException
at javax.vecmath.Tuple2f.<Tuple2f.java:66>
at javax.vecmath.TexCoord2f.<TexCoord2f.java:64>
at com.sun.j3d.utils.geometry.GeometryInfo.setTextureCoordinates<GeometryInfo.java:1001>
at hopSimu.ShapeImmeuble.ConstruireImmeuble<ShapeImmeuble.java:104>
at hopSimu.ShapeImmeuble.<ShapeImmeuble.java:31>
at hop3D.HopWorld.<HopWorld.java:44>
at GSimu3D.<GSimu3D.java:31>
at GSimu3D.main<GSimu3D.java:124>
C'est un programme de simulation de déplacement de voiture dans une ville avec des immeubles en 3D.
//constructor
public ShapeImmeuble(GGraphe im, Hop3D h)
{
immeuble=im;
hop = h;
ConstruireImmeuble();
}
public GGraphe getImmeuble(){ return immeuble;}
//accesseur aux points qui définissent le toit de l'immeuble
public Point3f getPointsToitImmeuble(int i) {return pointsimmeuble[immeuble.getNbrSommets()+i];}
//method
public void ConstruireImmeuble()
{
int PointsFondation = immeuble.getNbrSommets() ; //on récupère le nb de sommets enregistrés
int NbrPoints = 2 * PointsFondation; // a chaque sommet correspond un point en hauteur
int NbrQuad = immeuble.getNbrArcs(); //a chaque arc correspond un pan de mur
int NbrIndices = 4 * NbrQuad; // 4 points par surface
Point2f[] texCoords;
// on rempli le tableau de point dont les indices vont nous servir pour construir le tIndices
pointsimmeuble = new Point3f[NbrPoints];
texCoords = new Point2f[NbrIndices];
//on reference les point au sol
for (int i=0; i < PointsFondation ;i++)
{
pointsimmeuble[i] = new Point3f((float)immeuble.getSommet(i).getX(), 0.0f, (float)immeuble.getSommet(i).getY());
}
//on réference les points du toit
for (int i = PointsFondation; i < NbrPoints; i++)
{
pointsimmeuble[i] = new Point3f((float)immeuble.getSommet(i-PointsFondation).getX(), hauteur, (float)immeuble.getSommet(i-PointsFondation).getY());
}
//on construit Tindice qui va grouper 4 par 4 les points pour en faire des surfaces
// a chaque valeur de i correspond 4 point faisant une face
TIndices = new int[NbrIndices];
int j=0;
// traitement des premieres faces
for (int i=0; i<NbrQuad-1 ; i++)
{
TIndices[j]= i;
TIndices[j+1]=i+1;
TIndices[j+2]=PointsFondation+i+1;
TIndices[j+3]=PointsFondation+i;
j+=4;
}
// traitement de la derniere face
TIndices[j] = PointsFondation - 1;
TIndices[j+1] = 0;
TIndices[j+2] = PointsFondation;
TIndices[j+3] = NbrPoints - 1;
immeubleGI = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
public class GSimu3D implements Runnable
{
private GSimu simu;
private Hop3D hop3dDevice;
private HopCamera cam;
private HopWorld hopWorld;
private Random random ;
private Thread thread ;
private int animSpeed ;
private int frameWidth=500, frameHeight=500 ;
private int nbVoitures;
public GSimu3D()
{
simu = new GSimu();
random = new Random() ;
hop3dDevice = new Hop3D();
thread = null ;
animSpeed = 10 ;
//cam = new HopCamera(new Point3d(25.0, 30.0, 100.0), new Point3d(25.0, 10.0, 10.0));
hopWorld = new HopWorld(hop3dDevice, (GGraphe)simu);
nbVoitures = 0;
HopVehicules testVehicules = new HopVehicules(hop3dDevice);
for (;;)
{
if (nbVoitures < 5)
{
GVehicule vehicule = new GVehicule();
GSommet somSource, somPuit;
somSource = ((GGraphe)simu).getRandomSommet();
somPuit = somSource;
while (somPuit == somSource)
somPuit = ((GGraphe)simu).getRandomSommet();
cs_Duss
Messages postés890Date d'inscriptionlundi 8 avril 2002StatutMembreDernière intervention29 juillet 200411 25 mai 2003 à 15:07
salut,
visiblement c est cette ligne qui fait tout foirer :
immeubleGI.setTextureCoordinates(texCoords);
est ce que tu as bien initialisé ton tableau ????
(ou rempli)
Duss