Scaling for idiots

Blitz3D Forums/Blitz3D Programming/Scaling for idiots

Picklesworth(Posted 2004) [#1]
Is there another way to scale a mesh that makes a mesh shrink with negative numbers, and grow with positive numbers? Or is there a function of some sort that lets me transform a negative number into a number from 0 to 1?

This is for scaling a mesh according to mouse movement. If someone has done this (which I'm sure someone has), can I please see the code?


ashmantle(Posted 2004) [#2]
Sin() would probably do the trick, but Im not clearheaded enough to cough up some code on the fly..

others will be able though.


BlackJumper(Posted 2004) [#3]
You could try something like this...

For n = -4 To 4
	Print n
	Print MyScale#(n)
	Print
Next

Function MyScale#(val#)
	If val<0 Then
		Return 1.0/val
	Else
		Return val
	EndIf
End Function



Ross C(Posted 2004) [#4]
Something like this should do:

Function Scale_Mesh(mesh,scale#)

	If scale < 0 Then
		ScaleEntity mesh,1.0/Abs(scale),1.0/Abs(scale),1.0/Abs(scale)
	Else
		ScaleEntity mesh,scale,scale,scale
	End If

End Function



Ross C(Posted 2004) [#5]
Here's some more. Move the move up and down to scale. Some weird happening here though. But, the general idea is there :D Only way to really solve it, is to you scalemesh, instead of ScaleEntity. It does mean though, that you'll have no way to get back to the orginal scale of the entity. Anyway, here goes:

Graphics3D 800,600
SetBuffer BackBuffer()


Global camera = CreateCamera()
PositionEntity camera,0,0,-10

Global light = CreateLight()

Global cube = CreateCube()

Global mouse_dif#


While Not KeyHit(1)


	If MouseY() <300 Then
		mouse_dif = mouse_dif + 0.1
	ElseIf MouseY()>300 Then
		mouse_dif = mouse_dif - 0.1
	End If
	
	Scale_Mesh(cube, mouse_dif)
	MoveMouse 400,300
	
	UpdateWorld
	RenderWorld
	Flip
Wend
End



Function Scale_Mesh(mesh,scale#)

	If scale < 0 Then
		DebugLog (1.0/Abs(scale))
		ScaleEntity mesh,1.0/Abs(scale),1.0/Abs(scale),1.0/Abs(scale)
	Else
		DebugLog scale
		ScaleEntity mesh,scale,scale,scale
	End If

End Function



Picklesworth(Posted 2004) [#6]
Yay! Thanks :D


Picklesworth(Posted 2004) [#7]
I thought of another method, and so may as well put it here. Just use
fitmesh entity,entityx(entity),entityy(entity),entityz(entity),meshwidth(entity)+xscale,meshheight(entity)+yscale,meshdepth(entity)+zscale



Ross C(Posted 2004) [#8]
Ah, cool idea :D