Transforming a scale

Blitz3D Forums/Blitz3D Programming/Transforming a scale

JoshK(Posted 2005) [#1]
How would I transform a scale from world to local space, without using the "global" flag? Let's say I have a mesh rotated to 0,45,0. How would I make it twice as wide, in global space coordinates?

Transforming the scale vector isn't the solution, as this code shows:
Graphics3D 400,300,16,2
m=CreatePivot()
RotateEntity m,0,45,0
TFormVector 1,1,1,0,m
RuntimeError TFormedX()+", "+TFormedY()+", "+TFormedZ()

Inputting a global scale of 1,1,1 would produce a local scale of 1,1,1.


Matty(Posted 2005) [#2]
If you want to do it to a non-animated mesh, couldn't you simply do this:

rotatemesh m,0,45,0
scalemesh m,2,1,1

(I assume you are asking how to make a mesh twice as wide in the world's x-axis after first rotating the mesh by 45 degrees about the y-axis)


Shambler(Posted 2005) [#3]
Since the mesh is rotated 'width' no longer means just scaling in X it also means scaling in Z too.

Some adjustment to the X,Z elements of the scale matrix using sin/cos will be required but don't ask me how lol.

[Edit] is it not TFormVector 0,0,1,0,m ?


JoshK(Posted 2005) [#4]
Okay, I want a box rotated at 0,45,0 to to fit within a bounding box that is 2x1x1.

Since I want all the box's corners to touch, this requires me to change the rotation, we well. Otherwise the box would have to be skewed.



Shambler(Posted 2005) [#5]
Not sure I understand you.

What size is the box originally?

Any box rotated 45 degress will only fit into a square bounding box e.g. 2*2*1 unless you skew it.


Matty(Posted 2005) [#6]
Edit: Sorry I just realised this is not what you are after as the box inside is skewed.


You mean like this: (Edit - no not like this )

Further edit: Perhaps see if you can achieve what you are after with a 3d modeling package, even milkshape, and work it out from there (not the best way I guess)

Further further edit: Having a look at it on paper I agree with Shambler - without skewing it I don't think it is possible to fit a cube inside a 2x1x1 cuboid with all corners of the cube touching the sides of the cuboid
Graphics3D 800,600,32,2
WireFrame True

camera=CreateCamera()
MoveEntity camera,0,0,-50
cube1=CreateCube()
cube2=CreateCube()
ScaleMesh cube1,2,1,1
RotateMesh cube2,0,45,0
FitMesh cube2,-2,-1,-1,4,2,2
Repeat
angle=angle+1
x#=10*Sin(angle)
z#=10*Cos(angle)
y#=10*Sin(angle)
PositionEntity camera,x,y,z
PointEntity camera,cube2
RenderWorld
UpdateWorld
Flip

Until KeyDown(1)



JoshK(Posted 2005) [#7]
It's possible, but you have to rotate it, too.

I don't really want the rotations to change when objects are move, so I think scales will have to be input by hand.