1
Support / Re: Texture and MD2
« on: June 09, 2008, 10:48:46 pm »
Thanks for your quick reply.
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.
World worldx = new World();
ModelFactory modelFactory = ModelFactory.getInstance();
BaseEntity[] fields = new BaseEntity[4];
Object3D[] cruz = null;
if (SHOW_ORIGIN){
/* cruz = Loader.loadOBJ("/home/miguel/perfectday_project/TestProfectDay3D/models/xCoord.obj", "/home/miguel/perfectday_project"" /TestProfectDay3D/models/xCoord.mtl", 1.0f);*/
// cruz = Loader.load3DS("/home/miguel/perfectday_project/TestProfectDay3D/models/xCoord.3ds", 1.0f);
for (int i = 0; i < cruz.length; i++) {
worldx.addObject(cruz[i]);
}
}
worldx.buildAllObjects();
/**
* Place the camera at the starting position.
*/
Camera camera = worldx.getCamera();
camera.setPosition(this.xCamara,this.yCamara , this.zCamara);
camera.lookAt(SimpleVector.ORIGIN);
Config.fadeoutLight = false;
worldx.getLights().setOverbrightLighting(Lights.OVERBRIGHT_LIGHTING_DISABLED);
worldx.getLights().setRGBScale(Lights.RGB_SCALE_2X);
worldx.setAmbientLight(25, 30, 30);
/**
* Place the lightsources...
*/
worldx.addLight(new SimpleVector(0, -150, 0), 25, 22, 19);
worldx.addLight(new SimpleVector(-1000, -150, 1000), 22, 5, 4);
worldx.addLight(new SimpleVector(1000, -150, -1000), 4, 2, 22);
return worldx;
textureManager.addTexture("metal", new Texture(new FileInputStream("/home/miguel/perfectday_project/JPCTExm/textures/rocks.jpg")));
model = Loader.load3DS(new FileInputStream("/home/miguel/perfectday_project/blender_model/obj_export/montanya2.3ds"), 1);
Object3D field = model[0];
field.calcTextureWrap();
field.setTexture("metal");
field.setEnvmapped(Object3D.ENVMAP_DISABLED);
field.setCenter(SimpleVector.ORIGIN);
field.rotateX((float) (Math.PI /-2));
int size = (int) field.getScale();
System.out.println("SCALE:"+field.getScale());
field.setOrigin(SimpleVector.ORIGIN);
field.build();
worldx.addObject(field);
textureManager.addTexture("metal", new Texture(new FileInputStream("/home/miguel/perfectday_project/JPCTExm/textures/rocks.jpg")));
model = Loader.load3DS(new FileInputStream("/home/miguel/perfectday_project/blender_model/obj_export/montanya2.3ds"), 1);
Object3D field = model[0];
field.calcTextureWrapSpherical();
field.setTexture("metal");
field.setEnvmapped(Object3D.ENVMAP_DISABLED);
field.setCenter(SimpleVector.ORIGIN);
field.rotateX((float) (Math.PI /-2));
int size = (int) field.getScale();
System.out.println("SCALE:"+field.getScale());
field.setOrigin(SimpleVector.ORIGIN);
field.build();
worldx.addObject(field);
in this code set Texture but they are dont show ver wellTextureManager textureManager = TextureManager.getInstance();
textureManager.addTexture("metal", new Texture(new FileInputStream("/home/miguel/perfectday_project/JPCTExm/textures/rocks.jpg")));
model = Loader.load3DS(new FileInputStream("/home/miguel/perfectday_project/blender_model/obj_export/plano.3ds"), 1);
Object3D field = model[0];
field.setTexture("metal");
field.setEnvmapped(Object3D.ENVMAP_DISABLED);
field.setCenter(SimpleVector.ORIGIN);
field.rotateX((float) (Math.PI /-2));
int size = (int) field.getScale();
System.out.println("SCALE:"+field.getScale());
field.translate(-field.getScale()*(1), -field.getScale()*(1), 0);
field.setOrigin(SimpleVector.ORIGIN);
field.build();
JavaMan: i think you have got a point there. the model may not have uv cordinates, How could i set them in run time? Or should i set them in model design?TextureManager textureManager = TextureManager.getInstance();
textureManager.addTexture("metal", new Texture(new FileInputStream("/home/miguel/perfectday_project/JPCTExm/textures/rocks.jpg")));
model = Loader.load3DS(new FileInputStream("/home/miguel/perfectday_project/blender_model/obj_export/plano.3ds"), 1);
Object3D field = model[0];
field.setTexture("metal");
if i don t load any model, and use Primitive to create a plane and apply texture on it the textures are shown. Object3D plane = Primitives.getPlane(1, 4);
plane.translate(SimpleVector.ORIGIN);
plane.setTexture("metal");
plane.rotateX((float) (Math.PI /-2));
plane.setEnvmapped(Object3D.ENVMAP_DISABLED);
plane.build();
i have tried loading .obj and .3ds and textures are not applied tomy models ( i even tried loading very simple model like a cube or a plane)