AGS 3D

Started by DoorKnobHandle, Sun 15/05/2005 15:21:53

Previous topic - Next topic

DoorKnobHandle

That shading is possible, I implemented it before but then got rid of it again, don't remember why... :) I'll put it in again, I may have to make the game 16-bit then though and then write some basic shading stuff... hmm... this is going to be tricky as well... I'll take a look at it.

Making the controls customizable shouldn't be to hard, I don't know if I'll implement that in this preview thing, but in the little sample game that is going to come with the module, it'll be implemented for sure!


Kweepa

I recommend doing some back face culling (you can see there isn't any by looking at the top of the cubes in the wireframe + solid mode).
You'll need to set up the triangles so that the vertices are always in a particular order (clockwise or anticlockwise) looking at the front side.
The triangle should be drawn if the camera is "in front of" the triangle.

Find the triangle normal by taking the Cross Product of two edges. This defines the direction a point should be to be in front of the triangle.

Then find a line from the triangle to the camera, by subtracting any triangle vertex from the camera position.

The triangle should be drawn if the line to the camera is in the same direction as the triangle normal, or specifically, if the Dot Product of the line and the normal is positive.

Triangle = V1, V2, V3
Camera position = PC
Edge 1 = E1 = V2 - V1
Edge 2 = E2 = V3 - V1
Normal = N = CrossProduct(E1, E2) // may need to switch E1 and E2, depending on whether vertices are clockwise or anticlockwise
Line to Camera = LC = PC - V1
Draw if DotProduct(LC, N) > 0

You can also use these types of calculation to get the lighting of the polygons.

Imagine a light at PL
Line to Light = LL = PL - V1
Brightness of triangle is given by Br = DotProduct(LL, N)
You can use this to calculate an RGB value - if it was R, G, B, it's now Br*R, Br*G, Br*B

Although in this case you'll need to "normalize" the normal by dividing each component by the length of the normal.
The normal length NL = sqrt(Nx*Nx + Ny*Ny + Nz*Nz)
If the normal is Nx, Ny, Nz, then the "normalized" normal is Nx/NL, Ny/NL, Nz/NL

Cheers,
Steve


PS

function DotProduct(float x1, float y1, float z1, float x2, float y2, float z2)
{
   return x1*x2 + y1*y2 + z1*z2;
}

function CrossProductX(float x1, float y1, float z1, float x2, float y2, float z2)
{
   return y1*z2 - y2*z1;
}

function CrossProductY(float x1, float y1, float z1, float x2, float y2, float z2)
{
   return x2*z1 - x1*z2;
}

function CrossProductZ(float x1, float y1, float z1, float x2, float y2, float z2)
{
   return x1*y2 - x2*y1;
}
Still waiting for Purity of the Surf II

DoorKnobHandle

#42
Wow! Thank you VERY much, this is definately going to save some time for me, because I basically had the same in mind, but to do all the research in the internet would've taken a lot of time!

Cool!

EDIT: I just noticed that you'd need floats for these calculations, so I'll first port it to 2.7 and then implement this stuff (hopefully)...

Kweepa

Yeah, floats are pretty much essential unless you want to get into the pain of using fixed point maths. I don't recommend that.

Good luck!
Still waiting for Purity of the Surf II

DoorKnobHandle

Thank you, I'll try my best...  8)

But first I'll tackle "rotation"!

Ubel

Dude, you're sick. But I admire you! := Any chance of uploading the source file? :P

DoorKnobHandle

I'll take that as a compliment... ^^

Like mentioned before, there will be a script module, so everybody can use the functions. I'll also include a sample game with sourcecode and a very documented source code file with manual, to make sure that really everybody understands how it works...

That's all I can do... :)

Ishmael

Awsomeness :D

* Ishmael begins level design
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

stu

really fantastic work.
do you think it will be posible to rotate the "camera", so the player will effectively be turning side-to-side?

also, i think this is so neat, i made a couple of icons you could include with the next release if you feel the need to..
http://www.safewire.net/stu/ags3d

Ishmael

Quote from: stu on Wed 18/05/2005 09:47:52
do you think it will be posible to rotate the "camera", so the player will effectively be turning side-to-side?

I reckon
Quote from: [ ... ] on Tue 17/05/2005 20:51:13
But first I'll tackle "rotation"!
means exactly that...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

DoorKnobHandle

Thank you for this positive response!

Those icons look great, I'll definately use them, since I am no good at art...

Yes, I am currently working on rotation, then the shading that Steve mentioned and then I'll look into the backface-culling... Those tasks are pretty big, so it'll take me some time... After all, this is not my real project, just a side thing to play around with in my free time...

deltamatrix

a fine piece of work.

Although I must stress that full level design will be complicated if it can only be achieved by typing commands. (this is why i abandoned DarkBASIC) But this module will have many many cool uses. Such as a space harrier fan game. I may find it useful if my Ray Bexter II game ever gets going.

Good job!  :D
BAD WOLF - TORCHWOOD - MR SAXON - THE BEES ARE DISAPPEARING - PANDORICA - RIVER SONG

Scorpiorus

Good work! :)

As for rotation, all 3d transformations such as translating, rotating and scaling can effectively be done by using of matrices. I appreciate it probably is not a trivial task to implement them via the AGS scripting language since we can't have structs with user-defined pointers within them but the advantage is that once it's done things like object transformation and camera moving are much more easy to achieve.

GarageGothic

My god, how come I've totally missed this thread for such a long time!?!?  :o I guess I might as well stop wasting time on my own feeble attempts at  AGS vector graphics now.

Looks good though - you've come much farther than I did.

Jay

The images and archive files that you hosted on t-online.de are now broken links.

X-Hunter Blackzero

If I were you i would just quit fooling around with AGS and move into REAL 3d programming with torque.  It's language is based on C like AGS, but it can do everything you did much more easily.  You can get a compatible text editor for it called "Crimson Editor" and be sure to get a book called "3D Game Programming: All in one"  by Kenneth Finney.  It should walk you through it.   anyway, good luck with that.

Rui 'Trovatore' Pires

But the point is precisely to "go where no AGSer has gone before". Sure, people should use other tools to do other stuff, but thinking outside the box is wonderful practice, and proof of their skill and of the engine's versatility. Think about it - there IS a section called "Non-Adventure games" in the AGS games database, and it's quite alive, but it doesn't get 1/100th of the submissions the other categories get.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

DoorKnobHandle

Thanks for your advice, X-Hunter, but Rui did get the point pretty good.

Actually I have been programming in SDL (A graphics library for c++ that is upgradeable with opengl for 3d stuff) for several months before starting the project.

I've been writing games in 3d since several years. First modifing Half-Life, then continuing with Genesis3D, Irrlicht and several other stuff.

I also started writing stuff entirely in DirectX.

strazer

Could you or someone else please upload the latest version of the demo somewhere? As jayssite says, the links are broken.

DoorKnobHandle

My webspace was deleted.
I will upload the files as soon as possible to geocities.

Is that allright?

SMF spam blocked by CleanTalk