Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Java 3D / May 2004

Tip: Looking for answers? Try searching our database.

IndexedTriangleArray and Color

Thread view: 
Richard Steffen - 03 May 2004 13:22 GMT
Hi,

i try to set Color to every Triangle explicitily. (Code at the end)
Without setColor it works fine an i see two Triangles in the canvas3D.
But if i try to set the Colors i got following error ..

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
GeometryArray: has no colors
    at javax.media.j3d.GeometryArray.setColor(GeometryArray.java:1279)
    at ipbmesh.SimpleMeshViewer.insertMesh(SimpleMeshViewer.java:218)
    at ipbmesh.SimpleMeshViewer.createSceneGraph(SimpleMeshViewer.java:155)

How i can solve this problem, that IndexedTriangleArray instanciate a
ColorTable ?

Thanks for Help

Richard

########################################
Transform3D translate = new Transform3D();
translate.setTranslation (new Vector3d (0, 0, -10));       
TransformGroup objTranslate = new TransformGroup(translate);

IndexedTriangleArray ta = new
IndexedTriangleArray(6,GeometryArray.COORDINATES,6);

double[] ca1 = {0.0,0.0,0.0};
double[] ca2 = {1.0,1.0,1.0};
double[] ca3 = {1.0,2.0,2.0};
double[] ca4 = {2.0,4.0,1.0};
double[] ca5 = {2.0,4.0,9.0};
ta.setCoordinate(0,ca1);
ta.setCoordinate(1,ca2);
ta.setCoordinate(2,ca3);
ta.setCoordinate(3,ca4);
ta.setCoordinate(4,ca5);
       
int[] t1 = {0,1,2}; int[] t2 = {1,3,4};           
ta.setCoordinateIndices(0,t1);
ta.setCoordinateIndices(1,t2);

ta.setColor(0, new Color3f(100 , 100, 10));
ta.setColor(1, new Color3f(100,100,10));

Shape3D shape = new Shape3D (ta);       
objTranslate.addChild(shape);

########################################
Christian Wiech - 04 May 2004 06:48 GMT
> Hi,
>
[quoted text clipped - 22 lines]
> IndexedTriangleArray ta = new
> IndexedTriangleArray(6,GeometryArray.COORDINATES,6);

> double[] ca1 = {0.0,0.0,0.0};
> double[] ca2 = {1.0,1.0,1.0};
[quoted text clipped - 17 lines]
>
> ########################################

Hi

In the constructor you have to specify the vertexFormat. It is a bitmask.
See the javadoc for more info.

This should work:

IndexedTriangleArray ta = new
IndexedTriangleArray(6,GeometryArray.COORDINATES |
GeometryArray.COLOR_3,6);

Cheers

Christian


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.