Print at Dec 19, 2025, 9:01:59 PM

Posted by kleiba at Apr 30, 2012, 9:39:16 AM
Re: Add furniture progamatically !!!
Hi,

sorry for piggybacking on this thread - I've tried using the steps outlined by alied, but still cannot add new furniture to my room :-(

Here's how I'm doing it right now:

Home home = new HomeFileRecorder().readHome(roomFile.getPath());

Content model = new URLContent(modelUrl);
PieceOfFurniture piece = new CatalogPieceOfFurniture("MyName", null, model, 100, 100, 100, ...);

HomePieceOfFurniture hpof = new HomePieceOfFurniture(piece);
hpof.setX(200);
hpof.setY(300);
hpof.setElevation(0);

home.addFurniture(hpof);

What happens with this code if I construct a HomeComponent3D around the home and display it in a JFrame is that I see the room and a white cube (1m edge length) at coordinates (200,300,0) -- BUT ONLY FOR ABOUT ONE SECOND!

Then it magically disappears from the scene again.

Very strange. If I query home.getFurniture() I can see that my new object is still in there, but as I said, it is only shown for one second and then it is suddenly gone.

Any help would be greatly appreciated.

Thanks,
Thomas