Category: c#

Successfull at building Blender3d

author | 21. Dezember 2007

Phew! At last i was able to build and even modify the blender sources. I need to do that for my current project:

I’m trying to Simulate different BRDF-models for my research using the render engine of blender. It was easy to find the source code locations, where i had to change it, but the hard part was to get the blender source code compiled..

I tried following the guides that are given at blender.org, i downloaded all needed software, libraries and documentations, even tried changing the code on my own, when an error was shown. Mainly i tried compiling the code with cygwin and visual studio and although there are project files specially for visual studio, i couldn’t succeed at building the project.

Then – just before giving up completely – i decided to try to contact the ‘elders’ and describe my problem. The easiest way was to get into the irc-channel. I thought #blendercompilers would be the right place to ask this sort of question, but unfortunately nobody was really active at that channel. Then At #blendercoders someone pointed me to this guide. The guide uses mingw and – to my surprise – it works .. flawlessly!

So, at last i’m getting to the fun part: writing my own shader!

SharpDevelop 2.1

author | 2. April 2007

The latest version of SharpDevelop was released nearly a month ago bringing with it some nice features i’ve been waiting for. My main interest is the support of the Compact Framework.

Anyone trying to develop .net-applications will normally start off by using Microsoft’s free (but stripped down) IDE MS Visual Studio Express. Initially I was astonished to hear that Microsoft released the Express edition even for commercial use (!!) without many strings attached.

Later, once i found out about SharpDevelop I was looking for a method to develop applications for my pda-like xda. Unfortunately Microsoft has reserved Compact Framework support for professional users of Visual Studio. Now with the release of SharpDevelop 2.1 it’s possible to create applications for use in Microsoft’s Windows Mobile platform.

Structures in vb.net and c#

author | 22. März 2007

Ever since i ‘discovered’ how to use structures in vb.net, I’ve been fascinated by the abilities they give to developers. Structures are sort of mini-classes, that can have properties and methods. Take for example the following structure:

[vbnet]
Structure measurement
Dim startdate As DateTime
Dim enddate As DateTime
Dim heattemp As Double
Dim heattime As Double
Dim overalltime As Double
Dim title As String
End Structure
[/vbnet]

It describes a complete measurement-cycle of a heating device. The syntax for using structures is as simple as it gets:

[vbnet]
Dim meas As new measurement
meas.title = “hallo”
[/vbnet]

Next, it’ll need some measurement points. I’ll just create a new structure

[vbnet]
Structure measpoint
Dim time as DateTime
Dim tempt1 As Double
Dim tempt2 As Double
Dim tempb1 As Double
Dim tempb2 As Double
Dim volt As Double
Dim currt As Double
End Structure
[/vbnet]

This structure describes exactly one measurement point. In it we find the current time stamp, four temperature values, a current and a voltage value. Every measurements has an undefined number of measurement-points. To include them into the main measurement-structure, we use an array:

[vbnet]
Structure measurement
Dim startdate As DateTime
Dim enddate As DateTime
Dim heattemp As Double
Dim heattime As Double
Dim overalltime As Double
Dim title As String
Dim mpoints() As measpoint
End Structure
[/vbnet]

Next, we’ll need some evaluation of measurement-values. To do that, we’ll include a method into the measurement-structure:

[vbnet]
Structure measurement
Dim startdate As DateTime
Dim enddate As DateTime
Dim heattemp As Double
Dim heattime As Double
Dim overalltime As Double
Dim title As String
Dim mpoints() As measpoint
Public Function lowestvolt() as double
Dim lv As Double
Dim i As Integer
lv=mpoints(0).volt
For i = 1 To mpoints.Length – 1
If lv>mpoints(i).volt Then
lv=mpoints(i).volt
End If
Next
lowestvolt=lv
End Function
End Structure
[/vbnet]

The method ‘lowestvolt’ iterates through mpoints and finds the lowest voltage. That’s it!

Using the free IDE sharpdevelop we can now translate the code into c#:

[csharp]
public struct measpoint
{
public DateTime time;
public double tempt1;
public double tempt2;
public double tempb1;
public double tempb2;
public double volt;
public double currt;
}
public struct measurement
{
public DateTime startdate;
public DateTime enddate;
public double heattemp;
public double heattime;
public double overalltime;
public measpoint[] mpoints;
public double lowestvolt()
{
double lv;
int i;
lv = mpoints(0).volt;
for (i = 1; i <= mpoints.Length - 1; i++) {
if (lv > mpoints(i).volt)
{
lv = mpoints(i).volt;
}
}
return lv;
}
}
[/csharp]

So, why still use classes, when there is something as nice as structures? Well, structures can have properties, methods and even constructors but the main difference to classes is that structures are sterile, they can’t inherit from other structures. Also, there are no private properties/methods in structures as there are in classes. Other than that, there is no major difference other that that structures are much easier to use.. Since I don’t really use inheritance much, structures are my first choice for organizing data.