Drawing3D - Draw commands for 3D Scenes

Share your advanced PureBasic knowledge/code with the community.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Drawing3D - Draw commands for 3D Scenes

Post by STARGÅTE »

This include is an extension to the Drawing library to draw lines, triangles, or boxes in three-dimensional space. The whole is based on pure drawing and CPU instructions, so no additional DLLs. The include should not be used as a 3D engine (it's too slow), but to render small scenes.

Drawing3D.zip
Inlcude, a demo and five examples.
  • With StartDrawing3D() : StopDrawing3D() the environment is opened.
  • With Drawing3DMode() you can select or #Drawing3D_Outline or #Drawing3D_Default
  • Drawing3DPosition() and Drawing3DRotation() to change the position and rotation of the scene
  • All colors are always specified in 32-bit ($FF00FF00 for Green)
  • Drawing3DBackground() fill the area with the specified color. (if the alpha value is 0, the background is really transparent, useful for 32-bit images)
  • Drawing3DLight() sets a light (indicating where it comes from) in the scene
  • DrawPoint3D() DrawLine3D() and DrawTriangle3D() is a point, line or triangle (with vertex colors)
  • At DrawPlane3D(), DrawImage3D() and DrawBox3D() only the position, size and rotation is specified.
  • CreateImage3D () creates a Image3D from the image
Here is an example of a Drawing3D scene with a transparent background.
Image
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Drawing3D - Draw commands for 3D Scenes

Post by Danilo »

Thank you very much! Really amazing! Image
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Drawing3D - Draw commands for 3D Scenes

Post by Fred »

Yes, it's really good !
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Drawing3D - Draw commands for 3D Scenes

Post by Little John »

Hi Stargate,

really amazing, and might be very useful for a project of mine in the future. Image
Thank you very much for sharing!

I made an observation, and don't know whether or not that effect is intended.
After running Example03.pb, I get this result:

[Image removed]

What about the small area that I have marked with a black polygon here:

[Image removed]

Is the different color of that area an artefact?

Regards, Little John
Last edited by Little John on Sun Feb 03, 2013 7:36 pm, edited 1 time in total.
luciano
Enthusiast
Enthusiast
Posts: 151
Joined: Wed Mar 09, 2011 8:25 pm

Re: Drawing3D - Draw commands for 3D Scenes

Post by luciano »

Is the different color of that area an artefact?
No, I think it is a part of the rear face of the magenta cube.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Drawing3D - Draw commands for 3D Scenes

Post by STARGÅTE »

These boxes are transparent (25%), you see the rear face that is lighter because it is lighted.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Drawing3D - Draw commands for 3D Scenes

Post by Little John »

I see. I think I'll have to train my 3-D imagination. :-)
Thanks.
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Drawing3D - Draw commands for 3D Scenes

Post by idle »

very nice thanks
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Drawing3D - Draw commands for 3D Scenes

Post by eddy »

Great job! :D
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2056
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: Drawing3D - Draw commands for 3D Scenes

Post by Andre »

After commenting the WinAPI command calls (QueryPerformanceCounter_() - it seems to be not urgently needed!?) it's also working fine on MacOS 10.5.8.

Well done! Thanks a lot! :D
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Drawing3D - Draw commands for 3D Scenes

Post by netmaestro »

Truly excellent work and very useful for making stunning projects! Thanks a lot for this 8) 8) 8)
BERESHEIT
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Drawing3D - Draw commands for 3D Scenes

Post by STARGÅTE »

Andre wrote:After commenting the WinAPI command calls (QueryPerformanceCounter_() - it seems to be not urgently needed!?) it's also working fine on MacOS 10.5.8.

Well done! Thanks a lot! :D
No, it is only for measure the time to render the scene
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: Drawing3D - Draw commands for 3D Scenes

Post by em_uk »

Genius!

Thanks!
----

R Tape loading error, 0:1
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: Drawing3D - Draw commands for 3D Scenes

Post by heartbone »

STARGÅTE, you posted this before I joined and I had not seen it until now.
I now plan to use your extension in the port of INTERSHIP (version 3) from 2½D to 3D.
Thanks for the contribution and I'd like to mention you in the game's credits.
As much as I enjoyed the TV show, I'd prefer using a real name over inserting STARGÅTE.
If and when I come close to completing my little freeware game,
I'll contact you to see if I can credit you by real name. ;)

Image
http://www.acid-play.com/download/intership
The reviewer was a bit harsh considering the original gameplay design of my over 10 year old work. However in three dimensions I'll be able to have better eye candy rocket attacks, splashes, waves, explosions, ship sinking animations, and oil slicks. Using your extension should decrease the time needed to port the simulation into 3D.
Thanks again.
Keep it BASIC.
Post Reply