private HomePieceOfFurniture adjustPieceOfFurnitureElevation(HomePieceOfFurniture piece) {
// Search if another piece at floor level contains the given piece to elevate it at its height
if (!piece.isDoorOrWindow()
&& piece.getElevation() == 0) {
float [][] piecePoints = piece.getPoints();
HomePieceOfFurniture highestSurroundingPiece = null;
float highestElevation = Float.MIN_VALUE;
for (HomePieceOfFurniture homePiece : this.home.getFurniture()) {
if (homePiece != piece
&& !homePiece.isDoorOrWindow()
&& isPieceOfFurnitureVisibleAtSelectedLevel(homePiece)) {
Shape shape = getPath(homePiece.getPoints());
boolean surroundingPieceContainsPiece = true;
for (float [] point : piecePoints) {
if (!shape.contains(point [0], point [1])) {
surroundingPieceContainsPiece = false;
break;
}
}
if (surroundingPieceContainsPiece) {
float elevation = homePiece.getElevation() + homePiece.getHeight();
//pravin
if (elevation > highestElevation) {
try{
HomePieceOfFurniture table=homePiece;
HomePieceOfFurniture newpiece=piece;
if(table.getName().contains("able"))
{
if(newpiece.isunfolded()|| newpiece.isfolded())
{
FurnitureCatalog catalog1=preferences.getFurnitureCatalog();
FurnitureCategory category1=catalog1.getCategories().get(0);
CatalogPieceOfFurniture piece2= category1.getFurniture().get(6);
HomePieceOfFurniture piece3=createHomePieceOfFurniture(piece2);
float h=(float)piece3.getHeight();
float w=(float)piece3.getWidth();
float d=(float)piece3.getDepth();
FinalHeight=h;
FinalWidth=w;
FinalDepth=d;
Content newModel= piece3.getModel();
String name=piece3.getName();
Content icon=piece3.getIcon();
String id=piece3.getCatalogId();
newpiece.setModel(newModel);
newpiece.setName(name);
newpiece.setIcon(icon);
// newpiece.setId(id);
newpiece.setHeight(FinalHeight);
newpiece.setWidth(FinalWidth);
newpiece.setDepth(FinalDepth);
newpiece.setFolded(true);
newpiece.setunFolded(false);
twoDView.setBackground(Color.decode(ConstantColorsFonts.ButtonNotClicked));
}
}
if (table.getName().contains("anger"))
{
if(newpiece.isfolded()|| newpiece.isunfolded())
{
FurnitureCatalog catalog1=preferences.getFurnitureCatalog();
//List<HomePieceOfFurniture> m1 = this.home.getFurniture();
FurnitureCategory category1=catalog1.getCategories().get(0);
CatalogPieceOfFurniture piece2= category1.getFurniture().get(4);
HomePieceOfFurniture piece3=createHomePieceOfFurniture(piece2);
float h=(float)piece3.getHeight();
float w=(float)piece3.getWidth();
float d=(float)piece3.getDepth();
float e=(float)piece3.getElevation();
FinalHeight=h;
FinalWidth=w;
FinalDepth=d;
Content newModel=piece3.getModel();
String name=piece3.getName();
Content icon=piece3.getIcon();
String id=piece3.getCatalogId();
newpiece.setModel(newModel);
newpiece.setName(name);
newpiece.setIcon(icon);
newpiece.setHeight(FinalHeight);
newpiece.setWidth(FinalWidth);
newpiece.setDepth(FinalDepth);
elevation=elevation-FinalHeight;
newpiece.setFolded(false);
newpiece.setunFolded(true);
new HomePane();
}
}
if(FinalHeight!=0 && FinalDepth!=0 && FinalWidth!=0)
{
newpiece.setHeight(FinalHeight);
newpiece.setWidth(FinalWidth);
newpiece.setDepth(FinalDepth);
}
}
catch(Exception ex)
{
JFrame j10 =new JFrame("catch");
j10.setVisible(true);
j10.setSize(200,200);
JLabel op5= new JLabel(" Exception"+ex.toString());
j10.add(op5);
}
highestElevation = elevation;
highestSurroundingPiece = homePiece;
}
}
}
}
if (highestSurroundingPiece != null) {
piece.setElevation(highestElevation);
return highestSurroundingPiece;
}
}
这是我的代码工作正常...但在3d视图中引用有问题...请帮帮我(在3d视图模型中没有改变!!)