Log in or register to post comments

Load 2 Image Texture in VideoPlayback Sample

December 11, 2012 - 4:25am #1

Hi, i am following Videoplay back sample for iOS, i am successfully loading one texture on my marker now i want to load two texture on same time on single marker, with different positions and scales. And these two texture can be in any form not in just rectangular. As far as my experienced in Vuforia when i load a texture other than rectangular shape it makes image's edges black where image are not in rectangular shape.
This will be great for me. Thanks in advance.

Load 2 Image Texture in VideoPlayback Sample

June 12, 2015 - 2:32am #9

Hi.

I've to load an  image from url. how can i do that ?

 

Load 2 Image Texture in VideoPlayback Sample

December 12, 2012 - 2:47am #8

Here is What i am doing.
QCAR::Matrix44F modelViewMatrixButton = QCAR::Tool::convertPose2GLMatrix(trackablePose);
QCAR::Matrix44F modelViewProjectionButton;

ShaderUtils::translatePoseMatrix(0.0f, 0.0f, videoData[playerIndex].targetPositiveDimensions.data[1] / SCALE_ICON_TRANSLATION, &modelViewMatrixButton.data[0]);

ShaderUtils::scalePoseMatrix(videoData[playerIndex].targetPositiveDimensions.data[1] / SCALE_ICON,
videoData[playerIndex].targetPositiveDimensions.data[1] / SCALE_ICON,
videoData[playerIndex].targetPositiveDimensions.data[1] / SCALE_ICON,
&modelViewMatrixButton.data[0]);

ShaderUtils::multiplyMatrix(&qUtils.projectionMatrix.data[0],
&modelViewMatrixButton.data[0] ,
&modelViewProjectionButton.data[0]);

glDepthFunc(GL_LEQUAL);

glUseProgram(shaderProgramID);

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, quadVertices);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, quadNormals);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, quadTexCoords);

glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);

// Blend the icon over the background
//use to make transparent image
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, index);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjectionButton.data[0] );

glDrawElements(GL_TRIANGLES, NUM_QUAD_INDEX, GL_UNSIGNED_SHORT, quadIndices);

glDisable(GL_BLEND);

glDisableVertexAttribArray(vertexHandle);
glDisableVertexAttribArray(normalHandle);
glDisableVertexAttribArray(textureCoordHandle);

glUseProgram(0);

glDepthFunc(GL_LESS);

At here SCALE_ICON = 1; and SCALE_ICON_TRANSLATION = 1.98

Load 2 Image Texture in VideoPlayback Sample

December 12, 2012 - 2:34am #7

Thanks Nalin, I set SCALE_ICON to 1 only because divident should be set as it is dimension, now it looks better. Now my question is this, that what will be ideal size of image icon so that i can cover whole marker and i have multiple marker and these markers have different sizes some have width 400 some 500 and also 800. I am getting confuse what will be ideal size or what will be good approach to accomplish this task. Thanks again.

Load 2 Image Texture in VideoPlayback Sample

December 12, 2012 - 1:12am #6

If you set it to 0 I would expect it to crash with a division by 0 error on this line:

videoData[playerIndex].targetPositiveDimensions.data[1] / SCALE_ICON_TRANSLATION

 

What happens when you try experimenting with other values?


Also, have you tried experimenting with the values here?


            ShaderUtils::scalePoseMatrix(videoData[playerIndex].targetPositiveDimensions.data[1] / SCALE_ICON,

                                         videoData[playerIndex].targetPositiveDimensions.data[1] / SCALE_ICON,

                                         videoData[playerIndex].targetPositiveDimensions.data[1] / SCALE_ICON,

                                         &modelViewMatrixButton.data[0]);

 

N

 

Load 2 Image Texture in VideoPlayback Sample

December 12, 2012 - 12:55am #5

1) Are you creating the same app in Unity and also in XCode native?  if so why?

I am not creating same app for XCode and in Unity, these are different apps and for different purpose.

2) are you wanting to combine a unity generated project with additional objective C in XCode?

No, i am not going to combine both project.

Now i want to show image in its actual size as a texture on marker in XCode. I find two Constant "const float SCALE_ICON = 2.0f;" and "const float SCALE_ICON_TRANSLATION = 1.98f;" which will change scaling of icon, but can i get actual size of icon. I set "const float SCALE_ICON_TRANSLATION = 0.0f;" to 0 but it not show me any image. What will be ideal size for icon.

Load 2 Image Texture in VideoPlayback Sample

December 11, 2012 - 7:44am #4

I am not sure I understand?

1) Are you creating the same app in Unity and also in XCode native?  if so why?

...or 2) are you wanting to combine a unity generated project with additional objective C in XCode?

BTW if 1) If you look at the native iOS video playback and search for SCALE_ICON this will give you a clue as to where the texture icon is being created, though you will need to be familiar with OpenGL ES if you wish to change it.

 

 

Load 2 Image Texture in VideoPlayback Sample

December 11, 2012 - 5:25am #3

Thanks Nalin. My second question about unity but here i am asking for Xcode, i am build app both in xcode and in unity. So how can i scale icon and change position in xcode objective c.

 

Load 2 Image Texture in VideoPlayback Sample

December 11, 2012 - 4:58am #2

Hi Aleem,

It sounds like what you want to do is to extend and modify the VideoPlaybackBehaviour.cs.

For starters if you look at where the textures are declared public:

    // Texture for the play icon

    public Texture m_playTexture = null;

 

    // Texture for the busy icon

    public Texture m_busyTexture = null;

 

    // Texture for the error icon

    public Texture m_errorTexture = null;

 

...this exposes them in the Inspector.  You will need to do the same for any additional textures.

Next you will need to add the functionality to display them and also to scale/not scale the icon.  Please see my response to your other question about this to see how you might be able to modify this script so that the scaling does not override what you put in place.

HTH

 

Log in or register to post comments