In 3D

Updated: 2025-09-15

Although everything can be represented in 2D, in some simulations—especially mechanical ones or those with a strong visual focus—it may be desirable to use 3D representations.

GPSS-Plus is not intended to be a 3D modeling tool; the focus is on enabling visually effective simulations that are easy to implement. Therefore, 3D content can come from two sources:

  • External .GLB files
  • Built-in geometric primitives

 

Available 3D primitives

Type Description
BOX 3D box with WIDTH, HEIGHT, DEPTH
SPHERE Sphere with RADIUS and optional SEGMENTS
TRIANGLE Triangle
PLANE Plane made of two triangles sharing an edge
PRISM Regular prism between two points, with SIDES sides
OBJECT External object in .GLB format

 

Permanent transforms (at creation time)

Property Applies Description
WIDTH, HEIGHT, DEPTH Permanent Resizes the base geometry
displace_x/y/z Permanent Offsets the model relative to its internal pivot
rotate_x/y/z Permanent Rotates the model around its internal pivot

Dynamic transforms (in MOVE)

Action Description
MOVE_BETWEEN Positions the object between two points while keeping its size
STRETCH_BETWEEN Scales the object in Y to fit between two points
rotate_y Adds extra rotation around its Y axis, useful for screws or gears
y With MOVE_BETWEEN, allows sliding along the line

These actions are analogous to PRISMATIC and REVOLUTE joints in mechanical systems, but applied directly from the mathematical knowledge of the object's position.

Examples

; Places a spring described in a file between two defined points
MOVE {name:spring, STRETCH_BETWEEN:"[0,0,0],[0,P$x_mass,0]"}

; Places a piston or telescopic segment along a segment at position "X" relative to its center point
MOVE {name:shock_absorber, MOVE_BETWEEN:"[0,0,0],[0,P$x_mass,0]",y:P$x_mass -10}

Enable 3D mode

SYSTEM {TYPE:VISUAL, MODE:3D, V_WIDTH:70, V_HEIGHT:30, CAMERA:1}

V_WIDTH, V_HEIGHT: area the objects will occupy in internal units
CAMERA: camera preset (1 = isometric, 2 = top-down, etc.)

The example

In this example, two points are used to rotate a nut around that same axis.

Example

/*

 Graphics. 3D
 
*/
SYSTEM {TYPE:PRE_RUN, TRIGGER:PRE_RUN}
SYSTEM {TYPE:VISUAL, MODE:3D, V_WIDTH:40, V_HEIGHT:20, CAMERA:0}
SYSTEM {TYPE:OPTIONS, TIME_DECIMALS:1, SPEED:5}

GRAPHIC {NAME:floor, TYPE:PLANE, X:25, POINTS:"[0,0,0],[0,0,40],[40,0,0]", color:#fabada}

GRAPHIC {NAME:nut, TYPE:OBJECT, src:NUT, X:0, Y:0, Z:0,WIDTH:20, HEIGHT:20, DEPTH:20,rotate_x:90,opacity:0.9}

Graphic {NAME:axis1,Type:LINE,X1:0,Y1:0,X2:0,Y2:500}
Graphic {NAME:axis2,Type:LINE,X1:0,Y1:0,X2:500,Y2:0}
Graphic {NAME:axis3,Type:LINE,X1:0,Y1:0,X2:0,Y2:0,Z2:500}


Graphic {NAME:line4,Type:LINE,POINTS:"[10,0,10],[150,150,150]",color:red}
Graphic {NAME:Text1,Type:TEXT,X:20,Y:20,text:"sss",font:"2px"}



START 1
;===========================
; PROCEDURES
;===========================

PROCEDURE agent.init

savevalue DT,0.1
savevalue speed,1
savevalue X,4
savevalue state,0

  WHILE (1==1)

	if (X$state==0)
    savevalue X,X$X + X$DT * X$speed
	else 
    savevalue X,X$X - X$DT * X$speed
	endif
    
    if (X$X>10)
    savevalue state,1
    endif
    if (X$X<4)
    savevalue state,0
    endif
   
    assign height, round(X$X,3)
	move {name:Text1,text:"Height: P$height"}
    ; The nut is positioned and rotated around its axis
    MOVE {name:nut, MOVE_BETWEEN:"[10,0,10],[150,150,150]", rotate_y:P$height * 60,y:P$height}

    ADVANCE 1, 0

  ENDWHILE

STOP
ENDPROCEDURE
;===========================
PROCEDURE PRE_RUN

  TIMEOUT agent.init, 0

  TERMINATE_VE

ENDPROCEDURE