Skip to main content

# Re: Relationship between .obj file "v values" and on screen 2D coordinate?

No replies
Anonymous

At some point in time I searched for a description of the View Model. I
found these words but I am uncertain where in the API you can find them. I
hope that they help you develop your solution. A detailed reading of the
appropriate classes and technical descriptions related to viewing may also be
of use to you.

*The scale of the view platform coordinates is such that [-1,1] in virtual
* coordinates maps to [0, screen_width] in PHYSICAL units. The left side
of the
* screen corresponds to 0 and the right side corresponds to the
screen-width. 1
* unit in virtual coordinates is scaled to one half of the physical width
of
* the screen (1024/2). The default scale is physical_screen_width/2 (see
the
* docs for SCALE_SCREEN_SIZE scale policy in the View). The default
physical
* screen size is set assuming a 90 dots per inch screen resolution. For a
1024
* x 768 screen, the default screen width is 1024pixels/90pixels per inch =
* 11.37777778 inches. The screen width in meters is 11.37777778
inches/39.37
* inches per meter = .288996 meters. The screen width corresponds to the
* virtual distance between -1 and 1. Therefore the scale factor that
relates
* virtual units to physical world measurements is the width of the screen
in
* meters divided by the width of the screen in virtual coordinates (i.e.,
2).
* The scale factor is therefore .288996 meters/2 units or .144483 meters
per
* virtual unit. Conversely, the PHYSICAL to VIRTUAL scale = 6.92123 (i.e.,
* assuming a 1024 x 768 screen). So a clip distance of 0.1 in PHYSICAL
units
* will be 0.692123 in virtual coordinates.

In a message dated 12/24/2009 8:27:34 A.M. Pacific Standard Time,
java3d-interest@javadesktop.org writes:

Hi, all:

Simple .obj specification can be found at
http://www.royriggs.com/obj.html

```<br />
v x y z</p>
<p>The  vertex command, this specifies a vertex by its three coordinates. The<br />
vertex  is implicitly named by the order it is found in the file. For<br />
example, the  first vertex in the file is referenced as '1', the second as '2' and<br />
so on.  None of the vertex commands actually specify any geometry, they are<br />
just  points in space. ```

I just want to know, if I created a on/off screen canvas of size 640*480
on my computer screen, what is the relationship between
"v values" of the.obj files and the exact values on the on/off screen
canvas ???
Or, there is no relationship between this two at all?

In my case, my .obj file looks like:

```g main<br />
#  75972 vertices.<br />
v -58.1117 -49.4189 -12.242<br />
v -58.0527 -50.0355  -11.9883<br />
v -58.1128 -50.6568 -11.8222<br />
v -58.1629 -51.2563 -11.7768<br />
v -58.2183 -51.8611 -11.7323<br />
v -58.2231 -52.4784 -11.7214<br />
v  -58.259 -53.0993 -11.7188<br />
v -58.3331 -53.7061 -11.7407<br />
v -58.3663  -54.309 -11.7328<br />
v -58.3955 -54.9136 -11.7015<br />
v -58.4142 -55.526  -11.6696<br />
v -58.4299 -56.1264 -11.6939<br />
v -58.427 -56.7551 -11.8301<br />
v -58.4213 -57.3728 -12.0565<br />
v -58.8783 -29.3341 -12.3035<br />
v  -58.8634 -29.9544 -12.0902<br />
v -58.8288 -30.5471 -11.949<br />
v -58.7427  -31.1332 -11.886<br />
v -58.6354 -31.7285 -11.9012<br />
v -58.5571 -32.331  -11.9593<br />
...<br />
v 55.3262 -54.4387 -11.2943<br />
v 55.3417 -55.068 -11.3683<br />
v 55.3343 -55.6911 -11.5067<br />
v 55.3041 -56.3406 -11.6606<br />
mtllib  /.../filename.mtl<br />
usemtl default<br />
vt 0 0.198847 0.0<br />
vt 0 0.195965  0.0<br />
vt 0 0.193084 0.0<br />
vt 0 0.190202 0.0<br />
vt 0 0.18732 0.0<br />
vt 0  0.184438 0.0<br />
vt 0 0.181556 0.0<br />
vt 0 0.178674 0.0<br />
...```

I loaded the .obj file like:

```<br />
int flags =  ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY ; // |<br />
ObjectFile.RESIZE;<br />
ObjectFile f = new ObjectFile(flags, 0.0f);<br />
m_S = null;<br />
try  {<br />
m_S = f.load(fname);<br />
} catch (FileNotFoundException e)<br />
{<br />
...<br />
}<br />
m_BGFace =  m_S.getSceneGroup();<br />
m_Object3d = (Shape3D)m_BGFace.getChild(0);<br />
Bounds  m_ObjBounds = m_Object3d.getBounds();```

Now, as you might have noticed, I intended not to use the configuration
"ObjectFile.RESIZE; " to avoid automatically resize when loading this .obj
file.

Now, m_ObjBounds does show the bounds of this object's "v value list".
(well, you may look on the v value list as a point list and calculate its
boundary, Java3D Bounds and BoundingBox are pretty useful here )

However, I still can't find any relationship between this "loaded v
values" and "on/off screen pixel coordinates".
For sure, there must be some relationship between this two, because Java3D
must be able to load data from .obj files and display them automatically
on the screen by Java3D itself. isn't it?

So, can anybody tell me, what is the relationship between .obj files'
"loaded v values" and "on/off screen pixel coordinates" ??

Best Regards
JIA Pei
[Message sent by forum member 'jiapei100' (jp4work@gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=377391

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@java3d.dev.java.net
For additional commands, e-mail: interest-help@java3d.dev.java.net

[att1.html]