|
Hi Luis,
Just a very simple example of a rectangle which width you can change dynamically using a slider: crds[ 0]=-500.0f;
crds[ 1]= 0.0f; crds[ 2]=-300.0f; crds[ 3]= 500.0f; crds[ 4]= 0.0f; crds[ 5]=-300.0f; crds[ 6]=-500.0f; crds[ 7]= 0.0f; crds[ 8]= 300.0f; crds[ 9]= 500.0f; crds[10]= 0.0f; crds[11]= 300.0f; for(i=0;i<12;i+=3)
{ nrms[i ]= 0.0f; nrms[i+1]=-1.0f; nrms[i+2]= 0.0f; } int strl[]=new
int[1];
strl[0]=4; rect=new TriangleStripArray(4,TriangleStripArray.COORDINATES| TriangleStripArray.NORMALS| TriangleStripArray.BY_REFERENCE,strl); rect.setCoordRefFloat(crds); rect.setNormalRefFloat(nrms); rect.setCapability(TriangleStripArray.ALLOW_REF_DATA_WRITE); app=new Appearance();
........ shape=new Shape3D(window,app); ........
........ class SliderListener implements
ChangeListener
{ public void stateChanged(ChangeEvent me) { JSlider source=(JSlider)me.getSource(); if(source.getValueIsAdjusting()) { value=(int)slider.getValue();//mind slider here is the name of the slider dialog rect.updateData(new GeometryUpdater() { public void updateData(Geometry window) { crds[0]=-value/2.0f; crds[6]=-value/2.0f; crds[3]= value/2.0f; crds[9]= value/2.0f; } }); } } } Lots of fun with it,
Dirk
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". |
- [JAVA3D] Simple question - BY_REFERENCE Luis Endo
- [JAVA3D] AW: [JAVA3D] Simple question - BY_REFERE... Florin Herinean
- [JAVA3D] Determining the triangles lying on a pla... Dirk L. van Krimpen
- [JAVA3D] Determining the triangles lying on a... Shyam Prakash
- Re: [JAVA3D] Determining the triangles ly... Dirk L. van Krimpen
- Re: [JAVA3D] Determining the triangle... Shyam Prakash
- [JAVA3D] AW: [JAVA3D] Determining the tri... Florin Herinean
- Re: [JAVA3D] AW: [JAVA3D] Determining... Shyam Prakash
