Crystal Space
Welcome, Guest. Please login or register.
September 02, 2014, 08:50:47 pm

Login with username, password and session length
Search:     Advanced search
9009 Posts in 2043 Topics by 8379 Members
Latest Member: Hamlock3
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Can't read a blender model - what to do?
« previous next »
Pages: [1] Print
Author Topic: Can't read a blender model - what to do?  (Read 1333 times)
Geomannl
Newbie
*
Posts: 5


View Profile Email
« on: August 07, 2011, 09:36:53 pm »


Hello, I want to try out crystal space, without using a map file; I just want to load a simple model, not an entire map. I intend ultimately to read a heighmap-terrain and place a few (random) trees and rocks on it. And then perhaps a moving object, if it all works.

For starters, I read through the "simple" manual, followed all the steps and got a brick wall on a console screen.

Then I made a simple model in blender (2.58).

I exported it to 3ds format.

The manual states, that I can import this file, but that I need to import the textures and materials separately.

According to the manual, the texture is can be loaded as: loader->LoadTexture ("green", "/rob/green.png");

The material is a problem. I defined a material in blender, but I cannot find it after the 3ds export.
The material in this case is just a shader setting, so I wanted to add a shader programmaticaly with the same name as the missing material.

I got stuck here:

csRef<iMaterial> rots01 = engine->CreateBaseMaterial(0);
rots01->SetShader( .. ?

At this moment, I'm not sure if this is the right way of doing this. I'd like to know if it's ok, as much as which setting I could use here.

On a sidenote, I doubt the model will be recognized by the engine after these calls, but I couldn't find a function to bind them to the engine. Is there such a function?

Logged
Geomannl
Newbie
*
Posts: 5


View Profile Email
« Reply #1 on: August 08, 2011, 09:52:37 pm »

I got rid of errors by doing this (I noticed in a world file that shaders are defined in files):

Code:
csRef<iShader> shader = loader->LoadShader("/shader/std_lighting.xml");

csRef<iMaterialWrapper> rots01 = engine->CreateMaterial("rots01", 0);
rots01->GetMaterial()->SetShader(  0, shader);

iTextureWrapper* txt = loader->LoadTexture ("green", "/rob/green.png");
if (!txt)
ReportError("Error loading texture!");

csRef<iMeshFactoryWrapper> ff  = modelloader->Load ("rotsen", "/rob/rotsen.3ds");

But I don't know how to add this to the engine so that it's displayed.
Logged
Geomannl
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: August 08, 2011, 10:25:50 pm »

Ok, the loading-a-sprite part of the manual tells how to add it to the engine.
It loads and shows, but it's black.

Code:
// load shader.
csRef<iShader> shader = loader->LoadShader("/shader/std_lighting.xml");
csRef<iMaterialWrapper> rots01 = engine->CreateMaterial("rots01", 0);
rots01->GetMaterial()->SetShader(  0, shader);

// load texture:
iTextureWrapper* txt = loader->LoadTexture ("green", "/rob/green.png");
if (!txt)
ReportError("Error loading texture!");

// load model
csRef<iMeshFactoryWrapper> ff  = modelloader->Load ("factory_rotsen", "/rob/rotsen.3ds");

// Add the model to the engine.
csRef<iMeshWrapper> sprite (engine->CreateMeshWrapper (ff, "sprite_rotsen", room, csVector3 (-3, 5, 3)));
Logged
Geomannl
Newbie
*
Posts: 5


View Profile Email
« Reply #3 on: August 08, 2011, 11:05:55 pm »

An extra question:
does the project contain an example xml world file that uses the terrain2 engine?
the normal terrain engine world file example from the manual crashed and said the terrain renderer was deprecated. It would help if I have a working world xml file to modify.
Logged
kickvb
Global Moderator
Jr. Member
*****
Posts: 79


View Profile
« Reply #4 on: August 12, 2011, 04:56:06 pm »

To export your model from the Blender 2.5x series, then the simpler is to use the B2.5CS exporter  from Peragro Tempus. This should avoid you to have to deal with separate and manually defined materials.

If you really want to add manually some material, then the simpler is to define it through XML, just like most of the example models in CS/data. See eg in CS/data/krystal/krystal.xml.

About the last code you posted, AFAICS you seem to create correctly the material and set the shader, but you don't associate the texture to the material, and you don't set the material to the mesh, so the mesh will clearly be kept black.

does the project contain an example xml world file that uses the terrain2 engine?
Most scenes in the CS/data/terrainXX series use terrain2 and are such examples (along with foliage examples etc). There is also the CS/data/terrainpnp.zip and CS/data/island scenes.
Logged
Geomannl
Newbie
*
Posts: 5


View Profile Email
« Reply #5 on: August 13, 2011, 01:48:20 pm »

Thanks.
I used the 1.4 stable download, that didn't contain the file you described.
I downloaded the latest version from SVN and that does contain the terrainpnp.zip file. I will try again.
Logged
kickvb
Global Moderator
Jr. Member
*****
Posts: 79


View Profile
« Reply #6 on: August 20, 2011, 02:53:07 pm »

I used the 1.4 stable download, that didn't contain the file you described.

I was talking of the 2.0 version, this is the recommended version to use now, even if it has not yet been officially released. The 2.0 features more advanced splatting and foliage functionalities for the terrains.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.488 seconds with 16 queries.