Ogre3D Camera, RenderWindow and Viewport understanding - camera

While looking through the tutorials I've seen the Ogre::Camera::getCameraToViewportRay method being used. I was trying understand what it does.
First I imagine a viewport, being placed somewhere in the 3D scene, let's say on the screen of the TV object. I can easily imagine how to transform the 2D coordinate on the viewport to the 3D coordinate of the scene and then to make a ray from the camera position point through that point on the VP.
But I can not understand how it's done when the VP is on the the RenderWindow(on my monitor). I mean, where is the render window in the scene, where is the point on the renderwindow's VP in the scene? How is the point on the renderwindow's VP transformed into a 3D point of the scene?
Thanks for answer!

The viewport shows what you see through a camera, but the viewport is in front of the camera.
There is a stackoverflow post with information about the relation of camera and viewport and a nice visual illustration: https://stackoverflow.com/a/7125486/2168872
The camera to viewport ray is a worldspace ray, starting from your camera and intersecting the viewport at a certain point, e.g. where your mouse cursor points to.

Related

How to make 3d text to appear on camera view in blender

I am creating a 3d text on blender2.8 but I am having a hard time trying to make it appear on the camera view.
I have tried rotating and scaling the camera but it doesn't help.
The camera object is the focal point for the final image, like in real life, if you want to get more in the picture you need to move the camera back or zoom out.
With the camera close -
With the camera far away -
To zoom out, you reduce the camera's focal length.

Rotate camera but render sprites so that they appear in their original world positions

TLDR: I want to rotate camera but render sprites in regards to their world position not camera position.
Howdy,
I'm currently using LibGDX and have come across an issue in regards to camera/object rotation.
Say I have my camera with a rotation of 0 and I have an object(sprite) to the left of the camera's center.
i.e.
Camera Normal (0 degrees rotation)
The sprite renders fine when given a standard world coordinate, however once I rotate my camera, that world coordinate differs from the camera's new (x, y) values.
If I then rotate my camera smoothly 90 degrees to the right(clockwise so that the up direction is facing to the right like the picture below), the object(sprite) that used to be on the left should have simulated a left rotation in regards to the camera (the rotation happens via the camera, the sprite just needs to update position) and now be below the camera's center point.
i.e.
Camera Rotated (90 degrees clockwise)
I'm confused as to how I would calculate the sprite's new locations/positions during the smooth rotation.
Cheers,
Solist.
After looking everywhere for a solution to this problem for 3 weeks it was merely a matter of me needing to call the method
batch.setProjectionMatrix(camera.combined);
in order to update the sprites to their new position in regards to the changing camera rotation.
This link here explains how the Projection Matrix works.

Blender border render internals

I would like to know how Blender's border render works internally. How can Blender compute lights if it has not information about the lights in the tiles he won't render? I have not found any reference (source code excluded) on how this feature of blender works. Can somebody explain it (or give me some reference)?
The render border setting only alters what part of the image is rendered, it does not alter what data is sent to the render engine to generate the image.
You can test this by placing an object with a reflective surface in front of the camera and another object behind the camera, the object behind the camera will show in the reflection. The border setting doesn't change the reflection in the object, it only changes what part of the image is rendered.
Rendering an image starts at the pixel that will be visible in the final image and sends a "ray" into the scene to determine what colour the specific pixel will be. Each ray will bounce around in the scene from object to object to light source based on render settings to calculate the final result. While the render border will reduce the pixels used as the starting point for each ray, it does not reduce the objects or lights in the scene that each ray may come into contact with. Each ray going through the scene will see every visible object and light in the scene that can influence the final result for each pixel.
This conference video explains ray types and might give you a better grasp of how a ray goes through a scene to get the final image.

How to clip part of a sprite based on its position?

I'm designing a game in Cocos2d, and at one point I have coins shooting out on a platform from a zelda-ish perspective. I'd like to display the coin's shadow sprite (a different sprite from the coin) on the platform, but mask or clip the shadow sprite on the edge of the platform. The coin can continue off the edge of the platform, but the shadow should stop at the edge. The platform also moves, so I need the shadow sprite to track with the platform's movement.
I thought it could work to use a CCClippingNode for this, but I can't add it as a child of anything in a spriteBatchNode which is how I'm making my platform. Without having the shadow as a child of the platform, I'll mess up z-order and the shadow movement won't track correctly. I also checked out Ray Wenderlich's tutorial on masking a sprite but I don't think that'll work since it looks like it masks an individual sprite texture and not an area of the view where the sprite shouldn't be displayed. Any ideas on how to solve this?

How to recognize the touch of a non regular sprite image?

I have a sprite and if it is touched the touch should be recognized. I used the coordinates to do so. I took the coordinates (min x, min y, max x , max y)of the sprite image. But The sprite image is not a rectangular shape. So, even if I touch the coordinates outside the sprite and inside the rectangular bounds the sprite is recognized.
But for my application I need only the sprite to be recognized. So, I have to take only the coordinates of the sprite, but it is not regular shape. I am using CCSprite in my program.
So, what can I do to for only the sprite to be selected ? Which classes should use for this?
Thank You.
You could try one of the following...
Create a bounding box smaller than the absolute extents of the sprite image. Yes it will be smaller than the sprite. This will eliminate the dead space click detection of the sprite the trade off being parts of your sprite which look selectable won't be
Use a circular bounding area to detect if the user has clicked on your sprite. Again you will have the dead space problem in my first suggestion but the sphere may give you some better coverage area over the sprite giving you better results on touch detection
This is a standard problem in physics collision detection systems which often end up using circles or rectangles as their collision bodies. I would go with the either a circle or rectangle smaller than the size of your sprite as your bounding area. Going finer detail than that you could generate bounding area polygons. This would however introduce a whole bunch of new issues and concerns.
I am building a Cocos2D game right now and what I am doing is first I step through my sprites and see which sprites the touch hit (they overlap in my app)
Then, for each sprite hit I use [sprite convertTouchToNodeSpace] to get an X,Y co-ordinate inside the sprite, which I can use (although the Y axis is flipped) to reference the CGImage I created the sprite with.
If the pixel at the touch point is 'clear' ie alpha 0, then the sprite was not really touched, and I check the next sprite in the z-order to see if it has color where it was touched.
Sometimes I think I should be using a two color mask image to go along with each sprite, not the sprite image. But, I am mr. make it work, then make it fast.
I realise this is not super efficient, but I do not have very many sprites and I do this only for touches.