My first C4D plugin.

Gord.T

Still "Senior Member"
I created a plugin which takes the camera tracking targets imported from a program like boujou, voodoo, ect, and creates a polygon whose points match the tracking targets.

Then you can draw a mesh from those points.

I'm still waiting for some more feedback but you can pick it up (post #14) and view the original thread at ...

http://www.c4dcafe.com/ipb/index.php?showtopic=28542
 
I didn't know you knew C++, impressive!

How did you get the null point data out of C4D?, did you poke into the memory or something?
 
Hey Anhar. Merry Christmas.

I used the c.o.f.f.e.e scripting language to make the plugin. It's compatable on all platforms for C4D. There is also a c++ SDK but it is platform dependent, but is ofcourse more powerfull.

The coffee language is object oriented based and simple as most scripts are, so I just had to get a pointer to the parent object and iterate down through the children, using GetPosition() for each null child.

The actual script code is now here...

http://www.c4dcafe.com/ipb/index.php?showtopic=28576

...so you can see it's pretty basic.

The temporary utility I did at first was c++ using Visual Studio 2005.
I'm an intermediate programmer but this new CLR stuff is not what I'm used to. I prefer conventional c++ but I also like CLRs ability to handle the GUI better, but it's all good.

Oh, the c++ SDK does allow you to hook into the program flow too.
Ummm, I guess which method (coffee or c++ SDK) to use depends on the complexity of the job at hand.

//Oh, haha, while coffee is very similar to c++, I'm not yet sure how similiar so when you see stuff like count = count + 1; instead on count++; that's why.
 
Last edited:
right I gotcha, same as maxes MaxScript and Mayas MEL scripting thing.

Thanks for posting the code, I'll be having a looke, I'm also an modest programmer, so codes always interest me.

The whole .net (ala CLR runtimes/framwork) is MS way of doing what Java and VM already has done (Thats MS for you, taking great ideas from others)

Lately I've been looking very deeply at machine language (nope bot Assembly language, the direct

bla bla..
 
Man , assembly, ya know I got the whole binary thing and all the CPU books but Microsoft always has to do thier own thing. Throw a spin on everything.
 
Sorry for the half post, I was typing and then I got an important call, I had to deal with that, so I just typed "bla bla" :)

Anyways yea, I was just sayin back in the Cambridge days, we had to code in machine language (yep use the direct opcodes and poke them into a simulator!).

I was looking up machine code and then decided that unless I wanna make 3d on C64 (which has been done, mind blowing stuff! see youtube type "C64 Demo 3d")

Its probably easier to do good old assembly for small one time CLI console apps.

Take a look at Kernal programming (OS developement), man its some deep sh*t
 
I was into machine back, oh 25 years ago, GOD. I wrote a program for those led sequential signs you would see in bars. Took me about 70 pages (double sided, hand written).I think and not very editable by todays standards. Still, it was byte by byte coding. Nowadys I dont have time for that, it's more for hardware developers and my interests now are in the creative end. But I still have a heart for the old stuff.

Even the classic c++, because of MS, is getting pushed out of the way. I hear, and this is what bugs me, is to make it 'more accessable' which means dummied down and stupid. AND slower by it's very nature.

I rememer sitting in a office several years ago, long story, but some stupid beeatch was sitting there. The boss wanted something done in HTML. I didn't know it. The other guy did. I knew c++. She said..."He only knows c++". Referring to me. I almost puked my brains out.

Anyways, it's CE and I'm wobbly and red eyed.
-Cheers.
 
Damn man C++ still rules (Its the one language I want to master, I can read it and understand it but not strong enough to code without references), I still love FORTRAN man I picked that up in two weeks!

I think your right, modern languages are trying to make things simpler but that sometimes backfires, my only gripe would be Java, thats the one language that has been forced upon us (at Uni, I'm doing a computer science MSc) and I have to say I tried, boy I tried to use it, but making everything OOP maybe is not the best idea, C++ is better in that regard, you can flip between Procedural and OOP when needed and not be boxed in one way of thinking.

Now I'm not gonna bash Java, I respect it too much, in fact all my fellow students and friends code in it happly, I can see its merits (and it does have very good points), but its just my personal taste, and Java "aint my cup of Coffee!" :)

Have a merry Xmas Rap!
 
You have a good one too Anhar.

I looked and looked for my old Z80 code but things get moved around over the years and I can't find it. But if I come across it someday I'll post a page out it.

I did dig up some old Radio Electronics magazines that I used to buy when I was a kid. So here's a little trip down memory lane.

This issue talks about computer graphics so I'd thought you might like to read the actual article.
Note the date on the cover. I was 14 then. Yep.
I used to write my name, address & phone# on the inside cover in case I lost it, it could be returned to me. The phone number isn't valid anymore.

RE4.jpg

RE1.jpg

RE2.jpg

RE3.jpg
 
Damn man! thats proper nostalgia! I think I can even see coffee/tea cup marks :)

Thanks for posting, I'm gonna read that later.

Raptor was you into electronics too?

lets see, if I said "555 and 741s" you know what I'm talking about right?

because if you do, then you and me would be really really rare, how many people would be into 3d, Programming, Electronics AND Filmmaking ! what a rare combination ! :)
 
Haha, yep, timer and single opamp, both 8pin dips but now available as surface mounts and cans. I still remember the pinouts for the 741 but the 555 I'd have to look up again.

I had extensive training as a electronics technician back when I was 24.
I still love electronics but not as much as when I was younger.

//Oh, and in 2000 I did a year of Computer Engineering. It was 97% rehashed stuff I had already done and couldn't stand to sit through anymore of it so I dropped out mid second year.

The math I really enjoyed though. (I'm not a mathmetician, that's for sure, haha)

//I don't have a camera handy but the scanner works...I can be a geek sometimes...some stuff from my parts box.

parts.jpg
 
Last edited:
Lovin the comp stash, hehe, mine was never that organised (I lost all of it when we moved house), and I always wanted to print my own PCBs, never got to do that :(

This gets weirder I'm also a qualified electronics technician (City and Guilds) lol!

Man, the maths and me its a "love/hate" relationship, I love maths, but hate it because sometimes I just can't understand it (visualize it).

Its seems the more I try and runaway from programming and maths, they just keep catching me in the end (like that cartoon, with that dog who was really slow, but always ahead of the bad guys)

Man I think qualifications is a weird thing, on the one hand, the theory is good, but on the other hand as I've found in the "real world" it does'nt hold as much weight as experience.

Thats why I'm trying to get both :) , I'm pretty much self taught, from electronics to programming to 3d and now VFX.

yea, memories man memories...
 
I agree about the math. It's nice to have some in your back pocket because like you say it always comes up in programming. There's when you appreciate having learned some areas of it.

Your a tech man. I didn't know that.

I think all of this stuff is related like electronics->micrprocessors->programming->games & 3D->animation->video. So it seems like one area leads into the other.
 
Last edited:
I hope people don't mind us chatting in here. It is the holidays and I for one am taking a little break.

Here's something again that you might appreciate Anhar, showing how the math thing always pops up.

This code detemines which side a points lies on a 2D line. It was used in the Doom2 game engine and originally written by John Carmack. I may have changed a couple lines since then.
But it derives from the formula Ax + By + C = 0 which is the equation of a 2D plane. You may also remember y = mx + b. From that, or both, you can rearrange and by optimizing the code you end up with the following. I've done it.
(The text gets a little parsed on post but I added some spaces.)

I also have my version of Doom2 that I coded in c++ that is complete except the AI for the monsters are not in. Toooo much work, but that's how I got started programming, to duplicate Doom2, like all good programmers did back in the day, haha.

People laugh at Doom2 now but they can have a look at my code, I'll give to anyone the whole project, and I think one can appreciate what the old school coders accompished. Especially John Carmack.

//Oh, and just for the record, I threw out my old working parts box too. The one with the used parts ripped out of everything I'd get my hands on. I just kept the stock parts. I'm not that organized, believe me. ha.

///One more. In case someones wondering, I am not related to or know Dave Taylor. I've been asked that before. No.

////ha. Speaking of John Carmack, he never sleeps, ever...
http://www.armadilloaerospace.com/n.x/johnc/Recent%20Updates

//---------------------------------------------------------------------------
//
// PointOnLineSide
// Returns 0 or 1
// coplanar is on backside.
int PointOnLineSide (long x, long y,long x1,long y1,long x2,long y2)
{
long dx,dy;
dx = x2-x1;
dy = y2-y1;

if (!dx)
{
if (x <= x1)return dy > 0;
return dy < 0;
}
else if (!dy)
{
if (y <= y1)return dx < 0;
return dx > 0;
}
else
{

int left = dy * (x - x1);
int right = dx * (y - y1);

if (right < left) return 0; // front side
return 1; // back side
}
}//
 
Last edited:
hey Raptor, I enjoyed reading that code! :)

I just had to figure out from 1st principles, so basically I grabbed a blank paper and did some basic maths and my solution is thus:

(1) Calculate Gradient of the Orginal Line,I call this M(o)

which is:

y = mx + c [let c = 0]

y = mx:
rearrange thus:

m = delta Y / delta X

Thus M(o) = (y2-y2) / (x2-x1)

The gradient of the Point can be found RELATIVE to the Orginal Line if we take co-ordinates (x1,y2) as the starting point and P(x,y) as the ending point thus:

M(p)= (y-y1) / (x-x1)

And the you simply check M(o) against M(p) you get three case:

M(o) = M(p) [Point lies on the orginal line]

M(o) > M(p) [Point lies Below line]

M(o) < M(p) [Point lies Above line]

Heres my handwritten work:

PointonLine.jpg
 
Last edited:
People laugh at Doom2 now but they can have a look at my code, I'll give to anyone the whole project, and I think one can appreciate what the old school coders accompished. Especially John Carmack.

what can I say but we are standing on the shoulders of giants!
 
Whoohoo. Anhar. I'm proud of you. Do you know how many people would find that interesting enough to pull out a pencil and try it? Except for maybe a couple college professors, noone I know personally, haha. Very cool.

I did it again too. With a real blunt lead pencil.

I also like to practice the 3D rendering code using vectors. I always try to keep my memory sharp enough (I said try) to be able to write an entire software rendering routine by hand at will. I don't know, it's kind of a personal challenge. I'm due to refresh again because I keep forgetting a few details. Maybe I'll post that too, or, I'm starting to feel like I'm overkilling this thread a bit but...

Wow, way to go Anhar.
A few more points on the old respectometer.

//Yeah, John Carmack is the closest thing I find to a modern day genius. It's all in a day's work for him.
But it seems like every thing he sais is important and leading edge.

//Oh, always an oh, I solved C to be a constant, which in your case 0 is a constant.
You may have taken a differrent approach than me, so I'll have to check your work.lol.
Actually, different approaches are always instructional.
Cool.
 
Last edited:
For noone in particular, the first 2 parts are 'easyouts' to optimize the code for speed.


THe doom2 engine defines vectors clockwise. If a line is vertical and the vector points up and a points is on the right side it is frontal. If the vector points down, that is -dy, it on the back.

Below quote states that the line is vertical so which side of the line the points lies depends on the direction of the vector.

As described here.

if (!dx)
{
if (x <= x1)return dy > 0;
return dy < 0;

The same method for the horizontal.

The actual math part is...
int left = dy * (x - x1);
int right = dx * (y - y1);

if (right < left) return 0; // front side
return 1; // back side

Geez, I've had a couple beer but I'll try and prove that mathematically right now, in 'typed' fashion haha. In otherwords, prove- if (right < left) return front;

Anyone else, jump in...

There's an old saying, you can always tell how much a person really knows by getting them drunk. How true.
I'll see if I can avoid embarrasing myself. Back momentarily.
 
Well...
dy = (y-b)dx;
dx = dy/(y-b);

hit the wrong button, hold on...

Actually, haha, Anhar does yours take into account the vector direction?

I just buggered myself up. I have proven it before, honest, lol, maybe I'm gettin old.

//Yeah, that's proof enough for me personally. It states that if dx < dy the it's on the front side. So it is more clockwise than counter clockwise.
 
Last edited:
Back
Top