You Are Here:

Community: Developer Discussion Boards

#1 Old Question jsr 184 3D to 2D coordinates - 2005-09-09, 17:58

Join Date: Aug 2005
Posts: 29
simonhayles
Offline
Registered User
Hi there,
I'm developing a program on the Nokia 6230i using jsr184.
I can display an m3g model ok, but I'm having trouble converting 3D coordinates to screen coordinates. Is there any way of giving jsr184 a set of coordinates (x,y,z) for a given camera position & projection and getting 2D (x,y) coordinates for the screen?
Reply With Quote

#2 Old Re: jsr 184 3D to 2D coordinates - 2005-09-13, 23:17

Join Date: Jul 2003
Posts: 14
mikbry
Offline
Registered User
Hi,

I have use a 3D to 2D transformation for my wireframe M3G demo.
You need to understand OpenGL transformation pipeline, it works the same.

Here you get a VertexArray from a Mesh, and at the end you fill a float array vertices2D filled with Transformed 2D points.

BR,

Mik
www.miklabs.com

Here is the code:
float mwidth = canvas.getWidth()/2;
float mheight = canvas.getHeight()/2;
VertexArray va = mesh.getVertexBuffer().getPositions(params);

// ModelView transformation
meshTransform.transform(va, qvertices, true);
float r = params[0];
// SCale vertices
for (int i = 0; i < vertexCount; i++)
{
qvertices[i*4+0] *= r;
qvertices[i*4+1] *= r;
qvertices[i*4+2] *= r;
qvertices[i*4+3] = 1.0f; // Not so usefull...
}
cameraTransform.transform(qvertices);

// Projection transformation
Transform t = new Transform();
camera.getProjection(t);
t.transform(qvertices);

// ClipCoordinates to Windows coordinates loop
for (int i = 0; i < vertexCount; i++)
{
float w = 1.0f/qvertices[i*4+3];
// Perspective division
float x = qvertices[i*4+0]*w;
float y = qvertices[i*4+1]*w;
// We now get Normalized device coordinates

// ViewPort transformation
vertices2d[i*2+0] = (int)(x*mwidth+mwidth);
vertices2d[i*2+1] = (int)(-y*mheight+mheight);
}
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Jsr 180 - J2me Sip Api sipshakers Mobile Java General 2 2005-10-19 08:30
M3G (JSR 184) Detail about External Reference in m3g file amitian Mobile Java Media (Graphics & Sounds) 1 2004-12-28 15:50
JSR 184 Example gadkii Mobile Java Media (Graphics & Sounds) 8 2004-10-26 21:05
3d api JSR 184 where i will get sdk?How to use it? abhishek_in2000 Mobile Java Media (Graphics & Sounds) 8 2004-07-02 00:03
Tracking bitmap coordinates uh...ok Symbian User Interface 2 2004-06-13 18:35

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ