0

what i am trying to learn to do is draw a 3D shape in a JFrame.

All I want to use to do this is my IDE. If anyone can help with how to draw any 3d shape like a square, and if its possible, how to rotate it. Or could someone put a link to a recource for learning how to draw 3d shapes only with java like i said above. If anyone needs more detail please ask. (please do not ask me to do this differently if it is possible to do it this way).

thanks.

user1776707
  • 23
  • 1
  • 7
  • Swing alone does not support 3D Graphics as far as I know. – aksappy Feb 14 '13 at 07:22
  • so it is not possible to draw anything 3d like this? no games or anything has 3d graphics without using library's and stuff? – user1776707 Feb 14 '13 at 07:24
  • If it IS possible, just curious as to why would you want to write all that code when it is easily accessible with libraries such as LWJGL and JOGL? – Savlon Feb 14 '13 at 07:27
  • because i would prefer to learn how to do it, even if it is somthing basic that im displaying in 3d i would be happy to write 3000 lines of code if i understand it. – user1776707 Feb 14 '13 at 07:41

1 Answers1

2

Java has a 3-D package, which may or may not meet your criterion of "no other libraries or framework or anything":

If it does, then you're still going to have to at least use the 2D Java package:

Q: How do you draw 3D objects using the 2D primitives?

A: It's not necessarily difficult, depending on how in-depth you want to go. At this simplest, just:

a) define a 3d coordinate system (normalized points 0.0 - 1.0 are always good)

b) write the functions to transform your 3D model into 2D coordinates

Lots of books (and tutorials), including:

I'm assuming your goal is to "learn the basics".

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • i am trying to stay away from things like java3D untill i can atleaste write somthing by myself that displays anything in 3d. is it at all possible to do that? just a shape, nothing amazing like a full gam or scene, im just trying to do a shape. possible? – user1776707 Feb 14 '13 at 07:43
  • If you can draw a 2D shape, then you can draw a 3D one just the same with coordinate space conversions like the ones seen [here](https://stackoverflow.com/questions/6139451/how-can-i-convert-3d-space-coordinates-to-2d-space-coordinates). – Vessel Oct 13 '20 at 17:31