Replace 3D model with different 3D model

Replace 3D model with different 3D model

1380457167 #61

Thank you so much !!!  that what i was looking for :D

Replace 3D model with different 3D model

1373342413 #60

Dear  Al,

When i try to convert 3D objek (obj) to .h file it's look fine, and i tried for once.

and now i'm trying to replace with another objek (ex: book.obj) i convert to .h file with opengl,

i put it into imagetarget.cpp

#include "book.h"

 

i replace glVertextAttribPointer Code :

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
                                      (const GLvoid*) &bookVerts[0]);

and then glDrawElements

glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
                               (const GLvoid*) &bookNumVerts[0]);

so i got this error message :
 

C:\Development\Android\vuforia-sdk-android-2-5-7\samples\sampleImage>ndk-build
"Compile++ arm  : ImageTargets <= ImageTargets.cpp
jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTarge
ts_ImageTargetsRenderer_renderFrame(JNIEnv*, jobject)':
jni/ImageTargets.cpp:441:65: error: invalid types 'unsigned int[int]' for array
subscript
make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1

could youe please help me

 

 

thanks, regards

Replace 3D model with different 3D model

1372412495 #59

ok i got that point, but the big different which i saw is in part "bananaVerts" and "TeapotVertices" is there any different function between verts and vertices ?

Those are just variable names (not functions), and they are defined in their respective header files (see teapot.h and banana.h); actually you can rename them if you like.

Note: understanding the difference between functions and variable names is the basic of C/C++ programming, maybe not appropriate to post these questions in the Vuforia forum...

 

 

Replace 3D model with different 3D model

1372410714 #58

AlessandroB wrote:

Concerning the OpenGL code below, the only difference is that the first will render the teapot mesh, and the second will render the banana mesh.

ok i got that point, but the big different which i saw is in part "bananaVerts" and "TeapotVertices" is there any different function between verts and vertices ?

thanks,

Replace 3D model with different 3D model

1372408472 #57

Hi,

so, if you are referring to the lighting condition of your environment (e.g. the room where you are doing your tests),

then this is expected; if the camera of your device gets a too dark image because the light is insufficient, it will be more difficult for Vuforia to detect the target.

Concerning the OpenGL code below, the only difference is that the first will render the teapot mesh, and the second will render the banana mesh.

 

Replace 3D model with different 3D model

1372407949 #56

hi Al, what i mean with "far from light" is lack of light / dark light

so when i stand in the dark light posistion, the object won't appear.

and could you please tell me the different and function of this two script

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &bananaVerts[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &bananaNormals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &bananaTexCoords[0]);

and

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &TeapotVertices[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &TeapotNormals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &TeapotTexCoords[0]);

thanks

Replace 3D model with different 3D model

1372402564 #55

my object won't appear if far from the light

which light ? there is no light in the official sample code.

 

Replace 3D model with different 3D model

1372380455 #54

hi AL, actually there is no reason why i use OPENGL 1, just for try and error.

and now i figure out the problem is, my object won't appear if far from the light

and when i try to light place the object appear clearly, could you give a reason why ?

 

thanks

regards

Replace 3D model with different 3D model

1372340858 #53

Is there a reason why you are using OpenGL ES 1.0 ?

You should always use OpenGL ES 2.0, unless your are targeting very old devices that might not support 2.0.

 

Replace 3D model with different 3D model

1372338448 #52

Dear Al,

Now all of object disapear...(teapot and banana)

i try re-import the project

rebuild with ndk-build

refresh

still nothing show..

please help me..

thanks

Replace 3D model with different 3D model

1372336419 #51

i've done with the instruction you gave me.

1. i set the USE_OPENGL_ES_1_1 flag to true

# The variable USE_OPENGL_ES_1_1 determines the OpenGL ES API version
# to use. If set to true, OpenGL ES 1.1 is used, otherwise OpenGL ES 2.0.

USE_OPENGL_ES_1_1 := true

# Set OpenGL ES version-specific settings.

2. rebuild with dos command

3. refresh the project.

 

and now my banana disapear

 

could you tell me why ?

 

thanks

regards

me

Replace 3D model with different 3D model

1372335060 #50

Hi, have a look here, everything is explained in detail:

https://developer.vuforia.com/forum/faq/android-how-do-i-replace-teapot

Also, if a model appears too small or too big, this is because you need to:

- adjust the scale to a different value

- rebuild the code with ndk-build and make sure the build was successfull

- refresh the project in Eclipse so that it picks the changes

 

 

 

Replace 3D model with different 3D model

1372334381 #49

hi Al, i follow all instrution below, and i changed my objek to banana.

i did this :

// Constants:
static const float kObjectScale = 120.f;

QCAR::DataSet* dataSetStonesAndChips    = 0;
QCAR::DataSet* dataSetTarmac            = 0;

but my banana.png just too small like a dot in image target

 

thanks,

 

regards

 Hi, in order to enable

1357908360 #48

 

Hi, in order to enable basic lighting (diffuse) effects, the vertex and fragment shaders must be modified as follows:

static const char* cubeMeshVertexShader = " \

attribute vec4 vertexPosition; \

attribute vec4 vertexNormal; \

attribute vec2 vertexTexCoord; \

varying vec2 texCoord; \

varying vec4 normal; \

uniform mat4 modelViewMatrix; \

uniform mat4 modelViewProjectionMatrix; \

void main() { \

   gl_Position = modelViewProjectionMatrix * vertexPosition; \

   normal = modelViewMatrix * vec4(vertexNormal.xyz, 0.0); \

   texCoord = vertexTexCoord; \

}";

 

static const char* cubeFragmentShader = " \

precision mediump float; \

varying vec2 texCoord; \

varying vec4 normal; \

uniform sampler2D texSampler2D; \

void main() { \

   vec3 n = normalize(normal.xyz); \

   vec3 lightDir = normalize(vec3(0.0, 0.0, -1.0)); \

   vec3 ambientLight = vec3(0.5, 0.5, 0.5); \

   vec3 ambientMaterial = vec3(0.3, 0.3, 0.3); \

   vec3 ambient = ambientMaterial * ambientLight; \

   vec3 diffuseLight = vec3(1.0, 1.0, 1.0); \

   vec3 diffuseMaterial = vec3(0.9, 0.9, 0.9); \

   float diffuseFactor = max(0.0, dot(n, lightDir)); \

   vec3 diffuse = diffuseFactor * diffuseMaterial * diffuseLight; \

   vec3 shadedColor = ambient + diffuse; \

   gl_FragColor = vec4(shadedColor, 1.0); \

}";

It is important to note that some of the variables defined in the fragment shaders, such as lightDir, ambientLight, diffuseLight and diffuseMaterial, would be better declared as uniform parameters, so that their values could be set from outside the shader (i.e. controlled from the application code); for simplicity reasons, this has not been done in the code above.

Also, a new uniform matrix, namely the “modelViewMatrix”, has been introduced in the vertex shader code; like for any other uniform parameters, the modelViewMatrix values must be set from the application code; this can be done in ImageTargets.cpp by simply adding the following line of code in the initRendering function:

modelViewMatrixHandle = glGetUniformLocation(shaderProgramID,

                                                "modelViewMatrix");

as well as adding the following line in the renderFrame function (just before calling glDrawElements):

glUniformMatrix4fv(modelViewMatrixHandle, 1, GL_FALSE,

                                   (GLfloat*)&modelViewMatrix.data[0] );

 

Let me know if something is not clear.

 

Replace 3D model with different 3D model

1357902919 #47

Hi, thanks for your  andwer. 

Yes, i already tried that solution but I would actually need something a bit nicer (such as lighting, material, diffusion). I know here the problem is that I'm not good at all with OpenGL.

Anywya, if you had some suggestion, they would be mooore than welcome :)

Hi, if you are fine with some

1357899180 #46

Hi, if you are fine with some "flat" solid colouring, you can achieve this by doing the following:

- open the CubeShader.h file

- replace this line:

   gl_FragColor = texture2D(texSampler2D, texCoord);

   with this:

   gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);

Note: the line above will set the four components as RGBA, with R (red) = 1.0, G (green) = 0, B (blue) = 0, and A (opacity) = 1.0; so this will make your objects look red, but use the RGBA values that you prefer.

Let me know if that would be sufficient or not; if you need more shaded colors (such as "diffuse" color effect, there is also a solution, but it requires many more code changes....)

 

Hi all,  thanks to everybody

1357897270 #45

Hi all, 

thanks to everybody for the useful help. 

I followed all the suggestions in this thread and I got my simple 3D object on screen.

Unfortunately, the UV mapping procedure (and then the baking) in Blender for objects more complex than a simple cube is very difficult, and I did not get any texture working on my object.

Do you have any idea on how I could achieve at least to get it coloured? I simply need to visualize some text on the frame marker, so nothing that should be very difficult per se.

Replace 3D model with different 3D model

1350894268 #44

Hi hoaxman, you see triangles and not squares because you did not disable GL_CULL_FACE;

so make sure you disable GL_CULL_FACE, by either commenting out the line of code "glEnable(GL_CULL_FACE)" at the beginning of the renderFrame method, or otheriwse by calling explicitly  "glDisable(GL_CULL_FACE);"  right before drawing your vertex array.

That should fix it (let me know then).

 

 

Replace 3D model with different 3D model

1350842543 #43

thx for reply alesandro :D
and i have followed your instruction..

same with you, i tried to make a simple cube on blender,
exported it to .obj - just give me an cubeVerts[]
then removed the line glVertexAttribPointer(normalHandle, ...) & glVertexAttribPointer(textureCoordHandle, ...)
also removed the line glEnableVertexAttribArray(normalHandle) & glEnableVertexAttribArray(textureCoordHandle)
and not forget to change glDrawElements(...) to glDrawArrays(...)

now it give me a strange cube, a cube with a triangle shapes for each faces instead of square shapes. i know it's because we put triangulate method to draw the object, but i don't how to make my cube as a cube as well..

 

Replace 3D model with different 3D model

1350493680 #42

Hi again hoaxman,
so I tried to replicate your issue, creating a mesh in Blender (a simple cube in my case), then exporting the mesh to OBJ,
and finally converting the OBJ to an OpenGL header file (.h) using the obj2opengl.pl script, same procedure you did, if I understand right.

So, indeed the perl script did produce (like in your case) a mesh containing only vertices and no texture coordinates (no normals either);
this happens because the .OBJ file exported by Blender also only contains vertices (and no texture coordinates).

Now, suppose we don't care about the texture coordinates, and you want to show your model in QCAR any way, then you'll need to do the following things:

- remove the line glVertexAttribPointer(normalHandle, ...) as we don't have normals

- remove the line glVertexAttribPointer(textureCoordHandle, ...) as we don't have texture coordinates

- VERY IMPORTANT: remove the line glEnableVertexAttribArray(normalHandle); as we don't have normals

- VERY IMPORTANT: remove the line glEnableVertexAttribArray(textureCoordHandle); as we don't have texture coordinates

- call glDrawArrays(GL_TRIANGLES, 0, MyMeshNumVerts);   instead of glDrawElements(...), as already explained in a previous message in this thread

- make sure that the scale kObjectScale value is appropriate for your mesh (as already explained in previous messages in this thread)

If you follow the above you'll be able to see your mesh somehow (as I was able too).

Another thing: sometime the perl script will produce triangles with vertices in clock-wise order; if that is the case, you will also need to remove the line glEnable(GL_CULL_FACE);

Of course a much better solution would be to make sure that your .OBJ exported from Blender also contains texture coodinates and normals up front,
so that the.h header will also do (but that's related to Blender export settings or so).

 

Replace 3D model with different 3D model

1350486360 #41

Hi hoaxman,

if you only have vertices (and no tex coords), it is expected that you won't be able to see your mesh;

if you want to see your mesh anyway, you'll need to to modify the shader code in CubeShader.h (I'm referring to ImageTargets sample), replacing the line:

gl_FragColor = texture2D(texSampler2D, texCoord);

with a line like:

gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);

This should show your mesh in a flat red color (but it will look flat, i.e. not shaded), so you can verify that it is actually drawn; then if you want to have texture coordinates, please check that your .obj file (as exported by Blender) does have texture coordinates, before you convert it to a .h file.

 

 

 

 

Replace 3D model with different 3D model

1350462456 #40

Hi there, i have a problem here when i want to convert .obj to .h with obj2opengl.pl

when i tried to convert banana.obj, i got my banana.h file, i checked its code and i got:
Array bananaVerts []
Array bananaNormals [] and
Array bananaTexCoords []
i modified the ImageTarget.cpp, compile and install it on my android, and the banana was successful appear on my android,

So, i tried my own object, i created it in blender, export into .obj (named nyancat.obj), then i convert into nyancat.h,
but when i checked the code, i can't find Array nyancatNormals [] and Array nyancatTexCoords [],
i only have Array of nyancatVerts []

first i ignored it, then i tried to modified the ImageTarget.cpp (and because of there was no texture for my nyancat, i didn't modify the ImageTarget.java). I compile and install it, i can't see my nyancat there..

is the problem is on my nyancat.h?

Replace 3D model with different 3D model

1348754866 #39

Hello,you seem not to mention that  we should add "banana.h" into ImaginationTargets.cppCool

Replace 3D model with different 3D model

1348754857 #38

Hello,you seem not to mention that  we should add "banana.h" into ImaginationTargets.cppCool

Replace 3D model with different 3D model

1347987728 #37

for anyone who see a weird banana, 

you need to change

private void loadTextures()    {

        mTextures.add(Texture.loadTextureFromApk("banana.jpg",getAssets()));

        mTextures.add(Texture.loadTextureFromApk("TextureTeapotBrass.png",                                                 getAssets()));

        mTextures.add(Texture.loadTextureFromApk("TextureTeapotBlue.png",                                                 getAssets()));

        mTextures.add(Texture.loadTextureFromApk("TextureTeapotRed.png",                getAssets()));

    }

to 

    private void loadTextures()    {

        mTextures.add(Texture.loadTextureFromApk("TextureTeapotBrass.png",                                                 getAssets()));

        mTextures.add(Texture.loadTextureFromApk("banana.jpg",getAssets()));

        mTextures.add(Texture.loadTextureFromApk("TextureTeapotBlue.png",                                                 getAssets()));

        mTextures.add(Texture.loadTextureFromApk("TextureTeapotRed.png",                getAssets()));

    }

the texture are loaded from ImageTargets.cpp line 351

        }        else if (strcmp(trackable->getName(), "stones") == 0)        {

            textureIndex = 1;

the weird banana is result from loading TextureTeapotBrass.png instead of banna.jpg

hope help anyone stuck with weird banana

 

 

Replace 3D model with different 3D model

1346850839 #36

Just to add some important spots..

Download the obj2opengl file. Unzip this and use the files as follows.

Paste the header file  banana.h  into the ImageTargets project.  location:ImageTargets/

Paste the jpg file banana.jpg into assets folder. location:ImageTargets/assets/

 

Find the ImageTargets.cpp INSIDE the jni folder and change this according to werther's advice! location:ImageTargets/jni/

 

 

werther wrote:

Guys, its working! I couldnt believe it, when I saw a banana floating over my table Smile Thank you so much for your help!

I used a solution that DavidBeard suggested:

       

1. Modify renderframe method in ImageTargets.cpp:

Replace this:

        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotVertices[0]);

        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotNormals[0]);

        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotTexCoords[0]);

with this:

 glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaVerts[0]);

 glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaNormals[0]);

 glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaTexCoords[0]);

 

And also replace this line:

glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &teapotIndices[0]);

with this one:

glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);

 

2. Modify loadTextures method in ImageTargets.java by adding a texture of banana:

    private void loadTextures()

    {

       mTextures.add(Texture.loadTextureFromApk("banana.jpg", getAssets())); 

        mTextures.add(Texture.loadTextureFromApk("TextureTeapotBrass.png", getAssets()));

        mTextures.add(Texture.loadTextureFromApk("TextureTeapotBlue.png", getAssets()));

        mTextures.add(Texture.loadTextureFromApk("TextureTeapotRed.png", getAssets()));        

    }

 

3. If you want your 3D model to be clearly visible, I recommend you to set kObjectScale = 120.f; (ImageTargets.cpp) 

4. Run the NDK-build and there you go. You will see a banana too! Smile

 

Working solution: http://interaktivnydokument.sk/download/ImageTargets.zip

<banana.h and banana.jpg download from http://heikobehrens.net/2009/08/27/obj2opengl/>

Replace 3D model with different 3D model

1345788803 #35

werther mentioned about that but i thought that was just a suggestion, not a must...

Can't believe that was the case :) I set "kObjectScale=120" now it works :)

Thanks a lot ppreuss, you saved my day :)

Replace 3D model with different 3D model

1345767311 #34

Hello,

Try setting the kObjectScale in ImageTargets.cpp to something larger.

Thank you,

-Peter

Replace 3D model with different 3D model

1345729139 #33

I've been looking for a solution to change this 3D object for whole day, and i've read every comment on this page but still i have nothing. I've got banana object and banana.h from http://heikobehrens.net/2009/08/27/obj2opengl/

 

In ImageTarget.java, i've added this line into loadTexture method:

mTextures.add(Texture.loadTextureFromApk("banana.jpg", getAssets()));

 

And then i've changed these lines in ImageTarget.cpp:

for USE_OPENGL_ES_1_1:

glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &bananaTexCoords[0]);

glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &bananaVerts[0]);

glNormalPointer(GL_FLOAT, 0,  (const GLvoid*) &bananaNormals[0]);

 

glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);

 

and for the rest:

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaVerts[0]);

glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaNormals[0]);

glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bananaTexCoords[0]);

 

glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);

 

I mean i've done everything as suggested, but now it draws nothing..? What am i missing? Thanks in advance...

Replace 3D model with different 3D model

1345096276 #32

how are u guys getting your own model ? I am still getting the teapot on both the stones and chips image targets...I have tried the code posted by muhammadgyan over here : https://ar.qualcomm.at/content/createreplace-object#top  ...still i m not getting it..please can someone tell me how to load the banana object provided i have the .h file and .png files already in my android project...where do we need to make the change in the ImageTargets.cpp file?

Replace 3D model with different 3D model

1345094235 #31

Forgot to mention the function name in ImageTarget.cpp:

Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_getCallFromJava.

 

Replace 3D model with different 3D model

1345089359 #30

Hi Its Done...:)

My 3d max guy wasn't converting the mesh into triangle. Once it was done it worked !!

Thanks guys..:)

I want to display no of models one by one in my project and chnge them on touch event.
Can some one guide me how to change my model to some other on tapping the screen in myImageTarget Project..?

I have tried changing bring teapot after my own model on touch event by calling a new function in ImageTarget.cpp

 

Heres the link to my ImageTarget.cpp.

Replace 3D model with different 3D model

1345082338 #29

Do you have another 3D environment, or a model conversion utility, that you can try with? - i.e. to generate the obj version from software other than 3DS Max.

But I wouldn't delete anything just yet. You might want to check on a 3D forum w/ 3DS Max users. The header file format that we use is used for native iPhone app development as well. So others have probably encountered this problem.

Replace 3D model with different 3D model

1345048652 #28

Hey, thanks Frano and DavidBeard.

I exported the 3d model as explained i.e. with the vertices and normals only. But I get the same .h file. Except that I dont get any error on line 294 in obj2openpl file.

Here the output of ndk-build:

Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver

Gdbsetup       : libs/armeabi/gdb.setup

Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver

Gdbsetup       : libs/armeabi-v7a/gdb.setup

Compile++ arm    : ImageTargets <= ImageTargets.cpp

In file included from jni/ImageTargets.cpp:45:0:

jni/./posefour.h:33941:9: error: "vertices" is not a valid filename

jni/./posefour.h:67851:9: error: "vertex" is not a valid filename

jni/./posefour.h:135608:9: error: "faces" is not a valid filename

jni/./posefour.h:169532:9: error: "vertices" is not a valid filename

jni/./posefour.h:203442:9: error: "vertex" is not a valid filename

jni/./posefour.h:271199:9: error: "faces" is not a valid filename

In file included from jni/ImageTargets.cpp:15:0:

/Users/harshvardhan/Documents/Work/app/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/jni.h:592:13: note: the mangling of 'va_list' has changed in GCC 4.4

In file included from jni/ImageTargets.cpp:45:0:

jni/./posefour.h:27:1: error: 'mtllib' was not declared in this scope

jni/./posefour.h:27:8: error: expected '}' before 'posefour'

jni/./posefour.h:27:8: error: expected ',' or ';' before 'posefour'

jni/./posefour.h:135613:1: error: expected declaration before '}' token

make: *** [obj/local/armeabi/objs-debug/ImageTargets/ImageTargets.o] Error 1


I still think that something is wrong with the 3d model only. Heinko mentioned a problem with 3ds max exporting script.

Should I delete the gw_objexp.ini or something else..any clue would be a great help..??

Replace 3D model with different 3D model

1344958857 #27

I'm not sure but it definitely comes from your obj file which come from DOS while the obj2opengl.pl script is intended to be used in unix. More specifically it comes from the line breaking and the presence of the "^M" hidden caracter. So for the perl script, it's like your .obj file is a long single line of text (on my Mac in any case). Try to find a utility that could change the file format or get rid of every "^M" (if you can get your hands on vim -> http://vim.wikia.com/wiki/File_format#Converting_the_current_file). Good luck.

Replace 3D model with different 3D model

1344957416 #26

It appears that the header file is corrupted. I notice that there is a reference to the MTL file, and the format is incorrect. Try Franck's advice, to make sure that you are exporting your model correctly. And uncomment line 294.

Take a look at the banana.h file that comes with the examples version of the script to see what these files should look like.

Replace 3D model with different 3D model

1344956606 #25

From my point of view, I think your .obj file is not compatible with the script, or maybe there is an error somewhere (I can not import it into Blender). I advise you first to look closely at the export panel in MAX and make sure that you export only vertices and normals (forget the export of the material .mtl file, it will not be taken into account in the script). The fact that you changed the script itself may be the cause of your second problem. In fact all the other problems:
1 - posefourNumVerts variable should contain the total number of vertices of your model (therefor it should not be equal to 3).
2 - Description of vertices should be in this format: posefourVerts float [] = {V1X, V1Y, V1Z, V2X, V2Y, V2Z, etc ...} but you end up with a copy/paste of the .obj file where vertices are described in this way:
v x1 y1 z1
v x2 y2 z2
etc ...
3 - your .h file has lines of comments from the max exporter ("#") which trigger errors (for instance line 33941 = # 33908 vertices)

Replace 3D model with different 3D model

1344947819 #24

I have been stuck on the same thing for last 1 and half days, I try compiling Heinko's script obj2opengl with my triangulated 3dmodel, which I exported for mac, but I get this error:

Illegal division by zero at ./obj2opengl.pl line 294.

So I hard coded scalefac = 1 and commented out line 294. Then I tried ndk-build in ImageTarget folder after making changes in ImageTarget.cpp I get following in Terminal:

Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver
Gdbsetup : libs/armeabi-v7a/gdb.setup
Install : libImageTargets.so => libs/armeabi/libImageTargets.so
Install : libQCAR.so => libs/armeabi/libQCAR.so
Compile++ arm : ImageTargets <= ImageTargets.cpp
In file included from jni/ImageTargets.cpp:45:0:
jni/./posefour.h:33941:9: error: "vertices" is not a valid filename
jni/./posefour.h:67851:9: error: "vertex" is not a valid filename
jni/./posefour.h:135608:9: error: "faces" is not a valid filename
jni/./posefour.h:169532:9: error: "vertices" is not a valid filename
jni/./posefour.h:203442:9: error: "vertex" is not a valid filename
jni/./posefour.h:271199:9: error: "faces" is not a valid filename
In file included from jni/ImageTargets.cpp:15:0:
/Users/harshvardhan/Documents/Work/app/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/jni.h:592:13: note: the mangling of 'va_list' has changed in GCC 4.4
In file included from jni/ImageTargets.cpp:45:0:
jni/./posefour.h:27:1: error: 'mtllib' was not declared in this scope
jni/./posefour.h:27:8: error: expected '}' before 'posefour'
jni/./posefour.h:27:8: error: expected ',' or ';' before 'posefour'
jni/./posefour.h:135613:1: error: expected declaration before '}' token
make: *** [obj/local/armeabi-v7a/objs-debug/ImageTargets/ImageTargets.o] Error 1

Here link to my 3dModel Files:
https://www.dropbox.com/sh/mz2ac79wnormm6d/zTHAem-y2W

Can you please suggest me how to get over these errors..?

Thanks

Replace 3D model with different 3D model

1343798096 #23

i've read and still don't know,, can you tell me step by step how to load 3D object from zero until success? help me please, i wanna learn more about it... :)

Replace 3D model with different 3D model

1343759768 #22

Hello,

Have you followed David's instructions below? Do you have a 3D model converted to a .h file?

Thank you,

-Peter

Replace 3D model with different 3D model

1343616932 #21

i build it with Java native, and until now i still dont know how to load my 3D Object to my marker....

Replace 3D model with different 3D model

1343616713 #20

Hi Guys,, !!!

i just want to load my 3D Object  to marker, any body help me how to do this???

Replace 3D model with different 3D model

1343139462 #19

Hm, it's a little more complicated. If you have your texture generated from a teapot without having exported the teapot mesh itself, you'll have to check that your UV unwrap texture matches one of the example (in the assets folder -> TextureTeapot [Blue / Barss / Red]. png). Then it should probably do the job. But once that is done, you will not be so advanced, as did those who managed to run the example of the banana. I guess if you have a project, you will not do that from teapots and bananasUndecided no? So, unless you are using the extension for Unity, you will want to make a set of objects in a 3D external software, render with textures of your choice, bake, export to image file, export the objects of your scene in. obj, convert it to .h (or use a c parser). Currently, this is where I'm stuck (see my post below), I have a problem of coordination (as you say) between the texture coordinates of my object and the texture itself ...

Replace 3D model with different 3D model

1343116110 #18

Hi,

Thanks for the reply.

So do I just replace the teapot.png with the generated png? anyone coordination work?

Replace 3D model with different 3D model

1343112304 #17

Hello lovebean. The things you need to do is called baking, if you use Blender, you can get more infos here : http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Bake. Exporting an obj will only export the mesh. There is also a lot of tutorials on Youtube (baking involves UV unwrap).

Replace 3D model with different 3D model

1343098921 #16

Greeting all,

     I using obj2opengl.pl to convert a obj file to a .h file.

The problem is in the example given(http://heikobehrens.net/2009/08/27/obj2opengl/), there are a .jpg file.

when i convert my .obj file, there doesnt give me the jpg file.

May I know where or how I can get it? 

Replace 3D model with different 3D model

1343040439 #15

werther wrote:

Working solution: http://interaktivnydokument.sk/download/ImageTargets.zip

Hello and thanks for posting an example. Correct me if I'm wrong, but I'm not sure your example is a trully working one. If I can build with no issues, I have a flying banana that does not have a propperly mapped texture.

banana

I tried to rotate the texture but it did not work (and won't be a good solution either). I wasn't sure if the problem came from the model or the vuforia code, so I made a custom susanne monkey from blender with a baked rendering texture. Still in Blender, I re-applied the baked texture itself to susanne to be sure that it matched the vertices with UV mapping (and it did), exported it to .obj (modifiers, edges, normals, UVs, Keep Vertex Order) passed it the obj2opengl.pl script and I was close to get the texture perfectly mapped but some huge problems remain.

Am I the only one to get that weird banana?
Thanks for your answer.

 

EDIT : it seems that the forum does not embed images very well : here is a link to the capture I made : http://penumbra.me/uploads/vuforia_banana.png

Replace 3D model with different 3D model

1342203493 #14

If you've compiled and cleaned the project, and are still seeing this, it's likely the texture assignment.

The textures are added in ImageTargets.java and their order is significant..

@ ln 294

    /** We want to load specific textures from the APK, which we will later
    use for rendering. */
    private void loadTextures()
    {
        mTextures.add(Texture.loadTextureFromApk("TextureTeapotBrass.png",
                                                 getAssets()));
        mTextures.add(Texture.loadTextureFromApk("TextureTeapotBlue.png",
                                                 getAssets()));
        mTextures.add(Texture.loadTextureFromApk("TextureTeapotRed.png",
                getAssets()));       
    }

 

because they are assigned by indes in ImageTargets.cpp

@ ln 347

        // Choose the texture based on the target name:
        int textureIndex;
        if (strcmp(trackable->getName(), "chips") == 0)
        {
            textureIndex = 0;
        }
        else if (strcmp(trackable->getName(), "stones") == 0)
        {
            textureIndex = 1;
        }
        else
        {
            textureIndex = 2;
        }

        const Texture* const thisTexture = textures[textureIndex];

 

It's likely that the banana texture is at the texture index being used by the teapot. You can restore the teapot texture to the Teapot by subtituting the loadTextures method above for the one you're currently using.

Replace 3D model with different 3D model

1342200876 #13

Cheers, Works !!!

Replace 3D model with different 3D model

1342096706 #12

Hi, 

 

as for iyasatuito, the same appened in my case.

 

I could see the teapot with the texture of a banana.... why is that? 

 

I guess we did not properly compile the C code with ndk-build, but I cannot understand what I am doing wrong. Any idea? 

 

thanks