Q

Home » Work » Creator’s Journal: Holodeck Management System Progress

Creator’s Journal: Holodeck Management System Progress

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 43 other followers

Dad, if you happen to hear and/or see and/or read and/or absorb what i am writing in any way, I have a great deal of respect of you and your chosen profession…

My father was a CAD designer. Computer Aided Drafting.

Drawing three dimensional objects on two dimensional space.

He started as a draftsman, doing it by hand, then he became good with it – really good in fact – and, like me, opted not to lead teams and stay doing what he did.

In any case. I am working with OpenGL, and I will tell you what, it’s a bitch thinking about the translation of real world coordinate systems into virtual coordinate systems and back.

A real mind fuck in fact.

The weird dreams I have had lately because of this..

Thinking.. in three dimensions.


Today’s been a rough day.

Take a couple steps forward.

And then a few backwards….

Off yesterday’s todo list:

1) Fix the 3D Sphere’s texture wrapping (done)

Turns out this was a problem with the soccer texture. Not so much a problem with the texture itself.

2) Fix the 3D segmented sphere (Done)

TexturedDisk

4) Check Memory allocation for all objects (Done)

This actually worked out pretty sweet. In the past, I had used Boundschecker by Numega which would provide you all kinds of information about memory leaks, and was crucial for corporate and industrial development.

Well AS it turns out. There’s some inbuilt functionality which can actually do the same thing with VERY few additions (and a lot less expense!).

I already had a global header I was using for a few constants like PI and the speed of light (I’m already using PI but not the other);

Constants

Two definitions for PI just to confuse people looking over my code:

And now that header file also has this markup for detecting memory leaks;

DebugCode

It’s real easy to use, when I am done with wrapping up my application and returning to the OS, I call this;

Memleaks
And while the output is cryptic when the program terminates, it either gives me this message:

NoProblemo

Or this one (I intentionally created a leak situation to demonstrate the detection):

MemoryProblem

Now while that output is cryptic, the line number pointed line 308:

mem2

segDiskMemProb

Now let’s see – did I delete the mySegmentedDisk object that I created a new one off?

noDelete

DOH! Clearly an example but this fixes the situation:

mem3

And a test run demonstrates this:

Noprob2

So if you’ve never programmed with C++ – every ‘new’ has to have an associated delete. It really is that simple. Every malloc a deallocation. And so on. So this nifty little feature catches when I forget to place this in my code.

In any case, immediately after placing this code in, I found one glaring leak – where I had ‘new”ed something and reused that same variable to new something else and lost reference to the original thing I new’ed. A sizable memory chunk consumed because of sloppy programming! Now fixed!

5) Implement inheritance use of positional information (Done)

This worked out pretty well too. I won’t show boring code stuff on this one, and since you can’t see rotation working besides the demos I have already done – this led to an optimization and better encapsulation of my objects.

As for positioning. i implemented a pretty cool design at the base class level and in doing this exposed a problem with my borrowed viewport code.

So now I am monkeying with that, getting to know that code was functional with the centered objects I was displaying, but the moment I went to move them off

Matrix view and Projection view problems, in a nutshell..

positioning information actually functional til I get another

6) Create base class rotation information and implement rotation in the inherited classes (Done)

I was able to keep it in the base class, and it all works out pretty sweet. But like I said. it exposed world view problems which I am currently working on.

Of Note;

3D programming and sprite based programming has an annoying tendency to mix and match the usage of the same structure for points, vectors, and rotation because they are all leveraging x,y,z axes and structures.

Initially, this caused me a shitload of confusion, because the concept of a vector is SO much different than a point than rotation angles.

So what I did was created three objects which look almost identical:

rotation

One called GLRotation3D (above), One called GLPosition3D, and the other called GLVector3D.

This distinction which other 3D programs don’t tend to do led to something that worked out pretty nifty, the ability to convert a point to a model and back to a projection matrix form on the fly – particularly useful for mapping screen coordinates that a person clicks on with a mouse to an equivalent x,y position in a 3d coordinate system.

And on to the final two things:.

3) Work on rotation of pyramid

Still to do on this one…

A big ugh on this one once I dove into it.

First and foremost, I have to do some more research to figure out how calling this function:
gluPerspective( 45.0f,(GLfloat)width/(GLfloat)height,0.0f,100.0f);

Maps to the projection view and the differences between that and the model view. Now I ‘get’ what a model is. And I ‘get’ the projection is the camera view into that model.

The problem is – understanding the viewport which correlates the two – and working with the objects…

That is; Do I create a really deep pool and set the large objects far away? Or do I create a really shallow pool, and scale the objects smaller? How does this effect perspective?

I don’t know until I have tried, so that’s what I am working on now.

On another note:

To “TEST out positioning” I captured and translated the mouse coordinates to the matrix view, here:

Mousemove

And then – the hope was – to have an object directly follow my mouse – centering the object on my mouse cursor – as it moved from the center of the screen:

Mousemovecenter

. And as I moved and rotated it – it should have stayed centered, but as you can see here, it didn’t quite work out that way 😦

Mouseposition

This demonstrated the problem I had with viewing angles.

OpenGL leverages a ‘camera’ position of 0,0,0 on the x/y/z axes, and you rotate ‘the world’ around that focal point.

Right now, I couldn’t tell you what my problem is with this.

YES it follows the mouse, but it’s like it’s basing it’s position based on an imaginary line that’s drawn to the back wall based on the x and y position  I translated for it.

How do I translate this back to my literal screen coordinates and move it according to the location of my mouse??

Fuck if I know.

So as I screwed with projection and the model view, that complete broke my background imagery and lighting.

So while I took a couple steps forward today, I took some major steps sideways with new things to learn.

Anyways.. things to ponder for tomorrow.

TODO for tomorrow:

1) Figure out coordinate systems and translating the mouse x,y to the object x, y, z position.
2) Update the object code to add in dynamic scaling based on what I figure out from (1)
3) Figure out the glu thingie from above.
4) Add in my own light sources. Don’t leverage someone else’s code on this, do it myself to fully understand it.
5) Place multiple primitives on the screen that can be dragged and dropped like a folder can in windows. Scaled accordingly.

That’s about it.

Enough for today!

On that note:

This is what a homeless man does for fun!

Enter your email address to follow this blog and receive notifications of new posts by email.