Page 1 of 1

CollisionBounds fourth value?

Posted: Mon Sep 11, 2023 7:47 pm
by Ats
Hello. There is a fourth value that can be set for CollisionBounds, besides X,Y and Z.

collisionbounds.png
collisionbounds.png (14.33 KiB) Viewed 23063 times

There is no word about it in the Help:
The size of this model when it is tested for collision. This value is interpreted differently depending on the value of the CollisionStyle property:
• CollisionStyle is Rect2D or Rect2D_OBB: The first value represents the width, and the second value is the height.
• CollisionStyle is Sphere3D or Circle2D: The first value is the radius of the sphere.
• CollisionStyle is Box3D: The first value represents the width, the second is height, and the third value is the depth (x,y,z).
So what is it, and how to set/get it by code?

Re: CollisionBounds fourth value?

Posted: Mon Sep 11, 2023 7:53 pm
by Ats
Never mind, I got it like a color: Model.CollisionBounds.A

But now I'm wondering what it has to do with bounds :lol:

Edit:
and Model.CollisionBounds.W

Maybe it should be mentioned in the Help :wink:

Re: CollisionBounds fourth value?

Posted: Mon Sep 11, 2023 8:20 pm
by Kjell
Hi Ats,
Ats wrote: Mon Sep 11, 2023 7:47 pmThere is a fourth value that can be set for CollisionBounds, besides X,Y and Z. So what is it?
It's ( currently ) not used by any of the collision styles.
Ats wrote: Mon Sep 11, 2023 7:47 pmHow to set/get it by code?
Both XYZW and RGBA can be used with any 4D vector. So in order to access the 4th component of CollisionBounds you can use either W or A.

Which also means you can do this ( although i wouldn't recommend it ) :wink:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
  <OnUpdate>
    <ZExpression>
      <Expression>
<![CDATA[// Animate blue component of clear color

App.ClearColor.Z = cos(App.Time)*0.5+0.5;

// Animate x-coordinate of camera

App.CameraPosition.R = sin(App.Time);]]>
      </Expression>
    </ZExpression>
  </OnUpdate>
  <OnRender>
    <RenderSprite/>
  </OnRender>
</ZApplication>
In GLSL you can also use STPQ ( which is generally used when dealing with texture coordinates ), but that's not available elsewhere in ZGE.

K

Re: CollisionBounds fourth value?

Posted: Mon Sep 11, 2023 8:23 pm
by Ats
Hahaha, nice little hack Kjell :D