Start a new topic

scaling 3D object with 3D pins in a specific position

Hi,

I will explain my problem. I have a 3D object (length, width, height) overlaying in the center of a square image target when I detected with my phone camera.

the center of 3D object base is mingled with the image target center. I want to add some 3D pins to my object in a specific positions.

to do that, I'm using the option "translate" in AR.model to place 3D pins in their places. but I can't get the right result. 

I want to know how to calculate "Translate" parameters (x, y,and z) from what I have??


I have :

  • reel dimensions of 3D object
  • reel distances of 3D pins positions from the image target center 
  • scale used
this is the code:

 

 

this.modelobject = new AR.Model("assets/3D_object.wt3", {
onLoaded: World.showInfoBar,

onError: World.onError,

scale: {

x: 0.002,

y: 0.002,

z: 0.002

},

translate: {

x: 0.0,

y: 0.0,

z: 0.0

},

rotate: {

x: 0,

y: 0,

z: 0

}

});



this.modelpin = new AR.Model("assets/3D_PIN1.wt3", {

onLoaded: World.showInfoBar,

onError: World.onError,

scale: {

x: 0.002,

y: 0.002,

z: 0.002

},

translate: {

x: 0.5,

y: 0.3,

z: 0.8

},

rotate: {

x: 0,

y: 0,

z: 0

}

});

 the image below show how 3D pins should be displayed

thank you for help  

moto.PNG
(58 KB)

Hi,



the coordinate system is set up such that the height of the image target equals 1 virtual units of length. Since you have a square target, this will be the same for the width of the target. For example, a translation of (+0.5, +0.5) will put something in the upper right corner of the image target, while a translation of (-0.5, -0.5) will put something in the lower left corner of the image target.


Knowing the size of your object, it should be easy to figure out where to place your pins. Obviously you will need to take the scale you set into consideration.


If you started with a cube with side length 250 and applied a scale of 0.002 you will have a cube with a side length of 0.5 virtual units. The corner positions will then be at (±0.25, ±0.25).



- Daniel

thank you for replying 

I have a small question after I read your response. the side length that you take it 250 can en m, cm, or even mm.

for example if we have  250 cm that's mean 2500 mm, we keep the same scale 0.002, we have as a result 2 different values 0.5 and 5. so we will use ±0.25  and ±2.5  to point the corner position. but in reality ±2.5 doesn't work. 

My question is the result value from "length *  scale" must be between 0 and 1 to  get things work or there is another reason??


Hi,



a translation value of 2.5 will be significantly outside the area of the image target (which works just fine, but I'm guessing that's not what you want to achieve), remember: the coordinate system spans ±0.5 in X and Y.


I don't think we consider any unit of measure when importing models, whatever is contained in your model file as vertex positions we simply use.


Could you attach your models to a post here so I can have a look at them?



- Daniel

this is my models


wt3
wt3
(19.6 KB)
Login or Signup to post a comment