TRectangle is a TPrimitive used to render rectangles.
ProtoObjectObjectTObjectTFrameTPrimitiveTRectangle
- TButtonHolder
- TPortal
- TTexture
- TWaves
| aspect | aspectFixed | extent | flip | location | norm |
| OpenGLConstants |
| instance | class |
|---|---|
accessing
|
no messages
|
| aspect |
|---|
| aspectFixed |
|---|
| extent |
|---|
| flip |
|---|
| location |
|---|
| norm |
|---|
| accessing |
|---|
| aspect |
^ aspect. |
| aspect: asp |
aspect _ asp. |
| aspectFixed |
^ aspectFixed. |
| aspectFixed: bool |
aspectFixed _ bool. |
| extent |
^ extent. |
| extent: ext |
aspectFixed ifTrue:[ (extent x - ext x)abs > (extent y - ext y) abs ifTrue:[ extent _ (ext x) @ (ext x * aspect).] ifFalse:[ extent _ ext y/aspect @ ext y.]. ] ifFalse: [ extent _ ext.]. self boundsChanged. |
| extentRect: extRect |
self extent: (extRect extent). self location: (extRect center - (extRect extent/2.0))@0.0. |
| flip: bool |
flip _ bool. flip ifFalse:[norm _ (B3DVector3 x:0.0 y:0.0 z:1.0) ] ifTrue:[norm _ (B3DVector3 x:0.0 y:0.0 z:-1.0)]. |
| frameBox |
"Answer the local bounding box of this frame" ^TBox origin: (B3DVector3 x: extent x/-2.0 y: extent y/-2.0 z:0.0) corner: (B3DVector3 x: extent x/2.0 y: extent y/2.0 z:0.0) . |
| location |
^ location. |
| location: loc |
location _ loc. self boundsChanged. |
| normal: n |
norm _ n. |
| scale: scl |
self translation: self translation * scl. self extent: extent * scl. |
| initialize |
|---|
| initBounds |
boundSphere _ TBoundSphere localPosition: location radius: extent asPoint r / 2. boundSphere frame: self |
| initialize |
super initialize. location _ B3DVector3 x: 0.0 y:0.0 z:0.0. extent _ Point x: 1 y: 1. " x-y extent of the rect." self flip: false. aspectFixed _ false. aspect _ 1.0. self initBounds. ^self |
| render |
|---|
| pick: pointer |
| dx dy | dx _ self extent x/2. dy _ self extent y/2. flip ifFalse:[ ^ pointer pickQuad: norm q1: (B3DVector3 x: location x + dx negated y: location y + dy z: location z) q2: (B3DVector3 x: location x + dx negated y: location y + dy negated z: location z) q3: (B3DVector3 x: location x + dx y: location y + dy negated z: location z) q4: (B3DVector3 x: location x + dx y: location y + dy z: location z). ] ifTrue:[ ^ pointer pickQuad: norm q1: (B3DVector3 x: location x + dx y: location y + dy z: location z) q2: (B3DVector3 x: location x + dx y: location y + dy negated z: location z) q3: (B3DVector3 x: location x + dx negated y: location y + dy negated z: location z) q4: (B3DVector3 x: location x + dx negated y: location y + dy z: location z).] |
| renderPrimitive: ogl |
| dx dy uv | dx _ self extent x/2. dy _ self extent y/2. ogl glBegin: GLQuads. texture ifNotNil:[ uv _ texture uvScale.] ifNil:[uv_ 1.0@1.0.]. flip ifFalse:[ ogl glNormal3f: 0.0 with: 0.0 with: 1.0; glTexCoord2f:0.0 with: 0.0; "1" glVertex3f: location x + dx negated with: location y + dy with: location z; glTexCoord2f:0.0 with: uv y; "2" glVertex3f: location x + dx negated with: location y + dy negated with:location z; glTexCoord2f:uv x with: uv y; "3" glVertex3f: location x + dx with: location y + dy negated with: location z; glTexCoord2f:uv x with:0.0; "4" glVertex3f: location x + dx with: location y + dy with: location z.] ifTrue:[ ogl glNormal3f: 0.0 with: 0.0 with: -1.0; glTexCoord2f:uv x with:0.0; "4" glVertex3f: location x + dx with: location y + dy with: location z; glTexCoord2f:uv x with:uv y; "3" glVertex3f: location x + dx with: location y + dy negated with: location z; glTexCoord2f:0.0 with:uv y; "2" glVertex3f: location x + dx negated with: location y + dy negated with:location z; glTexCoord2f:0.0 with: 0.0; "1" glVertex3f: location x + dx negated with: location y + dy with: location z.]. ogl glEnd. |