confused High priority HomeTexture

This topic has been viewed 3930 times and has 4 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
Mitsaki
Posts: 62
Joined: Tue Jul 26, 2011 2:27 pm

HomeTexture

Post by Mitsaki »

Hello,

I would like to use the class room and modify the setFloorTexture, but the API says that my variable is of type HomeTexture. I am not very familiar with Java and I don't know how I can modify it...
Here is some of my code. What I have done already is to make an array of the values that I need and then save them in the variables. So, if str[16] = Beige_Tiles, I would like this value to be places in Floor_Texture and then use it to make my Room.

String Floor_Display = str[15];
HomeTexture Floor_Texture = str[16];

if (Floor_Display == "True") {
Parallelogram_Room.setFloorVisible(true);
Parallelogram_Room.setFloorTexture(Floor_Texture);
}

Any help would be very important [:((]
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: HomeTexture

Post by Puybaret »

As you're "not very familiar with Java", you should probably rather learn the language first, shouldn't you? Once you know it better, you'll perfectly understand that a String instance can't match HomeTexture instance, and be able to change your program accordingly.
Emmanuel Puybaret, Sweet Home 3D creator
Mitsaki
Posts: 62
Joined: Tue Jul 26, 2011 2:27 pm

Re: HomeTexture

Post by Mitsaki »

Yes, I know that I cannot do that. But I don't know how to use the type HomeTexture.
That is my problem. I don't understand if I should create a variable that is HomeTexture. eg.

TextureImage firstTexture = preferences.getTexturesCatalog().getCategories().get(0).getTexture(0);

Home Texture newHomeTexture = new HomeTexture(firstTexture texture); (something like that)

Parallelogram_Room.setFloorTexture(newHomeTexture);

But the thing is that I don't understand how to use the default libraries of Sweethome3D.

Like, if I want Beige_Tiles, how do I select them?
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: HomeTexture

Post by Puybaret »

You shouldn't handle textures with strings but directly with some TextureImage, CatalogTexture or HomeTexture instances.
To get some ideas, have a look to the TextureListCellRenderer class used to display the CatalogTexture instances displayed in the list of textures displayed to the user.
Emmanuel Puybaret, Sweet Home 3D creator
Mitsaki
Posts: 62
Joined: Tue Jul 26, 2011 2:27 pm

Re: HomeTexture

Post by Mitsaki »

Thanks for the advice. After a while, I found the solution.
for anyone interested:

String[] Wall_Ceiling_Text = {"Beige_Tiles","Blue_Tiles", "Box_Tree", "Marble", "Roughcast",
"Small_Bricks","Small_Red_Bricks","Small_White_Bricks", "Stone",
"Stone-2-","Stone-3-"};

Code: Select all

    int m;
    for (m=0; m<11; m++)
    {
         if(Left_Wall_Texture.equals(Wall_Ceiling_Text[m]))
        {
                    
          // Set as Texture image the selected texture 
          TextureImage Left_Texture_Image = preferences.getTexturesCatalog().getCategories().get(2).getTexture(m);
          
          Left_Wall.setLeftSideTexture(new HomeTexture (Left_Texture_Image));
      
        }
     }
To select a texture from Wall Textures catalogue. [:)]

Really thank you Puybaret. My project seems to work finally:)))
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 3 guests