Problem with material - Sketchup to Ogre

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Problem with material - Sketchup to Ogre

Post by zakato » Wed Nov 21, 2012 9:06 pm

Hi everyone, I have a little problem with import of material from Sketchup to Ogre.
The problem is that, once i created my 3d scene with Sketchup and exported it using the plugin, created the file
.mesh, .materials and .jpeg, and copied the file ( .mesh in media/models, .materials in media/materials/scripts and .jpeg in media/materials/bitmap and copied this file also in the resource files of my project),
i compile the program with this code:

Code: Select all

#include "Ogre\ExampleApplication.h"




class Example1 : public ExampleApplication
{
public:

   void createScene()
   {



Ogre::SceneNode* Node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "CubeNode" );
      Ogre::Entity* Entity = mSceneMgr->createEntity( "Cube", "vico.mesh" );
      Node->attachObject( Entity );
	  Entity->setMaterialName("vico.material");


	  Ogre::SceneNode* node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Sesso");
	  Ogre::Entity* Sinbad = mSceneMgr->createEntity("Sinbad","Sinbad.mesh");
	  node2->attachObject(Sinbad);




	 Ogre::Light* light = mSceneMgr->createLight("Light1");
		light->setType(Ogre::Light::LT_SPOTLIGHT);
		
   }
};

int main (void)
{
   Example1 app;
   app.go();
   return 0;
}




The mesh is on the screen, but without material, it is all white.

Can you help me to figure out what is the problem.
0 x

zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post by zakato » Sun Nov 25, 2012 12:52 pm

up
0 x

bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia

Re: Problem with material - Sketchup to Ogre

Post by bstone » Sun Nov 25, 2012 2:03 pm

zakato wrote:Entity->setMaterialName("vico.material");
Doesn't look like the correct material name to me. The material name is whatever you have after the "material" keyword in vico.material.
0 x

zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post by zakato » Sun Nov 25, 2012 3:53 pm

i tried also this:

Code: Select all

  Entity->setMaterialName("vico");
but it does'nt work either.
0 x

zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post by zakato » Sun Nov 25, 2012 3:56 pm

the vico.material, that i copied in the media/material/scripts folder is like this

Code: Select all

material Asfalto_Nuovo
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Asphalt_New.jpg
         }
      }
   }
}

material 0132_GrigioChiaro
{
   technique
   {
      pass
      {
         diffuse 0.662745098039216 0.662745098039216 0.662745098039216 1.0
         ambient 0.662745098039216 0.662745098039216 0.662745098039216 1.0
      }
   }
}

material Acqua_Frizzante
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Water_Sparkling.jpg
         }
      }
   }
}

material Blocco_di_Cemento_Effetto_Pietre_Grigie
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Concrete_Block_Retaining_Gray.jpg
         }
      }
   }
}

material Granito_Blu_Notte
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Stone_Granite_Midnite.jpg
         }
      }
   }
}

material SketchupDefault
{
   technique
   {
      pass
      {
         diffuse 0.890196078431373 0.882352941176471 0.870588235294118
         ambient 0.890196078431373 0.882352941176471 0.870588235294118
      }
   }
}

material SketchupDefault_Back
{
   technique
   {
      pass
      {
         diffuse 0.545098039215686 0.533333333333333 0.603921568627451
         ambient 0.545098039215686 0.533333333333333 0.603921568627451
      }
   }
}

all the .jpeg files that are present in the code of vico.material i copied in the media/material/textures.

I don't understand why it does'nt work...
0 x

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 2

Re: Problem with material - Sketchup to Ogre

Post by syedhs » Mon Nov 26, 2012 5:52 am

You keep mentioning jpeg but in your material, the file is jpg (not jpeg). Probably that is the source of error?
If renaming the file doesn't solve it, paste the Ogre.log here.
0 x
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post by zakato » Mon Nov 26, 2012 12:19 pm

I change in the material script the extension of the files( jpg -> jpeg) but still does'nt work.
In the log of Ogre, it says that it find now the texture .jpeg but the program can't find the material script. But i have the material script file in media/materials/scripts.
I can't understand what is the problem.
0 x

User avatar
saejox
Goblin
Posts: 260
Joined: Tue Oct 25, 2011 1:07 am

Re: Problem with material - Sketchup to Ogre

Post by saejox » Mon Nov 26, 2012 5:06 pm

i don't see a material named "vico" in your .material file.
0 x
Nimet - Advanced Ogre3D Mesh/dotScene Viewer
asPEEK - Remote Angelscript debugger with html interface
ogreHTML - HTML5 user interfaces in Ogre

zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post by zakato » Mon Nov 26, 2012 7:17 pm

The file .material was created using the plug-in for Sketchup to ogre. Now the file .material has the information about the
texture of the submesh of the mesh that i created with Sketchup. There are different texture for different sub mesh.
As you say, there is not a vico material in my file .material, and i think this is the problem. Because, when i try and write in the code

Code: Select all

Entity->setMaterialName("Asfalto_Nuovo");
, the entire mesh presented with this material.
Now how can manage it and make it so that the correct textures are loaded on the correct sub mesh?

I tried

Code: Select all

material vico{


material Asfalto_Nuovo
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Asphalt_New.jpeg
         }
      }
   }
}

material 0132_GrigioChiaro
{
   technique
   {
      pass
      {
         diffuse 0.662745098039216 0.662745098039216 0.662745098039216 1.0
         ambient 0.662745098039216 0.662745098039216 0.662745098039216 1.0
      }
   }
}

material Acqua_Frizzante
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Water_Sparkling.jpeg
         }
      }
   }
}

material Blocco_di_Cemento_Effetto_Pietre_Grigie
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Concrete_Block_Retaining_Gray.jpeg
         }
      }
   }
}

material Granito_Blu_Notte
{
   technique
   {
      pass
      {
         diffuse 1 1 1 1.0
         texture_unit
         {
            texture Stone_Granite_Midnite.jpeg
         }
      }
   }
}

material SketchupDefault
{
   technique
   {
      pass
      {
         diffuse 0.890196078431373 0.882352941176471 0.870588235294118
         ambient 0.890196078431373 0.882352941176471 0.870588235294118
      }
   }
}

material SketchupDefault_Back
{
   technique
   {
      pass
      {
         diffuse 0.545098039215686 0.533333333333333 0.603921568627451
         ambient 0.545098039215686 0.533333333333333 0.603921568627451
      }
   }
}

}
and replace again "vico" in the previous code, but it does'nt work either.
0 x

User avatar
saejox
Goblin
Posts: 260
Joined: Tue Oct 25, 2011 1:07 am

Re: Problem with material - Sketchup to Ogre

Post by saejox » Mon Nov 26, 2012 10:41 pm

materials dont have automatic inheritance like that.

you should iterate over your sub-meshes then assign each sub-mesh the correct material.
0 x
Nimet - Advanced Ogre3D Mesh/dotScene Viewer
asPEEK - Remote Angelscript debugger with html interface
ogreHTML - HTML5 user interfaces in Ogre

zakato
Gnoblar
Posts: 9
Joined: Mon Nov 19, 2012 3:34 pm

Re: Problem with material - Sketchup to Ogre

Post by zakato » Tue Nov 27, 2012 12:11 am

saejox wrote:materials dont have automatic inheritance like that.

you should iterate over your sub-meshes then assign each sub-mesh the correct material.

sorry, can you explain tis better, maybe can you help me with the code?
0 x

User avatar
saejox
Goblin
Posts: 260
Joined: Tue Oct 25, 2011 1:07 am

Re: Problem with material - Sketchup to Ogre

Post by saejox » Tue Nov 27, 2012 12:18 am

just a small documentation search yielded this.

Code: Select all

SubEntity * 	getSubEntity (unsigned int index) const
 	Gets a pointer to a SubEntity, ie a part of an Entity.
SubEntity * 	getSubEntity (const String &name) const
 	Gets a pointer to a SubEntity by name.
unsigned int 	getNumSubEntities (void) const
 	Retrieves the number of SubEntity objects making up this entity. 
also there are many subEntity material assignment questions on the forum.
0 x
Nimet - Advanced Ogre3D Mesh/dotScene Viewer
asPEEK - Remote Angelscript debugger with html interface
ogreHTML - HTML5 user interfaces in Ogre

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7147
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 16

Re: Problem with material - Sketchup to Ogre

Post by Kojack » Wed Nov 28, 2012 12:57 am

If the original vico.material file was generated by the exporter, then you don't need to set materials manually. Each submesh contains the name of the required material and will load it automatically.
So setMaterialName is only needed if you want to change the materials.
0 x

Post Reply