How to override physical marker in vuforia AR Camera in runtime? - unity3d

How can I override the physical marker in unity to just make the physical marker invisible in camera while detecting any object.
Like in this video:
https://m.youtube.com/watch?v=R_F1LvK5gCk
And many other videos.

This maybe isn't the correct answer but, I'll put my ideas here because sadly it doesn't fit in the comment section.
I just watch the video and some of the reels they show as his works.
First, yes, in deed they make the marker a sort of invisible marker, but if you look closely, like a 0.25 speed and pushing space bar very fast to look it in slowmo, you can see a kind of "artifact" in between the girl's fingers that makes me think there's no invisible marker but a texture that are covering the marker. Maybe a cylinder that gets his texture from the video camera input.
Now, how I do that?
There are several ways to get the pixels from the webcamera, even Unity has one function. The trouble is, I dont want all the pixels but a little tiny part of the camera render, specifically the one's around my marker.
In my experience, and in his examples, they are using OpenCV, another unity plugin, so they can track anything, from faces, hands, or markers, so I can't be quite sure they are using Vuforia alone or in combination.
My idea is, with OpenCV you can catch your marker and his contour, then ask for the pixels outside the contour of your marker, those pixels will be the skin tone of the person and latter apply them as a texture over some plane or 3d model that can cover your marker. You can have the pixels at right side and left side of the marker and use a average function betwen them so it could look nice or if you like the adventures you can try to use some kind of digital images processing method to get bether results.
I'm not sure if you can have the pixels arround a marker just using just Vuforia. Honestly I've never try it before.
Well, that's my idea.
If you can get it better I'll like to hear about it.

Related

How do I efficiently render a pixelated line?

I am working in Unity2D and have a character who can shoot in all directions. The game has mobile controls and the player will choose his shooting direction with a joystick on the right side.After testing I found it rather difficult to correctly determin where the shot is going to land at. To convey this to the player I wanted to add a sort of "shooting line of sight" to the player. It is moving around the player according to the joysticks position. (As seen in the picture)
Because I want the line to be pixelated (to match the design theme of the game) I cant use the standard LineRenderer component as it doesn't support such pixelated lines. So I started looking for solutions to this problem and stumbled upon Bresenham's line algorithm. After implementing it into the game I knew which x, y coordinates I had to fill with a pixel. Currently every single white pixel in this line is a GameObject with its own SpriteRenderer and a single white pixel as a sprite. In my test scenario up to 400 pixels where rendered at once. I am already using an object pooling system to minimize the performance drag. Moving this line around drops me from around 1100 Fps down to like 200 Fps in the editor. I know it will be slightly better in the build game but I am sure it will take a toll on older mobile devices when enemys, animations etc. are present in the level.
So my question is: Is there a better or more efficient way to render the sprites? Or (preferably) do you have a better idea on how to render this line at all without creating ~300+ GameObjects. (e.g. Shaders (Zero experience), drawing on a texture)
I am grateful for any ideas that lead me into the right direction.

How I fix my character into center of camera with unity 3d

I need a solution for my problem, please.
I make a character in unity 3d base on AR, the problem is when I build the project in my android phone I can found the character or I should to turn a camera for search where is he.
I need to make this object into the center of my camera how can I do this, please ...
The question isn't the clearest, but I suggest attaching the camera to the gameobject you want to see in the editor.
This link is to a unity tutorial.
https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/following-player-camera
Just re-read your question, AR skimed over that at first ... so you dont want to move the camera rather you want to move the object.
To find the middle of the screen in world space is what you asking for.
Camera.current.ViewportToWorldPoint(new Vector3(0.5f,0.5f, 100));
Use your camera to find a point in the world that is in the middle of your view. You have several options, ViewportToWorldPoint for example as shown above. ViewPort calls 0.5,0.5 the middle of the screen, Z is the distance from the Camera origin point.
You could alternativly cast a ray from your camera center screen and find a point on the ground to put your character at ... would need to know more about your wourld set up to help further.
My old answer is how to move a camera ... I will leave it case its useful to you.
[Edit Old Answer]
The other answer will work and is nice and light but has its limitations as your project advances.
I recomend Cinemachine for camera work, in this case a simple Cinemachine virtual camera setting its 'Look At' and optionaly its 'Follow' is what you want.
https://unity3d.com/learn/tutorials/topics/animation/using-cinemachine-getting-started
Cinemachine tutorail above. in short, Cinemachine works with the concept of 'virtual cameras' these are just light easy to use behvaiours that discribe how to 'frame' a shot e.g. what to look at, how to move, etc.
You real camera will get a Cinemachine 'brain' which simply listens to these virtual cameras and sorts out what to do to the real camera to make it happen. Getting to terms with this system will greatly improve your camera work and masivly simplify it.
Things like simply attaching the camera to the player object and similar work but have big limitations that end up biting you in the backside eventually.
Alternativly you can write a script to transform the camera based on your own custom logic the draw back here is the 'ball of code' problem ... that is at first the logic is simple but as you want more and more specific shots framed up it gets to being a spegettie monster quickly.

how to deform image?

Hi Friends
I Want to make a simple gaming Application in which the user hit the car and car breaks from that point means the image get little deformed when the user hit the car image. I know everything could be possible with using of lots of images and get change when user hit that car image but i don't want to use so many images.
is there any solution for this , how can i deform the image ..sorry for my English but , here i paste a link of the game that is on flash and this is what i exactly want..
http://www.playgecogames.com/file.php?f=657&a=popup
please respond soon
thanks
You don't say if this is in 2D or 3D, or what techniques you're going to use.
If you're implementing the game using OpenGL, it's fairly straightforward. The object can be made up of a regular mesh, with the image as a texture mapped to the mesh. When the user hits the object, you just deform the mesh.
A simple method would be to take a vector in the direction of the hit, displace the nearest vertex by an amount proportional to the force of the strike, and then fan out in to deform the rest of the mesh in decreasing amounts. By deforming the mesh, the image texture will be rendered with all the dents or deformations you like.
If you want to to this without OpenGL and just straight images, you could use image resampling to simulate the effect. You have your original pristine image which is 'filtered' to make up the resulting image. At first there are no deformations so you copy the original image verbatim. Each time the user hits the object, you can add a deformation using a filter or transform within a local region of interest. This function would resample the source image in a distorted manner, causing it to look like the object is damaged.
If you look up some good books on game development, you'll find a great range of approaches to object collisions, deformations and so on.
If you know a bit about image processing technics here is the documentation for accessing the pixels of the image :
Apple Reference
You also have libraries for this such as this one :
simple-iphone-image-processing
But for what you want to do this might not be the easiest way. What I would suggest is that you divide the car into several images depending on what areas can be impacted. Then you just change the image corresponding to the damaged zone each time the car is hit.
I think you should use the cocos2d effects http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide%3aeffects + multiple images. Because there are many parts which drops after the player kick the car. Like when user kick the side mirror you should change the car image with without side mirror car image.
The person that has made that flash game used around 4 images to display the car. If you want the game to be in 2d, the easiest way is to draw the car, cut it into about 4 pieces (: left side + right side (duplicate of the left side) hood and roof).
If you want to "really" deform the car you'll have to use a 3d engine like openGLES.
Id really suggest doing it in 2d :)
I suggest having a look at the cocos2d game engine. You can modify images with effects, which are applied using a virtual grid. Have a look at the effects page in their programming guide.

How to create a level with curved lines with cocos2d + Box2d on the iphone?

I'd like to create a game that has levels such as this: http://img169.imageshack.us/img169/7294/picdq.png
The Player moves "flies" through the level and mustn't collide with the walls. How can I create such levels?
I found that piece of software: http://www.sapusmedia.com/levelsvg/
It's not that cheap, so I wonder whether there is another way to create such a level as shown in the picture above...?
You can do that pretty easy by reading the color value of pixels at specific places of the level. Take for instance that your level background is white and the walls are black. In order to perform collision detection, whether your character had hit the wall, you would do the following:
-take your character's position
-look at the color values of the pixels of your map that overlap with character's bounding box or sphere at that position
-if any of those contain black color you have yourself a collision :)
Now if your level is all colourful, you would want to build a black and white mask texture that would reflect the wall surfaces of your actual map. Then use the coloured map for drawing and the bw map for collision detection.
I'd spend a good solid couple weeks getting caught up on Objective-C, Xcode, Interface Builder, and Apple iOS documentation. There are many good tutorials out there and sample Xcode projects to download and run on the iPhone/iPad simulator.
If just starting out, some of those quick startup libraries can rob you of the intimate knowledge you'll need to create the intricacies and nuances you'll need when your application starts to reach outside the boundaries of the code sandbox. Not bad to use as learning tools or to speed up development time, but I'd advise against using them as a crutch until you strengthen your developer legs. Crawl. Walk. Run!

How do I create a floor for a game?

I'm attempting to build a Lunar Lander style game on the iPhone. I've got Cocos2D and I'm going to use Box2D. I'm wondering what the best way is to build the floor for the game. I need to be able to create both the visual aspect of the floor and the data for the physics engine.
Oh, did I mention I'm terrible at graphics editing?
I haven't used Box2D before (but I have used other 2D physics engines), so I can give you a general answer but not a Box2D-specific answer. You can easily just use a single static (stationary) Box if you want a flat plane as the floor. If you want a more complicated lunar surface (lots of craters, the sea of tranquility, whatever), you can construct it by creating a variety of different physics objects - boxes will almost always do the trick. You just want to make sure that all your boxes are static. If you do that, they won't move at all (which you don't want, of course) and they can overlap without and problems (to simulate a single surface).
Making an image to match your collision data is also easy. Effectively what you need to do is just draw a single image that more or less matches where you placed boxes. Leave any spots that don't have boxes transparent in your image. Then draw it at the bottom of the screen. No problem.
The method I ended up going with (you can see from my other questions) is to dynamically create the floor at runtime and then draw it to the screen.