Project

General

Profile

« Previous | Next » 

Revision da56b12f

Added by Leszek Koltunski about 2 years ago

Beginnings of support for display of a collection of bandaged cubits in the CreatorView.

View differences:

src/main/java/org/distorted/bandaged/BandagedCreatorRenderer.java
1 1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
2
// Copyright 2022 Leszek Koltunski                                                               //
3 3
//                                                                                               //
4 4
// This file is part of Magic Cube.                                                              //
5 5
//                                                                                               //
......
21 21

  
22 22
import android.opengl.GLSurfaceView;
23 23

  
24
import org.distorted.library.effect.EffectType;
25
import org.distorted.library.effect.VertexEffectQuaternion;
26
import org.distorted.library.effect.VertexEffectRotate;
27 24
import org.distorted.library.main.DistortedLibrary;
25
import org.distorted.library.main.DistortedNode;
28 26
import org.distorted.library.main.DistortedScreen;
27
import org.distorted.library.type.Static4D;
29 28

  
30 29
import javax.microedition.khronos.egl.EGLConfig;
31 30
import javax.microedition.khronos.opengles.GL10;
......
37 36
   private final BandagedCreatorView mView;
38 37
   private final DistortedScreen mScreen;
39 38

  
39
   private final BandagedCubit[] mCubits;
40

  
41
   private float[][] POSITIONS = new float[][]
42
        {
43
          {-1.0f, +1.0f, +1.0f},
44
          {-1.0f, +1.0f, +0.0f},
45
          {-1.0f, +1.0f, -1.0f},
46
          {-1.0f,  0.0f, +1.0f},
47
          {-1.0f,  0.0f, +0.0f},
48
          {-1.0f,  0.0f, -1.0f},
49
          {-1.0f, -1.0f, +1.0f},
50
          {-1.0f, -1.0f, +0.0f},
51
          {-1.0f, -1.0f, -1.0f},
52
          { 0.0f, -1.0f, +1.0f},
53
          { 0.0f, -1.0f, +0.0f},
54
          { 0.0f, +1.0f, +1.0f},
55
          { 0.0f, +1.0f, +0.0f},
56
          { 0.0f, +1.0f, -1.0f},
57
          { 0.0f,  0.0f, +1.0f},
58
          { 0.0f,  0.0f, -1.0f},
59
          { 1.0f, +1.0f, +1.0f},
60
          { 1.0f, +1.0f, +0.0f},
61
          { 1.0f, +1.0f, -1.0f},
62
          { 1.0f,  0.0f, +1.0f},
63
          { 1.0f,  0.0f, +0.0f},
64
          { 1.0f, -1.0f, +1.0f},
65
          { 1.0f,  0.0f, -1.0f },
66
          { 1.0f, -1.0f, -1.0f },
67
          { 1.0f, -1.0f, +0.0f },
68
          { 0.0f, -1.0f, -1.0f },
69
        };
70

  
71
   Static4D mQuat1, mQuat2;
72
   int mScreenMin;
73

  
40 74
///////////////////////////////////////////////////////////////////////////////////////////////////
41 75

  
42 76
   BandagedCreatorRenderer(BandagedCreatorView v)
43 77
     {
44 78
     final float BRIGHTNESS = 0.333f;
45 79

  
80
     mQuat1 = new Static4D(0,0,0,1);
81
     mQuat2 = new Static4D(0,0,0,1);
82

  
46 83
     mView = v;
47 84
     mScreen = new DistortedScreen();
48 85
     mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f);
86

  
87
     mCubits = createCubits();
88
     }
89

  
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

  
92
   private BandagedCubit[] createCubits()
93
     {
94
     int len = POSITIONS.length;
95
     BandagedCubit[] cubits = new BandagedCubit[len];
96

  
97
     for(int c=0; c<len; c++)
98
       {
99
       cubits[c] = new BandagedCubit(POSITIONS[c],mQuat1,mQuat2,1.0f);
100
       DistortedNode node = cubits[c].getNode();
101
       mScreen.attach(node);
102
       }
103

  
104
     return cubits;
49 105
     }
50 106

  
51 107
///////////////////////////////////////////////////////////////////////////////////////////////////
......
62 118
   @Override
63 119
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
64 120
      {
121
      mScreenMin = Math.min(width, height);
65 122
      mScreen.resize(width,height);
66 123
      }
67 124

  
......
70 127
   @Override
71 128
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
72 129
      {
73
      DistortedLibrary.setMax(EffectType.VERTEX,25);
74
      VertexEffectRotate.enable();
75
      VertexEffectQuaternion.enable();
76

  
77 130
      DistortedLibrary.onSurfaceCreated(mView.getContext(),this,1);
78 131
      }
79 132

  
......
83 136
     {
84 137
     android.util.Log.e("CREATOR", "unexpected exception: "+ex.getMessage() );
85 138
     }
86

  
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

  
89
   DistortedScreen getScreen()
90
     {
91
     return mScreen;
92
     }
93 139
}

Also available in: Unified diff