Anyone has experience with working with blender?

Started by eye1, May 22, 2013, 05:40:41 PM

Previous topic - Next topic

eye1

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?


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]

EgonOlsen

Check for the object's center after calling build(). Maybe Blender applies some translations to the vertices.

eye1


   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:

first:(-845.3932,734.2141,-306.81332)
second: (0.0,0.0,0.0)


blender exported model:

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?
 

EgonOlsen

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.

eye1

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.

EgonOlsen

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.

eye1

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?


   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:


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

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)

eye1

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 

EgonOlsen

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.