0% found this document useful (0 votes)
26 views18 pages

12 - Basic 3D in Processing

This document provides an overview of basic 3D concepts in Processing including: 1) The different renderers in Processing and when to use P3D for 3D graphics. 2) The 3D coordinate system in Processing and how to define basic 3D shapes like boxes and spheres. 3) Lighting controls in Processing like ambientLight and directionalLight and how lighting affects the rendered scene. 4) Projection types in Processing like perspective and orthographic and how to control the camera. Exercises are provided to practice translating, rotating, and modifying lighting and projections to better understand 3D rendering in Processing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views18 pages

12 - Basic 3D in Processing

This document provides an overview of basic 3D concepts in Processing including: 1) The different renderers in Processing and when to use P3D for 3D graphics. 2) The 3D coordinate system in Processing and how to define basic 3D shapes like boxes and spheres. 3) Lighting controls in Processing like ambientLight and directionalLight and how lighting affects the rendered scene. 4) Projection types in Processing like perspective and orthographic and how to control the camera. Exercises are provided to practice translating, rotating, and modifying lighting and projections to better understand 3D rendering in Processing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

12 – Basic 3D in Processing

TMD21304 – Computer Graphics


Sinantya Feranti Anindya, S.T., M.T.
(last revised 2023/12)
Outline

• Session description
• Aim and targeted learning outcome
• Topics:
• 3D space in Processing
• Processing renderers
• 3D coordinate system in Processing
• 3D shapes
• Lighting
• Perspective
• Camera Effects and 3D transformations
• Free discussion & Q/A session
• Review and assignment
What is this session about?

• You’ll learn on how to create Processing-based programs to


render simple graphics in 3D space.
• You’ll learn some basic concepts you need to be aware of
when rendering objects in 3D space.
By the end of this course, you should be able to…

• …demonstrate how to visualize simple 3D objects in


Processing.
• …demonstrate how to manipulate 2D objects in Processing’s
3D space.
• …able to describe the important aspects of 3D objects.
Reference

• Processing Official Tutorials


• https://processing.org/tutorials/p3d
Into the class… good luck!
Processing Renderers

• Renderer
• a set of code/program that takes a model’s data and actually draws
them to screen.
• The five renderers in Processing:
• Default renderer
• P2D
• FX2D
• P3D
• PDF
• SVG
When to Use Other Renderers?

• When you want to draw specifically into a file (PDF, SVG) and
want to maintain compatibility.
• When you use A LOT of objects but need to maintain
performance.
• When you want to use some renderer-specific features.
• For example, P2D and P3D make use of OpenGL-compatible graphics
hardware.
Using Alternative Renderers in Processing

• You need to define the renderer when creating the application


window.
3D Coordinates in Processing

• Different programs have


different coordinate systems.
• For Processing/P3D renderer,
the direction is as follows:
Shapes in Processing 3D Space

• You can use the basic


primitives from Processing
2D, alongside some new
primitives:
• box();
• sphere();
• You can use vertex too (in
fact, you’ll likely use it A LOT).
Box and Sphere

• You can define simple • You can define sphere using


box/cube using the following: the following:
• box(size); // defines cube • sphere(radius);
• box(width, height, depth);
Lighting

• An important part of 3D scene rendering is


the lighting.
• Processing supports some default lighting
modes:
• lights();
• ambientLight(r, g, b);
• directionalLight(r, g, b, x, y, z);
• spotLight(r, g, b,
x_source, y_source, z_source,
x_target, y_target, z_target,
angle, concentration
);
• pointLight(r, g, b, x, y, z);
• If making dynamic scene:
• Lighting must be set in draw(); to calculate the
colors each time.
Lighting
Projections

• Processing supports both perspective and


orthographic projections.
• perspective(); //default
• perspective(fov_y, aspect, zNear, zFar);
• ortho();
• ortho(leftClip, rightClip, bottomClip,
topClip);
• ortho(leftClip, rightClip, bottomClip,
topClip, near, far);
• Try modifying the code and see what
happens.
Exercises

• Practice the examples as presented here. Then, do the following:


• Translate and rotate:
• What happens when you don’t use translate() function?
• What happens when the pushMatrix and popMatrix are removed?
• Try all of the other different lighting modes (free specification), and present the
result.
• What happens when the lighting is put in setup() instead of draw()?
• What happens when you modify the camera and projections?
Next week

Custom 3D shape and texturing in Processing


Good luck!

You might also like