16
Ok, following your instructions now it works.... You ARE GREAT
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
public void loadFerito(String name, float x, float y, float z){
Object3D animateMe=null;
texMan=TextureManager.getInstance();
texMan.addTexture(name+".jpg",new Texture(getDocumentBase(),"textures/feriti/"+name+".jpg"));
Object3D[] animArray=Loader.load3DS(getDocumentBase(),"3ds/"+name+"_anim.3ds", 20f);
animateMe=animArray[0];
animateMe.setCenter(SimpleVector.ORIGIN);
animateMe.translate (x, y+55, z);
animateMe.rotateX((float)-Math.PI/2);
animateMe.rotateMesh();
animateMe.setRotationMatrix(new Matrix());
animateMe.createTriangleStrips(2);
animateMe.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
animateMe.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
//animateMe.build();
Animation anim=new Animation(animArray.length);
anim.createSubSequence("standing-up");
for (int i=0; i<animArray.length; i++) {
animArray[i].build();
anim.addKeyFrame(animArray[i].getMesh().cloneMesh(true));
}
animateMe.setAnimationSequence(anim);
animateMe.animate(0);
theWorld.addObject(animateMe);
}
public class ThreeDSimApplet extends Applet implements Runnable, KeyListener, MouseListener {
.
.
.
FrameBuffer buffer=null;
World theWorld;
TextureManager texMan=null;
private Camera camera=null;
.
.
.
public void init() {
theWorld=new World();
.
.
.
public void loadFerito(String name, float x, float y, float z){
Object3D ferito=null;
texMan=TextureManager.getInstance();
texMan.addTexture(name+".jpg",new Texture(getDocumentBase(),"textures/feriti/"+name+".jpg"));
Object3D[] feritoArray=Loader.load3DS(getDocumentBase(),"3ds/"+name+".3ds", 20f);
ferito=feritoArray[0];
ferito.setCenter(SimpleVector.ORIGIN);
ferito.translate (x, y+50, z);
ferito.rotateX((float)-Math.PI/2);
ferito.rotateMesh();
ferito.setRotationMatrix(new Matrix());
ferito.createTriangleStrips(2);
ferito.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
ferito.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
ferito.enableLazyTransformations();
theWorld.addObject(ferito);
}
Object3D[] animArray=Loader.load3DS(getDocumentBase(),"3ds/ferito_anim.3ds", 20f);
Animation anim;
anim=new Animation(n);
ferito1=(-591,-74,-90)
ferito2=(-766,-82,246)
public void init() {
theWorld=new World();
String param = getParameter("FileToRead");
if ( param != null){
FileToRead = new String(param);
}
// Now read the file.
readConfigFile();
.
.
.
theWorld.addObject(mondo);
theWorld.addObject(ferito);
public void loadFerito(String name, float x, float y, float z){
texMan=TextureManager.getInstance();
texMan.addTexture(name+".jpg",new Texture(getDocumentBase(),"textures/feriti/"+name+".jpg"));
Object3D[] feritoArray=Loader.load3DS(getDocumentBase(),"3ds/"+name+".3ds", 20f);
ferito=new Object3D(0);
ferito=feritoArray[0];
ferito.setCenter(SimpleVector.ORIGIN);
ferito.translate (x, y+50, z);
ferito.rotateX((float)-Math.PI/2);
ferito.rotateMesh();
ferito.setRotationMatrix(new Matrix());
ferito.createTriangleStrips(2);
ferito.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
ferito.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
ferito.enableLazyTransformations();
}
Loading Texture...textures/feriti/ferito1.jpg
Loading file 3ds/ferito1.3ds
File 3ds/ferito1.3ds loaded...55321 bytes
Processing new material 1.Mat0Tex1!
Processing object from 3DS-file: polySur
Object 'polySur_jPCT0' created using 694 polygons and 354 vertices.
Created 183 triangle-strips for polySur_jPCT0 in 1 pass(es)
Loading Texture...textures/feriti/ferito2.jpg
Loading file 3ds/ferito2.3ds
File 3ds/ferito2.3ds loaded...54631 bytes
Processing new material 1.Mat0Tex1!
Processing object from 3DS-file: polySur
Object 'polySur_jPCT4' created using 706 polygons and 360 vertices.
Created 178 triangle-strips for polySur_jPCT4 in 1 pass(es)
theWorld.addObject(ferito)
is outside loadFerito() and so it passes just the last value of ferito to init(). So I’ve tried to move theWorld.addObject(ferito)
in the last line of the loadFerito method (and even theWorld=new World()
to avoid a null exception) to try to add an obj to the world for every ferito’s occurance, but nothing changes... Any suggestion.....Bye and thanks
if (event.getButton()==MouseEvent.BUTTON3) {
cameraPosition=camera.getPosition();
cameraX=(int)cameraPosition.x;
cameraY=(int)cameraPosition.y;
cameraZ=(int)cameraPosition.z;
clicked=true;
rightClick=true;
}
public void loadFerito(String name, float x, float y, float z){
texMan=TextureManager.getInstance();
texMan.addTexture(name+".jpg",new Texture(getDocumentBase(),"textures/feriti/"+name+".jpg"));
Object3D[] ferito1Array=Loader.load3DS(getDocumentBase(),"3ds/"+name+".3ds", 20f);
ferito1=new Object3D(0);
ferito1=ferito1Array[0];
ferito1.setCenter(SimpleVector.ORIGIN);
ferito1.translate (x, y+109, z);
ferito1.rotateX((float)-Math.PI/2);
ferito1.rotateMesh();
ferito1.setRotationMatrix(new Matrix());
ferito1.createTriangleStrips(2);
ferito1.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
ferito1.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
ferito1.enableLazyTransformations();
}
File dir=new File("C:/Programmi/Java_SDK/bin/textures");
String[] files=dir.list();
for (int i=0; i<files.length; i++) {
String name=files[i];
if (name.endsWith(".jpg")) {
texMan.addTexture(name, new Texture(getDocumentBase(),"textures/"+name));
}
}
Object3D[] ferito1Array=Loader.load3DS(getDocumentBase(),"3ds/ferito1.3ds", 20f);
ferito1=new Object3D(0);
ferito1=ferito1Array[0];
ferito1.setCenter(SimpleVector.ORIGIN);
ferito1.rotateX((float)-Math.PI/2);
ferito1.rotateMesh();
ferito1.setRotationMatrix(new Matrix());
ferito1.createTriangleStrips(2);
ferito1.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
ferito1.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
ferito1.enableLazyTransformations();
ERROR: A texture with the name 'ferito1.jpg' has been declared twice!
texMan.addTexture("car1.jpg",new Texture(getDocumentBase(),"textures/car1.jpg"));
File dir=new File("textures");
String[] files=dir.list();
for (int i=0; i<files.length; i++) {
String name=files[i];
if (name.endsWith(".jpg")) {
texMan.addTexture(name, new Texture("textures"+File.separator+name));
}
}
java.lang.NullPointerException
at ThreeDSimApplet.init(ThreeDSimApplet.java:238)
at sun.applet.AppletPanel.run(AppletPanel.java:348)
at java.lang.Thread.run(Thread.java:536)