Author Topic: Anyone has experience with working with blender?  (Read 1359 times)

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
Anyone has experience with working with blender?
« on: May 22, 2013, 05:40:41 pm »
I have a 3ds file. If I load it to jpct engine it is loaded fine. I import/export the file in blender (without any change). Exported file is than imported by the engine normally, but it is not visible in the world. I must be missing something here?

Code: [Select]
Loading file 3ds/forklift.3ds
File 3ds/forklift.3ds loaded...6964 bytes
Processing new material BLACK_PLASTI!
Processing new material CROMED!
Processing new material Material #1!
Processing object from 3DS-file: ELT_COVE
Object 'ELT_COVE_jPCT154' created using 394 polygons and 221 vertices.
Created 83 triangle-strips for object158 in 5 pass(es)

Before:


After:


regards

[attachment deleted by admin]

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Anyone has experience with working with blender?
« Reply #1 on: May 22, 2013, 07:09:13 pm »
Check for the object's center after calling build(). Maybe Blender applies some translations to the vertices.

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
Re: Anyone has experience with working with blender?
« Reply #2 on: May 22, 2013, 09:46:48 pm »
Code: [Select]
   public void addToWareHouse(WareHouse warehouse, SimpleVector origin)
   {
      getPart(PART_MODEL).setOrigin(origin);
      warehouse.addObject(getPart(PART_MODEL));
      SimpleVector rotPiv = getPart(PART_MODEL).getRotationPivot();
      SimpleVector center = getPart(PART_MODEL).getCenter();

      getPart(PART_MODEL).build();
      System.out.println("first:" + getPart(PART_MODEL).getCenter());
      getPart(PART_MODEL).setRotationPivot(rotPiv);
      getPart(PART_MODEL).setCenter(center);
      System.out.println("second: " + getPart(PART_MODEL).getCenter());
      this.warehouse = warehouse;
   }

original model:
Code: [Select]
first:(-845.3932,734.2141,-306.81332)
second: (0.0,0.0,0.0)

blender exported model:
Code: [Select]
first:(-0.028999299,-2.2083154,0.854877)
second: (0.0,0.0,0.0)

It is a big difference. The thing is I override rotationpivot and center with values which object had before the build was called.
What does this difference mean here, I am not really sure what does this mean?
 

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Anyone has experience with working with blender?
« Reply #3 on: May 22, 2013, 11:23:26 pm »
It means that either Blender or your exporter has transformed the mesh in object space. Obviously to make the mesh to be located around the origin in object space.

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
Re: Anyone has experience with working with blender?
« Reply #4 on: May 23, 2013, 09:28:08 am »
Shouldn't than model just be located on different coordinates and not moved out of the scene?
Can I do something here?
The thing is, even if I create a simple box with blender and try to import it into the World.  I can not see it anywhere.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Anyone has experience with working with blender?
« Reply #5 on: May 23, 2013, 09:50:07 am »
What Blender does here is actually a good thing, because locating the object around the origin of object space is usually more intuitive for humans. To understand how to deal with this, you have to understand the basics of objects vs. world space. I'll try to give an simple example:

If your object is located around 100,100,100 in object space and no transformation will be applied, you'll find it around 100,100,100 in world space too. If you translate it 100 units along x, it's still 100,100,100 in object space (because object space doesn't change), but 200,100,100 in world space.
If you want that object to appear around the origin 0,0,0 in world space, the translation would be -100,-100,-100.

However, if you redo the object so that it's located around the origin in object space, the same translation applied to it will place it at -100,-100,-100 in world space...and what might have been in your view before is now invisible. This is what happens here.

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
Re: Anyone has experience with working with blender?
« Reply #6 on: May 23, 2013, 10:58:44 am »
Hi Egon,

I understand this relation between object vs. world space (at least I think I do). The reason I have overridden the center of the object is because I wanted that objects have the center at exactly the point where it was defined in 3ds file and not in the center of the object as it recalculated when build is called (this was done long time ago, I think that was the reason).
 
Nevertheless even if I leave the center untouched and leave it how the engine recalculates it, still original 3ds file is rendered, while exported one from blender is not.
The center engine recalculates is much different. Do this numbers tell me that the blender resized the model and is now much smaller and maybe thats why I can not see it anymore?

Code: [Select]
   public void addToWareHouse(WareHouse warehouse, SimpleVector origin)
   {
      getPart(PART_MODEL).setOrigin(origin);
      warehouse.addObject(getPart(PART_MODEL));
      System.out.println("first:" + getPart(PART_MODEL).getCenter() + " - " + getPart(PART_MODEL).getOrigin());
      getPart(PART_MODEL).build();
      System.out.println("second:" + getPart(PART_MODEL).getCenter() + " - " + getPart(PART_MODEL).getOrigin());
      this.warehouse = warehouse;
   }

original 3ds:

Code: [Select]
first:(0.0,0.0,0.0) - (0.0,-2500.0,0.0)
second:(-845.3932,734.2141,-306.81332) - (0.0,-2500.0,0.0)

blenders exported 3ds
Code: [Select]
first:(0.0,0.0,0.0) - (0.0,-2500.0,0.0)
second:(-0.028999299,-2.2083154,0.854877) - (0.0,-2500.0,0.0)

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
Re: Anyone has experience with working with blender?
« Reply #7 on: May 23, 2013, 11:14:03 am »
Yes,
That was the case! Blender put the model on completely different scale, much smaller.
I'll do the research to find out how to set those unit in blender to fit my needs.

thanks 

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Anyone has experience with working with blender?
« Reply #8 on: May 23, 2013, 12:56:39 pm »
A little off topic: Could you please correct your email address? I'm getting bounces for each reply because the notification mails can't be send.

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
Re: Anyone has experience with working with blender?
« Reply #9 on: May 23, 2013, 01:09:12 pm »
Ok, I changed it.