Package apple.glkit
Class GLKReflectionMapEffect
- java.lang.Object
-
- org.moe.natj.general.NativeObject
-
- org.moe.natj.objc.ObjCObject
-
- apple.NSObject
-
- apple.glkit.GLKBaseEffect
-
- apple.glkit.GLKReflectionMapEffect
-
- All Implemented Interfaces:
GLKNamedEffect,NSObject
public class GLKReflectionMapEffect extends GLKBaseEffect implements GLKNamedEffect
GLKReflectionMapEffect GLKReflectionMapEffect is a subclass of GLKBaseEffect. It is expected that GLKBaseEffect functionality will be used in combination with GLKReflectionMapEffect. GLKReflectionMapEffect implements common reflection mapping functionality as is used by many of todays games and simulations. A reflection or environment map can be thought of as a texture mapped polyhedral or spherical mesh that encloses a 3D model. When the model is rendered surface normals from the model are used to calculate reflection vectors which intersect the environment map at some location. The environment map texture color at this location is used to impart a modulated environment map color on the model giving the appearance that the shiny model is reflecting its surroundings to the viewer. The polyhedral shape used for GLKReflectionMapEffect is a cube. Because reflection mapping relies on surface normals to compute the intersection between reflected rays and the environment map the GLKVertexAttribNormal array must be enabled in order for GLKReflectionMapEffect to work properly. The normals are always normalized. GLKReflectionMapEffect requires at least an OpenGL ES 2.0 context on iOS and an OpenGL Core Profile context on OS X. This context must be initialized and made current prior to creating or initializing GLKReflectionMapEffect instances. No OpenGL context state settings are modified when a GLKReflectionMapEffect instance is created or its properties set. When -[GLKReflectionMapEffect prepareToDraw] is called it modifies the following state: GL_CURRENT_PROGRAM GL_TEXTURE_BINDING_CUBE_MAP For performance reasons GLKReflectionMapEffect does not restore any of these state settings. It is up to the client application to save/restore/set these state elements as they choose. A cube mapped texture name must be provided to GLKReflectionMapEffect to provide it texture data for the 6 faces of the environment map. GLKReflectionMapEffect reflection vectors are computed in eye space per section 2.11.4 of the OpenGL 2.1 desktop specification for the GL_REFLECTION_MAP texgen mode. Typical reflection mapping uses an environment map with a fixed position (e.g. the sky in a real world rendering) and will accurately map the reflection map on the model regardless of the modelview transformation. To achieve this effect decompose the modelview matrix into its model and view components (i.e. the transforms on the object are the model and the transforms on the view are the camera). Then undo the viewing transform by inverting the viewing matrix - call this Vinv. Now, starting with Vinv, treat it as the canonical normal matrix by applying an inverse transpose to it and choosing the upper 3x3 elements of the result. inverseTranspose(Vinv) simplifies to Vtranspose. To apply this result to GLKReflectionMapEffect set its matrix property as follows: reflectionMapEffect.matrix = GLKMatrix4GetMatrix3(Vtranspose); to get correct, view-angle independent reflection mapping. The following (5) steps are required to use GLKReflectionMapEffect: (1) Allocate and initialize an instance of GLKReflectionMapEffect reflectionMapEffect = [[GLKReflectionMapEffect alloc] init]; (2) Initialize vertex attribute / vertex array state preferrably with a vertex array object for the model or scene to be drawn. glGenVertexArraysOES(1, &vaoName); glBindVertexArrayOES(vaoName); // Create and initialize VBO for each vertex attribute // The example below shows an example of setup up the position and normal vertex attributes. // Specifying and binding a GLKVertexAttribNormal array attribute is required for GLKReflectionMapEffect // to work properly. The normals are always normalized. glGenBuffers(1, &positionVBO); glBindBuffer(positionVBO); glBufferData(GL_ARRAY_BUFFER, vboSize, dataBufPtr, GL_STATIC_DRAW); glVertexAttribPointer(GLKVertexAttribPosition, size, type, normalize, stride, NULL); glGenBuffers(1, &normalVBO); glBindBuffer(normalVBO); glBufferData(GL_ARRAY_BUFFER, vboSize, dataBufPtr, GL_STATIC_DRAW); glVertexAttribPointer(GLKVertexAttribNormal, size, type, normalize, stride, NULL); ... repeat the steps above for other desired vertex attributes glBindVertexArrayOES(0); // unbind the VAO we created above (3) Create a cube map texture for the reflection map glGenTextures(1, &textureCubeMap); glBindTexture(GL_TEXTURE_CUBE_MAP, textureCubeMap); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); GLenum cubeMapBase = GL_TEXTURE_CUBE_MAP_POSITIVE_X; for(face = 0; face < 6; face++) glTexImage2D(cubeMapBase + face, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, faceData[face]); (4) Set the textureCubeMap property to our new GL cube map and turn on reflection mapping reflectionMapEffect.enable = GL_TRUE; reflectionMapEffect.textureCubeMap = textureCubeMap; // created in step (2) above (5) For each frame drawn: Update properties that change per frame. Synchronize the changed effect state by calling -[GLKReflectionMapEffect prepareToDraw]. Draw the model with the effect reflectionMapEffect.transform.modelviewMatrix = modelviewMatrix; [reflectionMapEffect prepareToDraw]; glBindVertexArrayOES(vaoName); glDrawArrays(GL_TRIANGLE_STRIP, 0, vertCt);
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class apple.NSObject
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedGLKReflectionMapEffect(org.moe.natj.general.Pointer peer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanaccessInstanceVariablesDirectly()static GLKReflectionMapEffectalloc()static java.lang.ObjectallocWithZone(org.moe.natj.general.ptr.VoidPtr zone)static booleanautomaticallyNotifiesObserversForKey(java.lang.String key)static voidcancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)static voidcancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)static NSArray<java.lang.String>classFallbacksForKeyedArchiver()static org.moe.natj.objc.ClassclassForKeyedUnarchiver()static java.lang.StringdebugDescription_static()static java.lang.Stringdescription_static()static longhash_static()GLKReflectionMapEffectinit()static NSObject.Function_instanceMethodForSelector_retinstanceMethodForSelector(org.moe.natj.objc.SEL aSelector)static NSMethodSignatureinstanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)static booleaninstancesRespondToSelector(org.moe.natj.objc.SEL aSelector)static booleanisSubclassOfClass(org.moe.natj.objc.Class aClass)static NSSet<java.lang.String>keyPathsForValuesAffectingValueForKey(java.lang.String key)GLKMatrix3matrix()Identitystatic java.lang.Objectnew_objc()voidprepareToDraw()static booleanresolveClassMethod(org.moe.natj.objc.SEL sel)static booleanresolveInstanceMethod(org.moe.natj.objc.SEL sel)voidsetMatrix(GLKMatrix3 value)Identitystatic voidsetVersion_static(long aVersion)static org.moe.natj.objc.Classsuperclass_static()GLKEffectPropertyTexturetextureCubeMap()GL Texture Name == 0static longversion_static()-
Methods inherited from class apple.glkit.GLKBaseEffect
colorMaterialEnabled, constantColor, fog, label, light0, light1, light2, lightingType, lightModelAmbientColor, lightModelTwoSided, material, setColorMaterialEnabled, setConstantColor, setLabel, setLightingType, setLightModelAmbientColor, setLightModelTwoSided, setTextureOrder, setUseConstantColor, texture2d0, texture2d1, textureOrder, transform, useConstantColor
-
Methods inherited from class apple.NSObject
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKey
-
-
-
-
Method Detail
-
accessInstanceVariablesDirectly
public static boolean accessInstanceVariablesDirectly()
-
alloc
public static GLKReflectionMapEffect alloc()
-
allocWithZone
public static java.lang.Object allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
-
automaticallyNotifiesObserversForKey
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
-
cancelPreviousPerformRequestsWithTarget
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
-
cancelPreviousPerformRequestsWithTargetSelectorObject
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)
-
classFallbacksForKeyedArchiver
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
-
classForKeyedUnarchiver
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
-
debugDescription_static
public static java.lang.String debugDescription_static()
-
description_static
public static java.lang.String description_static()
-
hash_static
public static long hash_static()
-
instanceMethodForSelector
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
-
instanceMethodSignatureForSelector
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
-
instancesRespondToSelector
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
-
isSubclassOfClass
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
-
keyPathsForValuesAffectingValueForKey
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
-
new_objc
public static java.lang.Object new_objc()
-
resolveClassMethod
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
-
resolveInstanceMethod
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
-
setVersion_static
public static void setVersion_static(long aVersion)
-
superclass_static
public static org.moe.natj.objc.Class superclass_static()
-
version_static
public static long version_static()
-
init
public GLKReflectionMapEffect init()
- Overrides:
initin classGLKBaseEffect
-
matrix
public GLKMatrix3 matrix()
Identity
-
prepareToDraw
public void prepareToDraw()
- Specified by:
prepareToDrawin interfaceGLKNamedEffect- Overrides:
prepareToDrawin classGLKBaseEffect
-
setMatrix
public void setMatrix(GLKMatrix3 value)
Identity
-
textureCubeMap
public GLKEffectPropertyTexture textureCubeMap()
GL Texture Name == 0
-
-