Crystal Space
Welcome, Guest. Please login or register.
October 25, 2014, 02:50:27 pm

Login with username, password and session length
Search:     Advanced search
9011 Posts in 2044 Topics by 8828 Members
Latest Member: Saikjanna
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  3D Models
« previous next »
Pages: [1] Print
Author Topic: 3D Models  (Read 2348 times)
Freetimecoder
Newbie
*
Posts: 31


View Profile
« on: October 06, 2007, 04:53:34 pm »

Hi,

OK I searched quite a lot time for it. So there either is nothing or I am dumb (Wink)
I'm working with Blender and using Blender2Crystal for the models. I already exported a nice Map and managed to walk around like in a FPS. Well for an FPS I need a gun. My Problem: I didn't managed to export my weapon model from Blender, so that I can use it as an own object.

First try:
I exported my gun-szene like a world map. I tried to load the gun with the factories in the exported .zip (because there is a directory called "factories"). This failed.

Second try:
In the first tutorial is code to load a object:
Code:
  csRef<iMeshFactoryWrapper> imeshfact (loader->LoadMeshObjectFactory (
        "/lib/std/sprite1"));
  if (imeshfact == 0)
    ReportError("Error loading mesh object factory!");
  // Add the sprite to the engine.
  csRef<iMeshWrapper> sprite (engine->CreateMeshWrapper (
        imeshfact, "MySprite", room,
        csVector3 (-3, 5, 3)));
So I tried:
Code:
  csRef<iMeshFactoryWrapper> imeshfact (loader->LoadMeshObjectFactory (
        "/lib/shotgun/library"));
  if (imeshfact == 0)
    ReportError("Error loading mesh object factory!");
  // Add the sprite to the engine.
  csRef<iMeshWrapper> sprite (engine->CreateMeshWrapper (
        imeshfact, "MySprite", room,
        csVector3 (-3, 5, 3)));
Error: crystalspace.maploader.parse.map:  File '/lib/shotgun/library' does not seem to contain a 'meshfact'!
and
Code:
  csRef<iMeshFactoryWrapper> imeshfact (loader->LoadMeshObjectFactory (
        "/lib/shotgun/factories/genBody"));
  if (imeshfact == 0)
    ReportError("Error loading mesh object factory!");
  // Add the sprite to the engine.
  csRef<iMeshWrapper> sprite (engine->CreateMeshWrapper (
        imeshfact, "MySprite", room,
        csVector3 (-3, 5, 3)));
Error: crystalspace.maploader.parse.map:  File '/lib/shotgun/factories/genBody' does not seem to contain a 'meshfact'!
This failed too...

Third try:
Somewhere I found this code:
   VFS->ChDir ("/lib/shotgun");
   if (!loader->LoadLibraryFile ("library"))
    ReportError("Error couldn't load shotgun!");

  csRef<iMeshFactoryWrapper> MyGun (loader->LoadMeshObjectFactory (
        "/lib/shotgun/factories/genBody"));
  if (MyGun == 0)
    ReportError("Error loading mesh object factory!");
  csRef<iMeshWrapper> sprite (engine->CreateMeshWrapper (
        MyGun, "MyGun", room,
        csVector3 (-3, 5, 3)));
All possible errors occurred -.-


Now I don't know what to do. Maybe the code above is just ...hum... silly. I don't know. But my first thought was that I maybe used b2cs wrong. So I searched for a better tutorial how I can get objects into CS. All I found were tutorials about maps. But I already have a running map...

I know I'm a newbie atm ^^
Hope you can help me.
Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #1 on: October 07, 2007, 02:35:12 pm »

First of all, since you're repeatedly using the VFS path /lib/shotgun, I assume you have correctly set up a VFS mount for that?

Third try:
Somewhere I found this code:
   VFS->ChDir ("/lib/shotgun");
   if (!loader->LoadLibraryFile ("library"))
    ReportError("Error couldn't load shotgun!");

  csRef<iMeshFactoryWrapper> MyGun (loader->LoadMeshObjectFactory (
        "/lib/shotgun/factories/genBody"));
  if (MyGun == 0)
    ReportError("Error loading mesh object factory!");
  csRef<iMeshWrapper> sprite (engine->CreateMeshWrapper (
        MyGun, "MyGun", room,
        csVector3 (-3, 5, 3)));


In that snippet, the first three lines should work - after all, you have your model in a library. However, to obtain the correct factory, you're trying to load it again - this is wrong. In fact, the factory is already loaded, you just have to fetch it via engine->FindMeshFactory.
Logged
Freetimecoder
Newbie
*
Posts: 31


View Profile
« Reply #2 on: October 07, 2007, 07:43:11 pm »

Thanks a lot. Now it works... But I am still learning, so be prepared for more questions Cheesy
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.346 seconds with 16 queries.