animation / speed

Hi Bill,

thanks for your fast help. The DisplayImplJ3D with a TwoDDisplayRendererJ3D is 
indeed a lot faster and probably satisfies my speed needs. However, though I 
only changed the type of display from 

  display = new DisplayImplJ2D("display1");

to 

  display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D());

my application crashs after a while with a java.lang.IndexOutOfBoundsException 
[...] at javax.media.j3d.J3dThread.run. Then I tried the P5_01 example with the 
3D modification and set the number sample points to 10000. Same error after a 
while (see full error trace below). The original 2D version works fine (and 
slow) with 10000 samples. I think the error is somewhere in VisAD or Java3D. 
You find the modificated P5_01 attached.

Cheers,
Timo
      
PS. Here's the output of two runs:   

~/da/test/visad: java P5_01
java.lang.IndexOutOfBoundsException: Index: -1, Size: 1
        at java.util.ArrayList.RangeCheck(ArrayList.java:491)
        at java.util.ArrayList.get(ArrayList.java:307)
        at javax.media.j3d.RenderBin.findOrderedCollection(RenderBin.java:3061)
        at javax.media.j3d.RenderBin.findEnvironmentSet(RenderBin.java:3449)
        at javax.media.j3d.RenderBin.insertRenderAtom(RenderBin.java:2867)
        at javax.media.j3d.RenderBin.processGeometryAtoms(RenderBin.java:2398)
        at javax.media.j3d.RenderBin.processMessages(RenderBin.java:974)
        at 
javax.media.j3d.StructureUpdateThread.doWork(StructureUpdateThread.java:83)
        at javax.media.j3d.J3dThread.run(J3dThread.java:256)
Exception in thread "main" java.lang.OutOfMemoryError
        <<no stack trace available>>
java.lang.NullPointerException
        at visad.DerivedUnit.toThis(DerivedUnit.java:718)
        at visad.DerivedUnit.toThis(DerivedUnit.java:659)
        at visad.BaseUnit.toThat(BaseUnit.java:462)
        at visad.BaseUnit.toThis(BaseUnit.java:376)
        at visad.Unit.convertTuple(Unit.java:74)
        at visad.FlatField.getFloats(FlatField.java:1131)
        at 
visad.ShadowFunctionOrSetType.doTransform(ShadowFunctionOrSetType.java:1333)
at javax.media.j3d.J3dThread.run(J3dThread.java:256)
Exception in thread "main" java.lang.OutOfMemoryError
        <<no stack trace available>>
java.lang.NullPointerException
        at visad.DerivedUnit.toThis(DerivedUnit.java:718)
        at visad.DerivedUnit.toThis(DerivedUnit.java:659)
        at visad.BaseUnit.toThat(BaseUnit.java:462)
        at visad.BaseUnit.toThis(BaseUnit.java:376)
        at visad.Unit.convertTuple(Unit.java:74)
        at visad.FlatField.getFloats(FlatField.java:1131)
        at 
visad.ShadowFunctionOrSetType.doTransform(ShadowFunctionOrSetType.java:1333)
        at 
visad.java3d.ShadowFunctionOrSetTypeJ3D.doTransform(ShadowFunctionOrSetTypeJ3D.java:101)
        at 
visad.java3d.DefaultRendererJ3D.doTransform(DefaultRendererJ3D.java:98)
        at visad.java3d.RendererJ3D.doAction(RendererJ3D.java:195)
        at visad.DisplayImpl.doAction(DisplayImpl.java:1008)
        at visad.ActionImpl.run(ActionImpl.java:225)
        at visad.util.ThreadPool$ThreadMinnow.run(ThreadPool.java:86)
Terminated

--------
2nd run:

~/da/test/visad: java P5_01
Exception in thread "main" java.lang.OutOfMemoryError
        <<no stack trace available>>
        at 
visad.java3d.ShadowFunctionOrSetTypeJ3D.doTransform(ShadowFunctionOrSetTypeJ3D.java:101)
        at 
visad.java3d.DefaultRendererJ3D.doTransform(DefaultRendererJ3D.java:98)
        at visad.java3d.RendererJ3D.doAction(RendererJ3D.java:195)
        at visad.DisplayImpl.doAction(DisplayImpl.java:1008)
        at visad.ActionImpl.run(ActionImpl.java:225)
        at visad.util.ThreadPool$ThreadMinnow.run(ThreadPool.java:86)
Terminated
~/da/test/visad: java P5_01
Exception in thread "main" java.lang.OutOfMemoryError
        <<no stack trace available>>
java.lang.NullPointerException
        at visad.DerivedUnit.toThis(DerivedUnit.java:718)
        at visad.DerivedUnit.toThis(DerivedUnit.java:659)
        at visad.BaseUnit.toThat(BaseUnit.java:462)
        at visad.BaseUnit.toThis(BaseUnit.java:376)
        at visad.Unit.convertTuple(Unit.java:74)
        at visad.FlatField.getFloats(FlatField.java:1131)
        at 
visad.ShadowFunctionOrSetType.doTransform(ShadowFunctionOrSetType.java:1333)
        at 
visad.java3d.ShadowFunctionOrSetTypeJ3D.doTransform(ShadowFunctionOrSetTypeJ3D.java:101)
        at 
visad.java3d.DefaultRendererJ3D.doTransform(DefaultRendererJ3D.java:98)
        at visad.java3d.RendererJ3D.doAction(RendererJ3D.java:195)
        at visad.DisplayImpl.doAction(DisplayImpl.java:1008)
        at visad.ActionImpl.run(ActionImpl.java:225)
        at visad.util.ThreadPool$ThreadMinnow.run(ThreadPool.java:86)
java.lang.NullPointerException
        at visad.DerivedUnit.toThis(DerivedUnit.java:718)
        at visad.DerivedUnit.toThis(DerivedUnit.java:659)
        at visad.BaseUnit.toThat(BaseUnit.java:462)
        at visad.BaseUnit.toThis(BaseUnit.java:376)
        at visad.Unit.convertTuple(Unit.java:74)
        at visad.FlatField.getFloats(FlatField.java:1131)
        at visad.ShadowFunctionOrSetType.doTransform(ShadowFunctionOrSetType.jav
a:1333)
        at visad.java3d.ShadowFunctionOrSetTypeJ3D.doTransform(ShadowFunctionOrS
etTypeJ3D.java:101)
        at visad.java3d.DefaultRendererJ3D.doTransform(DefaultRendererJ3D.java:9
8)
        at visad.java3d.RendererJ3D.doAction(RendererJ3D.java:185)
        at visad.DisplayImpl.doAction(DisplayImpl.java:1008)
        at visad.ActionImpl.run(ActionImpl.java:225)
        at visad.util.ThreadPool$ThreadMinnow.run(ThreadPool.java:86)


-- 
__.__________
 |lmo |homas
/*
VisAD Tutorial
Copyright (C) 2000 Ugo Taddei
*/

// Import needed classes

import visad.*;
import visad.java2d.DisplayImplJ2D;
import visad.java3d.*;
import java.rmi.RemoteException;
import java.awt.*;
import javax.swing.*;

/**
  VisAD Tutorial example 5_01
  A simple sine curve, but this time animated.
  Run program with java P5_01
 * 
 */


public class P5_01{

  // Declare variables
  // The quantities to be displayed in x- and y-axes
  
  private RealType length, amplitude;
   

  // The function amplitude = f(length) 
  // as ( length -> amplitude )
  
  private FunctionType func_len_amp; 
     
   
  // Our Data values for length are represented by the set

  private Set lengthSet;


  // The Data class FlatField, which will hold data.
   
  private FlatField amp_len_ff;  
  
  // The DataReference from the data to display
  
  private DataReferenceImpl amp_len_ref;

  // The 2D display, and its the maps
  
  private DisplayImpl display;
  private ScalarMap lenXMap, ampYMap, ampRGBMap;
  
  
  public P5_01 (String[] args)
    throws RemoteException, VisADException {

    // Create the quantities
    
    length = new RealType("length", SI.meter, null);
    amplitude = new RealType("amplitude", SI.meter, null);
    
       
    // Create the function

    func_len_amp = new FunctionType(length,amplitude);
    
    
    // Create the domain (length) set
    int nSamples = 10000;    
    lengthSet = new Linear1DSet(length, -3.0, 3.0, nSamples);
    
        
    // Values for amplitude are in an array like float[ rangeDim ][ nSamples]
    
    float[][] ampVals = new float[1][nSamples];
    
    
    // Get the lengthtime values in the domain set to help with the calculations
    // "flase" means we don't get a copy from the samples

    float[][] lenVals  = lengthSet.getSamples( false );
  
    // Create some amplitude values:
    
    
    for(int i=0;i<nSamples;i++){
    
      ampVals[0][i] = (float) Math.sin( (float) lenVals[0][i] );
    }
    
    // Create a FlatField
    // Use FlatField(FunctionType type, Set domain_set)
    
   
     amp_len_ff = new FlatField( func_len_amp, lengthSet);
     
     
     // and initialize it with the first samples array
     
     amp_len_ff.setSamples( ampVals );
    
    
    // Create Display and its maps
    
    // A 2D display
    
          //          display = new DisplayImplJ2D("display1");
         display = new DisplayImplJ3D("display1", new TwoDDisplayRendererJ3D());
    // Get display's graphics mode control draw scales 
    
    GraphicsModeControl dispGMC = (GraphicsModeControl) 
display.getGraphicsModeControl();
    
    dispGMC.setScaleEnable(true);    
    
    
    // Create the ScalarMaps
    
    lenXMap = new ScalarMap( length, Display.XAxis );    
    ampYMap = new ScalarMap( amplitude, Display.YAxis );
    ampRGBMap = new ScalarMap( amplitude, Display.RGB );
     
    
    // Add maps to display
    
    display.addMap( lenXMap );
    display.addMap( ampYMap );
    display.addMap( ampRGBMap );
    
       
    // Create a data reference and set the FlatField as our data 
    
    amp_len_ref = new DataReferenceImpl("amp_len_ref");
    
    amp_len_ref.setData( amp_len_ff );
    
    // Add reference to display
    
    display.addReference( amp_len_ref );
    
    
    // Create application window, put display into it 
  
    JFrame jframe = new JFrame("VisAD Tutorial example 5_01");
    jframe.getContentPane().add(display.getComponent());
    
    // Set window size and make it visible
    
    jframe.setSize(300, 300);
    jframe.setVisible(true);
    

    
    // index to count time step
    int index=0;
    // Loop forever, changing the samples array every time
    while(true){
      try{

        // recalculate the values
        for(int i=0;i<nSamples;i++){

          ampVals[0][i] = (float) Math.sin( lenVals[0][i] + (float) index/50);
        }

        // Update samples
        amp_len_ff.setSamples( ampVals );
                  //      System.out.println("update!" + index);
                  

        index++;
        Thread.sleep(10);
      }
      catch (InterruptedException ie){
       ie.printStackTrace(); 
      }
    
    }
    
  }
  
  
  public static void main(String[] args)
    throws RemoteException, VisADException
  {
    new P5_01(args);
  }

} //end of Visad Tutorial Program 5_01
  • 2001 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: