jump to navigation

XB Awesome at FSOSS 2011 October 28, 2011

Posted by Andor Saga in Open Source, webgl, Arius3D, XB PointStream, FSOSS, point cloud.
1 comment so far

Tomorrow I’ll be giving a talk at FSOSS 2011 titled “XB PointStream: Rendering Point Clouds with WebGL”. Okay, the name is a bit dry, but I’ve packed a lot of awesome into this talk. If you liked my recent post on turbulent point clouds, you should definitely come to my talk! (:

I’ll be in room S2169 at 2:00, hope to see you there!

Advertisements

Fixing Ro.me’s Turbulent Point Cloud October 24, 2011

Posted by Andor Saga in Open Source, webgl, XB PointStream, point cloud.
6 comments

Run me
Turbulent Point Cloud

A few days ago I noticed the turbulent point cloud demo for ro.me was no longer working in Firefox. Firefox now complains that the array being declared is too large. If you look at the source, you’ll see the entire point cloud is being stuffed into an array, all 6 megabytes of it. Since it no longer works in Firefox, I thought it would be neat to port the demo to XB PointStream to get it working again.

Stealing Some Data…

I looked the source code and copied the array declaration into a empty text file.

var array = [1217,-218,40,1218,-218,37,....];

So I had the data, which was great, but I needed it to be in a format XB PointStream could read. I had to format the vertices to look something like this:

1217	-218	40
1218	-218	37
...

Conversions

Using JavaScript to do the conversion only made sense, but I first had to split up the file which contained my array declaration so Firefox could actually load it. After some manual work, I had 6 files—each with its own smaller literal array.

I then wrote a JavaScript script which loaded each array and dumped the formatted text into a web page. I ran my script and copied the output several times until I had the entire file reconstructed as an .ASC file.

Adding Turbulence

Once I had the point cloud loaded in XB PointStream, I needed to add some turbulence. I could have used the shader which the original demo used, but I found a demo by Paul Lewis which I liked a bit better. The demo isn’t quite as nice as the original, but given more time I could incorporate the original shader as well to make it just as good.

XB PointStream 0.8 Released October 23, 2011

Posted by Andor Saga in webgl, XB PointStream, point cloud.
1 comment so far
Free Cam Visible Human Projection

I lost a bit of momentum for this project while fixing some Processing.js tickets, so I’m releasing the tickets I completed for 0.8 now to keep things moving.

Download

You can download the library on this page which contains links to the minified and full versions.

Change Log

Some of the changes include:

  • Added functions to change projection (perspective and orthographic)
  • Created an ‘Export LOD’ script for Python
  • Added visible human demo
  • Created fake parser for testing
  • Added support to delete point clouds
  • Fixed ASC Exporter to work with Blender 2.59
  • And more fixes…

Objective-C Strings October 9, 2011

Posted by Andor Saga in Objective-C, Open Source.
add a comment

This is my second blog related to learning Objective-C! I’m going to briefly look into creating and using simple strings.

Since Objective-C is C with object extensions, you can still make use of C-style strings.

// This is still valid Objective-C string.
const char* cStr = "Hello!";

The language also introduces two classes which make using strings easier: NSString and NSMutableString. NSMutableString inherits from NSString which means we can use the mutable version anywhere where we can use an NSString.

As their names suggest NSString’s individual characters cannot change once they have been set, but we can easily mutate an NSMutableString. The primary reason for this split is efficiency v.s. flexibility. The compiler can efficiently store a string if it knows it will never change. Let’s take a look at declaring an NSString:

// Create a reference and point it to a statically allocated string.
NSString* nsStr1 = @"This is an Objective-C string";

When declaring string literals like this, the compiler will create a static const NSString. The string will be stored within the binary file itself. If you open up the object file you can even find it there.

Just like in C, strings are interned. If you create two static const strings, the compiler will be smart enough to make them point to the same address.

NSString* constStr1 = @"testing...";
NSString* constStr2 = @"testing...";

// compare pointers, not contents.
if(constStr1 == constStr2){
  NSLog(@"They are the same!");
}

If we wanted to compare their actual contents we can do:

if([constStr1 isEqualToString: constStr2]){
  NSLog(@"They are the same");
}

NSMutableString

An NSMutableString can be less efficient than an NSString, especially if we’re copying them a lot. But they do give us flexibility. A common way to instantiate an NSMutableString is:

NSMutableString* nsmString = 
  [NSMutableString stringWithFormat:@"This is a mutable string"];
NSLog(@"%@", nsmString);

We can later change the contents of the instance by sending messages to the receiver:

// Change the string entirely.
[nsmString setString: @"Changed mutable string"];
NSLog(@"%@", nsmString);

// Or append some more text.
[nsmString appendString: @"!!\n"];
NSLog(@"%@", nsmString);

That’s it for now! In my next blog I’ll start looking into classes and objects.

Introduction to Objective-C October 1, 2011

Posted by Andor Saga in Objective-C, Open Source.
add a comment

I began a course for Apple application development which requires me to learn Objective-C. I decided a good way to learn the language would be to write short blogs on the subject. So to begin, some notes about Objective-C…

Comments

Objective-C allows use of C as well as C++ comments // and /**/

Based on C

The language is based on C, so we have access to types such as int, float, char, etc.

New Keywords

Many new keywords have been added. Some of which are used to directly support object oriented programming. These new keywords are prefixed with ‘@’ to avoid naming conflicts: @class, @interface, @end, @implementation, @protocol are some examples.

Header Based

The language is header based. We have a (.h) header file and (.m) implementation file.
The .h file contains our ‘C++ class declaration’ which we call the interface. It is in this file which we have the interface, properties and methods.
The .m (which stands for module) contains the implementation for the interface. We write the definitions for the methods and synthesize our properties.

Strings

We can use C-style ASCII “strings” as well as Objective-C @”strings” which can support ASCII and Unicode.

Preprocessor

Objective-C has a preprocessor. Instead of using #include we use #import. The import directive does not need to be used in conjunction with include guards.

toString

In Java every object inherits from the Object class which has a toString method. In Objective-C, objects which inherit from NSObject can be sent a description message for equivalent behaviour.

Declarad Properties

Like C#, Objective-C has direct support for properties. Unlike
C#, we can make Objective-C generate accessor functions.

Memory Management

In C++ we use new to dynamically allocate memory for an object. We can then create many pointers to the same object. When the object is no longer needed, we use delete to free the memory. At that point, no pointer which pointed to that object should be dereferenced.

Objective-C uses a reference counting system. We use keywords retain and release to increase and decrease references to an object once it has been initialized. When an object’s reference counter reaches 0, it is freed by the runtime and a reference pointing to that part of memory should not be sent a message.

Inheritance

Like Java, Objective-C only supports single inheritance. And like Java, it supports interfaces, which we call protocols. Furthermore, unlike C++, we can only publicly inherit from another class.