Page 1 of 5

3D Objects in Game Editor

PostPosted: Thu Jan 12, 2012 9:26 pm
by tintran
this GE file reads a wireframe from an .obj file (obj file was created in blender).
it just reads the vector and faces definition and ignores all other lines.
but i think the function displaywire() which tries to project 3D into 2D can be improved (right now it's just hacked i just tried different values and see what looks acceptable, but when i do a regular cube it looks wrong, anyone who knows can improve on it).
to read a different model just change the file name inside wirefromfile() function to a different name
(ie. "monkey.obj" - a monkey head default object in blender,
"ico.obj" - icosphere,
"frame.obj" - a cube
or your own .obj model)
also rotate z-axis portion of rotatewire() function is buggy, when i try doing it it just flattens the model and i am not sure why :(
If anyone can help fix displaywire() function or figure out why the model flattens when z-axis rotation portion of rotatewire(), that would be awesome.

Re: Screensaver

PostPosted: Thu Jan 12, 2012 10:42 pm
by tintran
z-axis rotation bug solved.
improvement on 2D projection based on http://en.wikipedia.org/wiki/File:Perspective_Transform_Diagram.png

Re: Screensaver

PostPosted: Fri Jan 13, 2012 1:21 am
by happyjustbecause
Hey, I've tried all of these screensavers, and I must say, they are extremely cool. I don't really understand the code, and how you did them, but I like them a lot. It shows that gE can create a variety of things when people play around with it!
:D

Re: Screensaver

PostPosted: Fri Jan 13, 2012 3:52 pm
by Hblade
I'm very impressed! Amazing! and yay for blender monkey =)

Re: Screensaver

PostPosted: Fri Jan 13, 2012 8:13 pm
by Jagmaster
:lol: Suzanne.

Re: Screensaver

PostPosted: Fri Jan 13, 2012 9:28 pm
by SuperSonic
@tintran: Wow dude, that's awsome :D

Hblade wrote: yay for blender monkey =)

Jagmaster wrote::lol: Suzanne.

:lol:

Re: Screensaver

PostPosted: Sat Jan 14, 2012 1:16 am
by tintran
found a teddy bear .obj on the internet.
some models have much larger z values so i added the ability to set SCALE (left mouse button and SCALE will set to xmouse value)
and the ability to set BZ (right mouse button and BZ will set to xmouse value) (BZ seems to change the focal length I think).
two values will be displayed for debugging purposes.
so i guess now we sort of have a wireframe viewer as a screen saver.

Re: Screensaver

PostPosted: Sat Jan 14, 2012 3:14 am
by Hblade
You have truely impressed me with this 3D Wireframe drawing using 3D Files. Incredible indeed. Now add physics and a character model animated but in wireframe >:3

Lol jk thats too insane xD

Re: Screensaver

PostPosted: Sun Jan 15, 2012 2:29 am
by tintran
improved displaywire(). lines further away from view gets drawn first and in green.

Re: Screensaver

PostPosted: Sun Jan 15, 2012 6:26 am
by Jagmaster
+++++
A lot of time put into these Screensavers I'll bet.
Thanks for your contribution to GE :D

Re: Screensaver

PostPosted: Sun Jan 15, 2012 1:12 pm
by makslane
Awesome!

Re: Screensaver

PostPosted: Sun Jan 15, 2012 10:08 pm
by tintran
speed enhancement. (only look at defined vectors instead of blindly looping to 10000 all the time, rotation looks much smoother with this change)
speedy.zip
(293.57 KiB) Downloaded 403 times
monkey.png

also if you click Game Mode then hit Esc and repeat that 18 times or so you'll get the following error:
canvas -> Draw Actor, in displaywire function, line 119: Attempt to access 12529024 bytes.
If is correct, set variable gedMaxGameMem=138794450 or more
in an action before the allocation
canvas -> Draw Actor, in displaywire function, line 63: WRITE attempted beyond access area

then you have to close down GE, reopen it and do it another 18 times or so and the error appears again.
this looks like a memory leak problem, i haven't used malloc or free in my code, they're all just predefined arrays, so i don't really know how to fix this problem. :( please let me know if you find out why this memory leak is occuring!

edit: moved some arrays definition from displaywire() to global and solved the memory leak, weird I thought that functions automatically handled memory freeing of arrays that are defined within it.
nomorememleak.zip
(311.38 KiB) Downloaded 390 times

Re: Screensaver

PostPosted: Sun Jan 15, 2012 10:54 pm
by lcl
That's very impressive tintran! :D
+1 and a loooot respect!

Re: Screensaver

PostPosted: Sun Jan 15, 2012 11:27 pm
by Hblade
Fantastic. You've made a breakthrough.

Re: Screensaver

PostPosted: Mon Jan 16, 2012 12:23 am
by Game A Gogo
tintran wrote:edit: moved some arrays definition from displaywire() to global and solved the memory leak, weird I thought that functions automatically handled memory freeing of arrays that are defined within it.

This pretty much only happens within GE, happened to me before
When a game closes from within GE, I don't think it clears any memory