1. Michael Ludwig
  2. ferox

Commits

Michael Ludwig  committed f0ae76a

Update scene components to use new entreri api

  • Participants
  • Parent commits 91602a5
  • Branches default

Comments (0)

Files changed (15)

File ferox-scene/src/main/java/com/ferox/scene/AbstractPlacedLight.java

View file
     public final T setFalloffDistance(double distance) {
         // No argument checking, a negative distance disables
         // light falloff so every value is supported
-        falloffDistance.set(distance, getIndex(), 0);
+        falloffDistance.set(distance, getIndex());
         return (T) this;
     }
 
      * @return The falloff distance
      */
     public final double getFalloffDistance() {
-        return falloffDistance.get(getIndex(), 0);
+        return falloffDistance.get(getIndex());
     }
 }

File ferox-scene/src/main/java/com/ferox/scene/AtmosphericFog.java

View file
     public AtmosphericFog setFalloff(Falloff falloff) {
         if (falloff == null)
             throw new NullPointerException("Falloff cannot be null");
-        this.falloff.set(falloff, getIndex(), 0);
+        this.falloff.set(falloff, getIndex());
         return this;
     }
 
      * @return The Falloff of this fog
      */
     public Falloff getFalloff() {
-        return falloff.get(getIndex(), 0);
+        return falloff.get(getIndex());
     }
 
     /**
      * @return This AtmosphericFog for chaining purposes
      * @throws IllegalArgumentException if dist <= 0
      */
-    public AtmosphericFog setOpaqueDistance(float dist) {
-        if (dist <= 0f)
+    public AtmosphericFog setOpaqueDistance(double dist) {
+        if (dist <= 0)
             throw new IllegalArgumentException("Distance must be positive, not: " + dist);
-        distanceToOpaque.set(dist, getIndex(), 0);
+        distanceToOpaque.set(dist, getIndex());
         return this;
     }
 
      * @return The opaque distance, this will be above 0
      */
     public double getOpaqueDistance() {
-        return distanceToOpaque.get(getIndex(), 0);
+        return distanceToOpaque.get(getIndex());
     }
 
     /**

File ferox-scene/src/main/java/com/ferox/scene/BlinnPhongMaterial.java

View file
     public void setShininess(double shiny) {
         if (shiny < 0f)
             throw new IllegalArgumentException("Shininess must be positive, not: " + shiny);
-        shininess.set(shiny, getIndex(), 0);
+        shininess.set(shiny, getIndex());
     }
 
     /**
      * @return The shininess exponent, will be at least 0
      */
     public double getShininess() {
-        return shininess.get(getIndex(), 0);
+        return shininess.get(getIndex());
     }
 }

File ferox-scene/src/main/java/com/ferox/scene/Camera.java

View file
      * @return The field of view for this Camera, in degrees
      */
     public double getFieldOfView() {
-        return fov.get(getIndex(), 0);
+        return fov.get(getIndex());
     }
     
     /**
     public Camera setFieldOfView(double fov) {
         if (fov < 0.0 || fov > 180.0)
             throw new IllegalArgumentException("Field of view must be in [0, 180]: " + fov);
-        this.fov.set(fov, getIndex(), 0);
+        this.fov.set(fov, getIndex());
         return this;
     }
     
      * @return The distance to the near z plane of the camera
      */
     public double getNearZDistance() {
-        return znear.get(getIndex(), 0);
+        return znear.get(getIndex());
     }
     
     /**
             throw new IllegalArgumentException("Near distances must be greater than 0: " + znear);
         if (znear > zfar)
             throw new IllegalArgumentException("Near distance must be less than far: " + znear + ", " + zfar);
-        this.znear.set(znear, getIndex(), 0);
-        this.zfar.set(zfar, getIndex(), 0);
+        this.znear.set(znear, getIndex());
+        this.zfar.set(zfar, getIndex());
         return this;
     }
     
      * @return The distance to the far z plane of the camera
      */
     public double getFarZDistance() {
-        return zfar.get(getIndex(), 0);
+        return zfar.get(getIndex());
     }
 
     /**
      * @return The Surface of this Camera
      */
     public Surface getSurface() {
-        return surface.get(getIndex(), 0);
+        return surface.get(getIndex());
     }
 
     /**
      * @throws NullPointerException if surface is null
      */
     public Camera setSurface(Surface surface) {
-        this.surface.set(surface, getIndex(), 0);
+        this.surface.set(surface, getIndex());
         return this;
     }
 }

File ferox-scene/src/main/java/com/ferox/scene/InfluenceRegion.java

View file
     }
     
     public boolean isNegated() {
-        return negate.get(getIndex(), 0);
+        return negate.get(getIndex());
     }
     
     public InfluenceRegion setNegated(boolean negate) {
-        this.negate.set(negate, getIndex(), 0);
+        this.negate.set(negate, getIndex());
         return this;
     }
     

File ferox-scene/src/main/java/com/ferox/scene/Influences.java

View file
     private Influences() { }
     
     public Set<Entity> getInfluencedSet() {
-        return Collections.unmodifiableSet(entities.get(getIndex(), 0));
+        return Collections.unmodifiableSet(entities.get(getIndex()));
     }
     
     public Influences setInfluenced(Entity e, boolean canInfluence) {
             throw new NullPointerException("Entity cannot be null");
         
         // SetFactory ensures that this is not null
-        Set<Entity> set = entities.get(getIndex(), 0);
+        Set<Entity> set = entities.get(getIndex());
         if (canInfluence)
             set.add(e);
         else
             throw new NullPointerException("Entity cannot be null");
         
         // SetFactory ensures that this is not null
-        Set<Entity> set = entities.get(getIndex(), 0);
+        Set<Entity> set = entities.get(getIndex());
         return set.contains(e);
     }
     
     private static class SetFactory implements PropertyFactory<ObjectProperty<Set<Entity>>> {
         @Override
         public ObjectProperty<Set<Entity>> create() {
-            return new ObjectProperty<Set<Entity>>(1);
+            return new ObjectProperty<Set<Entity>>();
         }
 
         @Override
         public void setDefaultValue(ObjectProperty<Set<Entity>> property, int index) {
-            property.set(new HashSet<Entity>(), index, 0);
+            property.set(new HashSet<Entity>(), index);
         }
 
         @Override
         public void clone(ObjectProperty<Set<Entity>> src, int srcIndex,
                           ObjectProperty<Set<Entity>> dst, int dstIndex) {
-            Set<Entity> toClone = src.get(srcIndex, 0);
-            dst.set(new HashSet<Entity>(toClone), dstIndex, 0);
+            Set<Entity> toClone = src.get(srcIndex);
+            dst.set(new HashSet<Entity>(toClone), dstIndex);
         }
     }
 }

File ferox-scene/src/main/java/com/ferox/scene/Material.java

View file
         if (normals.getElementSize() != 3)
             throw new IllegalArgumentException("Normals must have an element size of 3, not: " + normals.getElementSize());
 
-        this.normals.set(normals, getIndex(), 0);
+        this.normals.set(normals, getIndex());
         return (T) this;
     }
     
      * @return The normal vector data to use for lighting calculations
      */
     public final VertexAttribute getNormals() {
-        return normals.get(getIndex(), 0);
+        return normals.get(getIndex());
     }
 }

File ferox-scene/src/main/java/com/ferox/scene/NormalMap.java

View file
      * @return The tangent vectors if this NormalMap is in tangent space
      */
     public VertexAttribute getTangents() {
-        return tangentVectors.get(getIndex(), 0);
+        return tangentVectors.get(getIndex());
     }
 
     /**
             if (tangents.getElementSize() != 3)
                 throw new IllegalArgumentException("Tangents must have an element size of 3, not: " + tangents.getElementSize());
         }
-        tangentVectors.set(tangents, getIndex(), 0);
+        tangentVectors.set(tangents, getIndex());
         return this;
     }
 

File ferox-scene/src/main/java/com/ferox/scene/Renderable.java

View file
 import com.lhkbob.entreri.ComponentData;
 import com.lhkbob.entreri.TypeId;
 import com.lhkbob.entreri.Unmanaged;
-import com.lhkbob.entreri.property.ElementSize;
 import com.lhkbob.entreri.property.IntProperty;
 import com.lhkbob.entreri.property.ObjectProperty;
 
      */
     public static final TypeId<Renderable> ID = TypeId.get(Renderable.class);
     
-    private static final int INDEX_OFFSET = 0;
-    private static final int INDEX_COUNT = 1;
-    
     private ObjectProperty<VertexAttribute> vertices;
     private ObjectProperty<VertexBufferObject> indices;
     private ObjectProperty<PolygonType> polyType;
     
-    @ElementSize(2)
-    private IntProperty indexConfig; // 0 = offset, 1 = count
+    private IntProperty indexOffset;
+    private IntProperty indexCount;
     
     private AxisAlignedBoxProperty localBounds;
     private AxisAlignedBoxProperty worldBounds;
         if (vertices.getElementSize() == 1)
             throw new IllegalArgumentException("Vertices can only have an element size of 2, 3, or 4");
         
-        this.vertices.set(vertices, getIndex(), 0);
+        this.vertices.set(vertices, getIndex());
         return this;
     }
 
         
         int componentIndex = getIndex();
         
-        this.indices.set(indices, componentIndex, 0);
-        polyType.set(type, componentIndex, 0);
-        indexConfig.set(first, componentIndex, INDEX_OFFSET);
-        indexConfig.set(count, componentIndex, INDEX_COUNT);
+        this.indices.set(indices, componentIndex);
+        polyType.set(type, componentIndex);
+        indexOffset.set(first, componentIndex);
+        indexCount.set(count, componentIndex);
         
         return this;
     }
      *         transformed before being rendered.
      */
     public VertexAttribute getVertices() {
-        return vertices.get(getIndex(), 0);
+        return vertices.get(getIndex());
     }
 
     /**
      * @return The indices, may be null
      */
     public VertexBufferObject getIndices() {
-        return indices.get(getIndex(), 0);
+        return indices.get(getIndex());
     }
 
     /**
      *         array indices)
      */
     public int getIndexCount() {
-        return indexConfig.get(getIndex(), INDEX_COUNT);
+        return indexCount.get(getIndex());
     }
 
     /**
      *         indices)
      */
     public int getIndexOffset() {
-        return indexConfig.get(getIndex(), INDEX_OFFSET);
+        return indexOffset.get(getIndex());
     }
     
     /**
      * @return The PolygonType rendered by this Renderable
      */
     public PolygonType getPolygonType() {
-        return polyType.get(getIndex(), 0);
+        return polyType.get(getIndex());
     }
 
     /**

File ferox-scene/src/main/java/com/ferox/scene/SpotLight.java

View file
      * @return The cutoff angle in degrees, will be in [0, 90]
      */
     public double getCutoffAngle() {
-        return cutoffAngle.get(getIndex(), 0);
+        return cutoffAngle.get(getIndex());
     }
 
     /**
     public SpotLight setCutoffAngle(double angle) {
         if (angle < 0 || angle > 90)
             throw new IllegalArgumentException("Illegal cutoff angle, must be in [0, 90], not: " + angle);
-        cutoffAngle.set(angle, getIndex(), 0);
+        cutoffAngle.set(angle, getIndex());
         return this;
     }
 }

File ferox-scene/src/main/java/com/ferox/scene/TextureMap.java

View file
      * @return The texture coordinates used to access this TextureMap's texture
      */
     public final VertexAttribute getTextureCoordinates() {
-        return textureCoordinates.get(getIndex(), 0);
+        return textureCoordinates.get(getIndex());
     }
 
     /**
         if (texCoords.getData().getData().getDataType() != DataType.FLOAT)
             throw new IllegalArgumentException("VertexAttribute must have FLOAT data");
         
-        textureCoordinates.set(texCoords, getIndex(), 0);
+        textureCoordinates.set(texCoords, getIndex());
         return (T) this;
     }
 
      * @return This TextureMap's texture
      */
     public final Texture getTexture() {
-        return texture.get(getIndex(), 0);
+        return texture.get(getIndex());
     }
 
     /**
         if (texture == null)
             throw new NullPointerException("Texture cannot be null");
         validate(texture);
-        this.texture.set(texture, getIndex(), 0);
+        this.texture.set(texture, getIndex());
         return (T) this;
     }
 

File ferox-scene/src/main/java/com/ferox/scene/Transparent.java

View file
      * @return The opacity
      */
     public double getOpacity() {
-        return opacity.get(getIndex(), 0);
+        return opacity.get(getIndex());
     }
 
     /**
     public Transparent setOpacity(double opacity) {
         if (opacity < 0f || opacity > 1f)
             throw new IllegalArgumentException("Opacity must be in [0, 1], not: " + opacity);
-        this.opacity.set(opacity, getIndex(), 0);
+        this.opacity.set(opacity, getIndex());
         return this;
     }
 }

File ferox-scene/src/main/java/com/ferox/scene/controller/ffp/LightGroupFactory.java

View file
         @Override
         public StateNode getNode(Entity e) {
             if (e.get(renderable)) {
-                int group = groupAssignment.get(renderable.getIndex(), 0);
+                int group = groupAssignment.get(renderable.getIndex());
                 return nodes.get(group);
             } else {
                 // shouldn't happen

File ferox-scene/src/main/java/com/ferox/scene/controller/light/LightGroupController.java

View file
                 
                 // check if we've already processed this entity in another pvs
                 if (!callback.renderable.isEnabled() 
-                    || assignments.get(callback.renderable.getIndex(), 0) >= 0) {
+                    || assignments.get(callback.renderable.getIndex()) >= 0) {
                     continue;
                 }
                 
                 }
                 
                 // assign group to entity
-                assignments.set(lightGroup.intValue(), callback.renderable.getIndex(), 0);
+                assignments.set(lightGroup.intValue(), callback.renderable.getIndex());
             }
         }
         
     @Override
     public void init(EntitySystem system) {
         super.init(system);
-        assignments = system.decorate(Renderable.ID, new IntProperty.Factory(1, 0));
+        assignments = system.decorate(Renderable.ID, new IntProperty.Factory(-1));
     }
     
     @Override

File ferox-scene/src/test/java/com/ferox/scene/controller/ffp/SimpleTest.java

View file
 import com.ferox.renderer.Framework;
 import com.ferox.renderer.OnscreenSurface;
 import com.ferox.renderer.OnscreenSurfaceOptions;
-import com.ferox.renderer.OnscreenSurfaceOptions.MultiSampling;
 import com.ferox.renderer.impl.jogl.JoglFramework;
 import com.ferox.renderer.impl.lwjgl.LwjglFramework;
 import com.ferox.resource.VertexBufferObject.StorageMode;
         private Animation() { }
         
         public double getLifetime() {
-            return life.get(getIndex(), 0);
+            return life.get(getIndex());
         }
         
         public void setLifetime(double lt) {
-            life.set(lt, getIndex(), 0);
+            life.set(lt, getIndex());
         }
         
         public @Const Vector3 getDirection() {