zNear and zFar plane Size

Following math works for perspective projection.

aEwwS

Height of zNear, another words it’s height of near plane:

 float H_near = 2*near*tan(fovy/2);

And the same for zFar, to get height of far plane:

 float H_far = 2*far*tan(fovy/2);

To get width, just multiple on aspect ratio of your screen.

Posted in others
Tagged Math, , perspective, plane, zFar, zNear

Rotate model with GLKit – Quaternions and Matrices math

I was looking for algorithm to apply additional rotation to model with current rotation matrix, and found this:

1
2
3
GLKVector3 up = GLKVector3Make(0.f, 1.f, 0.f);
up = GLKQuaternionRotateVector3( GLKQuaternionInvert(quarternion), up );
GLKQuaternion quarternion = GLKQuaternionMultiply(quarternion, GLKQuaternionMakeWithAngleAndVector3Axis(delta.x * RADIANS_PER_PIXEL, up));

It’s from this small tutorial about rotation:
A bit modified code, source here
Under code a bit more text and links
Continue reading

Configuring and compiling VTK 6.1 on Mac OS X 10.9.2 + simple example of VTK usage

Hello. In this short post I will explain how to build static libraries of VTK.
Main reason why it needs: Because official “How to” has just 2 lines without any explanations. And by default will be builded dynamic libraries. With which I had a problem like link to vtkCocoaGLView was not found, but it actually was in a library.

Let’s start. You will need CMake to build and VTK sources.

- Launch CMake from your Application folder. In main menu go to “Tool” -> “Install for Command Line Use”, in case if you did not install yet.
- Unpack VTK to some directory, working place.
- Enter to VTK directory and create directory with name build

Now you can configure and generate makefile or Xcode project file from console or User interface of CMake application.
If you would like to build with makefile in terminal go to next steps, if not jump to Build with Xcode section.
Continue reading

List of Anti-Aliasing techniques in 3D

I know about next Anti-Aliasing techniques:
MSAA – Multi-Sampled Anti-Aliasing
SSAA – Super-Sampled Anti-Aliasing also called FSAA
FXAA – Fast Approximate Anti-Aliasing, some good resource and this pdf
CSAA – Coverage Sample Anti-Aliasing
SMAA – Subpixel Morphological Anti-Aliasing
MLAA – Morphological Anti-Aliasing (OpenGL implementation)

If you know any other which is not in list, please write below in comment.
I will add them to list and links on page with description.

Distance between vertices and magnitude of a vector

Distance between vertices:

1
2
3
4
5
6
7
8
9
10
11
12
13
static inline GLfloat Vertex3DDistanceBetweenVertices
(Vertex3D vertex1, Vertex3D vertex2)
{
    GLfloat deltaX, deltaY, deltaZ;

    deltaX = vertex2.x - vertex1.x;
    deltaY = vertex2.y - vertex1.y;
    deltaZ = vertex2.z - vertex1.z;

    return sqrtf((deltaX * deltaX) +
        (deltaY * deltaY) +
        (deltaZ * deltaZ));
}

Magnitude of a vector:

1
2
3
4
5
6
static inline GLfloat Vector3DMagnitude(Vector3D vector)
{
    return sqrtf((vector.x * vector.x) +
        (vector.y * vector.y) +
        (vector.z * vector.z));
}

iPhone 3D Samples from “iPhone 3D Programming” book

iPhone 3D Samples from “iPhone 3D Programming Developing Graphical Applications with OpenGL ES” book.
Thanks Frank and Doris Rideout and O’REILLY

31 iPhone 3D Samples OpenGL ES 1.1 and 2.0


All links direct to http://examples.oreilly.com/

All Samples

HelloArrow

Continue reading

Good book!

Do you have a great idea for a graphics-intensive iPhone or iPad application, but don’t know how to bring it to life? This book offers the perfect solution: a crash course on the OpenGL graphics library with an overview of iPhone 3D development. Whether you’re an experienced OpenGL developer looking to build iPhone apps for the first time, or an iPhone developer wanting to learn sophisticated graphics, iPhone 3D Programming addresses both in one concise, easy-to-use guide.

What does it take to build an iPhone app with stunning 3D graphics? This book will show you how to apply OpenGL graphics programming techniques to any device running the iPhone OS — including the iPad and iPod Touch — with no iPhone development or 3D graphics experience required. iPhone 3D Programming provides clear step-by-step instructions, as well as lots of practical advice, for using the iPhone SDK and OpenGL.
Continue reading

iPhone Particles samples OpenGL ES

Screen shot 2009-10-14 at 8.09.27 PM

This is just one possible configuration – one of the simpler ones, actually, as it is only using point rendering and simple gravity – no textures, no wind, no transparency, etc. I call this configuration “fountain”, and it’s can be created in one line of code:

ParticleEmitter3D *fountain = [ParticleEmitter3D fountain];
then, you just need to tell the fountain to draw itself each time through your draw loop or callback…
[fountain drawSelf];
It’s probably going to be a few days before I get the first version of the code posted – it’s got some rough edges still, plus a few more bits of functionality I feel are needed before it can survive public scrutiny.

The above movie was taken on the simulator. The code does work on my first generation iPhone but I have to reduce the number of points emitted per second to get it to look good with no hiccups. I haven’t yet tested it on my second generation iPod Touch to see how much of a difference the new processor and FPU make. I’m also hoping that pooling and reusing the particles, rather than constantly allocating and freeing them will help a fair amount.

This is a particle generator wrote to help learn OpenGL ES 1.1 better. This project is intended for use on the iPhone, though imagine large chunks of it could be ported to other embedded devices that support OpenGL ES 1.1 or higher.

iPhone Particles samples

1 2 Next »