Java Programing

January 31, 2007

A vertex s position is defined using three dimensions

Filed under: Java 3D Programming — webmaster @ 11:15 pm

Figure 14.8 Using OBJECT_LINEAR texture coordinate generation That is, the t texture coordinate is equal to a scaled version of the y vertex coordinate plus an offset of 0.5. We use an offset of 0.5 because we defined the midpoint of the texture image as the elevation = 0 contour. From the equation you can see that: Vertex y = yMaxHeight, s = 1.0 Vertex y = 0.0, s = 0.5 Vertex y = yMaxHeight, s = 0.0 That is, we have successfully defined a mapping from vertex y coordinate in the range yMaxHeight to s texture coordinates in the range 0.0 to 1.0. The texture coordinate is independent of a vertex s x and z coordinates. Using the OBJECT_LINEARmode, the landscape has texture coordinates automatically calculated, coloring areas above sea level green (light gray) and areas below sea level blue (dark gray). As the landscape as a whole is rotated and translated, the texture coordinates are unaffected. The vertex coordinates in the local coordinate system of the landscape are unchanged, despite the origin of the landscape s coordinate being shifted. EYE_LINEAR mode The EYE_LINEARtexture coordinate generation mode is very similar to the OBJECT_LINEARmode with one important difference. The positions of vertices in their local coordinate system are no longer used; rather the positions of vertices in the world coordinate system are used instead. This has major consequences as the landscape is moved within the VirtualUniverse, the texture coordinates of the vertices within the landscape are recomputed, for example, in the TexCoordTestexample, by simply modifying the construction of the TexCoordGenerationobject to be: TexCoordGeneration texGen = new TexCoordGeneration( TexCoordGeneration.EYE_LINEAR, TexCoordGeneration.TEXTURE_COORDINATE_2, new Vector4f( 0, (float) (1.0/(2 * yMaxHeight)), 0, 0.5f ), new Vector4f( 0,0,0,0 ), new Vector4f( 0,0,0,0 ) ); We define a VirtualUniversewhere the texture coordinate of the landscape is calculated from the y coordinate of the landscape in the VirtualUniverse s coordinate system. In essence we have defined a band of texture coordinates (color) that ranges from yMaxHeight to +yMaxHeight. When the landscape falls inside this range, it will have a texture coordinate applied to it. In mathematical terms, this is equivalent to multiplying each vertex coordinate by the result of calling Shape3D.getLocalToVworldbefore computing the texture coordinate using: s texture coordinate = (0.0 * vertex x) + (1.0/ 2 * yMaxHeight * vertex y) + (0.0 * vertex z) + 0.5; 241

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Java Web Hosting