I'm trying out the java_arcore_hello_ar sample app but replacing the andy.obj with my own model created in Blender. I have exported the blender object using settings from this tutorial
The .obj and .mtl files were placed in the assets folder but when I tap on the screen I get nothing. It doesn't show an error so I'm thinking it does place the object on the screen but is not drawing it for whatever reason.
Any Google searching for results generally bring up tutorials where you have to create a parser for converting the object, but as far as I can see, the ObjectRenderer class in arcore package does this heavy lifting for you.
Has anyone tried this with any success? Do I have to do further work with the .mtl file?
I did get this worked by extending the code to reade OBJ and MTL files.
You can take a look at my code # https://github.com/JohnLXiang/arcore-sandbox .
I'm also new to openGL, my code is not perfect but works at least.
If it does't any error information , I think the reasons are:
1.The Obj model has been placed other position , for example far far place . So you should check if model's position is origin of Blender in modeling process .
2.The Obj model is different one of java_arcore_hello_ar sample , so when java_arcore_hello_ar sample's Obj parse library parsed error.
So, you can parse obj model by yourself.
Related
I have used the repo to make an android plugin for my unity game, wherein I reward the player with some stickers at each level. So basically Im successful in calling the add sticker function from the android plugin and can add the sticker pack according to the desired identifier and name. (Here the contents.json, is already in the aar.)
But since i now need to edit the contents.json (we cant modify .aar files) so i copy the assets file content checkout the content provider code https://pastebin.com/urhXTs7z
And now the contents.json is in my Android/data/packagename/files/
From Unity I deserialize and serialize that json and just add items to the sticker pack list. And then overwrite the contents.json if (Application.platform == RuntimePlatform.Android)
{
System.IO.File.WriteAllText(Application.persistentDataPath + "/contents.json", contents);
}
It works for the original contents.json but after updating the stickerpack, the new items are not read by the ReadContentFile function
But this doesnt work, the plugin just reads the original contents.json. (Because copy assets is called in OnCreate, I tried using sharepreferences of android to call the copyassets function only once. But then my app crashes.)
I found people with similar questions here : https://github.com/WhatsApp/stickers/issues/340
But im not able to figure out what to do.
I dont know even it is possible to handle stickers addition dynamically when the code is inside a plugin.
Please refer to the code in the pastebin link
Would love any suggestions to alternative methods to do this.
I have a fairly basic question that I cannot for the life of me find the answer to online (most definitely due to not really knowing what I am looking for).
Suppose I have multiple (for the most part static) objects that are stored inside one VBO and drawn to the screen. Each object will have images and text/external data associated with it. I need to be able to navigate this "map" of objects and on-tap, access the corresponding information.
My question is, what is the best practice when it comes to storing this corresponding data and linking it to its respective drawing? I figured you create a "parallel" array of custom objects that each references its drawing and holds all the data... Although it seems quite elementary and thought there might be a better way. Considering also that there will potentially be thousands of these objects on the "map".
You can Use model class and put all common data intro one entity than use extends. You can use yours custom object who will consider whole VBO or opengles program data. About identity make ID for each elementary object or "draws".
-I understand your problematic. In opengl/es procedural programming is actually on scene.
Remember you are still in android envelopment you can use any java/android methodology.
-When you say "tap" did you mean click? If you so than see "Raycast" thema.
-This is interest file . It is JS not android but you can use same logic methods to make your object based app.
https://github.com/zlatnaspirala/visualjs/blob/master/project/project_instance_webgl2/lib/matrix-world.js
You can see lines like this :
App.scene[squareObject.name] = squareObject;
I have a global object App.scene . I put here all object buffer data. It is a key access but works like array.
I wanna say your idea about arrays is good. But not in parallel order. Procedural part works with no problem you need draw function for each element entity.
Look at draw methods :
https://github.com/zlatnaspirala/visualjs/blob/master/project/project_instance_webgl2/lib/matrix-draws.js
For example one of my draw entity is App.operation.draws.cube function.
I use this method to draw any cube but each cube is uniq object with uniq data inside.
I originally have a code for generating and training a CNN model, with no added codes for saving or writing graph.
However, the optimized .pb file I generated using this code is not accepted in Android Studio and emulation stops.
What I did are the following:
Using my basic code for generating the CNN model, I added these lines in the training portion:
I edited my input placeholder and my output prediction by adding the "name" attribute,
X = tf.placeholder(tf.float32, shape [None,input_height,input_width,num_channels], name="input")
y_ = tf.nn.softmax(tf.matmul(f, out_weights) + out_biases, name='y_')
because I think these are needed to create the graph. I did not add any other code to my original code other than this
Then after saving the model, after generating the .pbtxt and .ckpt file, you freeze the model and generate the .pb file
I put this block of code outside of
in with session as tf.Session():
after training.
Then you still need to optimize this .pb file
I put this block of code outside of
in with session as tf.Session():
after training.
The final optimized model that will be placed in the assets folder in my Android Studio Project will be optimized_frozen_har.pb
But the emulation stops. I'm using my phone. If I simulated using the original optimized_frozen_har.pb file there aren't any errors. And the file size of the original optimized_frozen_har.pb file is 21kB but the one I generated is just 4kB.
Maybe there is the problem with code for generating the frozen and optimized model. Aside from adding the "name" attribute for the input and the output, should I add other lines of code in my original code? (such as with namescope.., etc
I am loading a 3ds model using Rajawali for android and its displaying correctly.
parser = new Loader3DSMax(this, R.raw.riale_3ds);
But the object has multiple Texture jpgs provided with it. I cant figure out how to use those Textures together in Rajawali. I have seen the object opens correctly in other 3d model viewers on my PC.
material.addTexture(new Texture("dcmap1", R.drawable.dcmap1));
material.addTexture(new Texture("dcmap2", R.drawable.dcmap2));
material.addTexture(new Texture("dcmap3", R.drawable.dcmap3));
I am applying this material on the object, if I apply only one it seems ok but when I do something as above it messes up.
I have some sort of simple mobile shopping section inside my app. I get XML or JSON from server and want to put name/description/price/currency/etc to corresponding views. I really don't want to parse all XML myself and prefer to use some syntax like ["products.product.price" -> R.id.priceTextView] to map xml/json data to Android views.
I googled a little bit but failed to find a good way to do this. Do anybody know some lib or maybe Android class doing that?