3D Measurements
Blitz3D Forums/Blitz3D Programming/3D Measurements
| ||
Hi Guys :) I would like to have an object (box) created with the specified width, depth and height entered by the user. Is there any way to do this at all? I am creating some kitchen software and I would like everything to be to scale by using real world measurements (inch, cm, & ft for example) I have no idea where to start with stuff like this. I would be very grateful for your help :o) Thanks in advance Ash |
| ||
When you create a cube using CreateCube(), it has a standard size of 2x2x2. Use ScaleEntity to scale the box by a certain percentage. |
| ||
You can use the FitMesh command to scale your objects to the desired size. As for what scale to use, alot (most?) people seem to use a scale of 1 blitz unit to every metre. Of course, this will also depend on what kind of 'real world' you are trying to model, but I think this scale will be fine for your purposes. |
| ||
Thanks guys :D I'll use that. Thanks again! Ash |
| ||
ScaleEntity entity,x_scale#,y_scale#,z_scalel#,[,global] Parameters entity - name of the entity to be scaled x_scale# - x size of entity y_scale# - y size of entity z_scale# - z size of entity global (optional) - Description Scales an entity so that it is of an absolute size. Scale values of 1,1,1 are the default size when creating/loading entities. Scale values of 2,2,2 will double the size of an entity. Scale values of 0,0,0 will make an entity disappear. Scale values of less than 0,0,0 will invert an entity and make it bigger. ; ScaleEntity Example ; ------------------- Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() light=CreateLight() cone=CreateCone( 32 ) PositionEntity cone,0,0,5 ; Set scale values so that cone is default size to begin with x_scale#=1 y_scale#=1 z_scale#=1 While Not KeyDown( 1 ) ; Change scale values depending on the key pressed If KeyDown( 203 )=True Then x_scale#=x_scale#-0.1 If KeyDown( 205 )=True Then x_scale#=x_scale#+0.1 If KeyDown( 208 )=True Then y_scale#=y_scale#-0.1 If KeyDown( 200 )=True Then y_scale#=y_scale#+0.1 If KeyDown( 44 )=True Then z_scale#=z_scale#-0.1 If KeyDown( 30 )=True Then z_scale#=z_scale#+0.1 ; Scale cone using scale values ScaleEntity cone,x_scale#,y_scale#,z_scale# RenderWorld Text 0,0,"Use cursor/A/Z keys to scale cone" Text 0,20,"X Scale: "+x_scale# Text 0,40,"Y Scale: "+y_scale# Text 0,60,"Z Scale: "+z_scale# Flip Wend End |
| ||
Here is a quick fix:; ScaleEntity Example ; ------------------- Graphics3D 640,480 SetBuffer BackBuffer() WireFrame 1 camera=CreateCamera() light=CreateLight() cube=CreateCube() PositionEntity cube,0,0,10 ; Set scale values so that cube is default size to begin with x_scale#=Input("What is the intital length of the cube? ") y_scale#=Input("What is the initial height of the cube? ") z_scale#=Input("What is initial the depth of the cube? ") While Not KeyDown( 1 ) ; Change scale values depending on the key pressed If KeyDown( 203 )=True Then x_scale#=x_scale#-0.1 If KeyDown( 205 )=True Then x_scale#=x_scale#+0.1 If KeyDown( 208 )=True Then y_scale#=y_scale#-0.1 If KeyDown( 200 )=True Then y_scale#=y_scale#+0.1 If KeyDown( 44 )=True Then z_scale#=z_scale#-0.1 If KeyDown( 30 )=True Then z_scale#=z_scale#+0.1 ; Scale cone using scale values ScaleEntity cube,x_scale#,y_scale#,z_scale# TurnEntity cube,1,1,1 RenderWorld Text 0,0,"Use cursor/A/Z keys to scale cube" Text 0,20,"X Scale: "+x_scale# Text 0,40,"Y Scale: "+y_scale# Text 0,60,"Z Scale: "+z_scale# Flip Wend End |
| ||
Hi Puki :o) Thank you very much for your help. I really appriciate it :o) My appologies for the delay in replying, I had a late night last night ;o) Cheers Ash |
| ||
I have heard of a weird bug when scaling an entity to 0,0,0. so you might want to avoid that, as it seems to cause a big slow down on some machines. Long lost bug report i think :) |
| ||
Thanks for that Ross ;o) I'll keep that in mind. Thanks again man! Ash |