Problem with scaling?

Blitz3D Forums/Blitz3D Beginners Area/Problem with scaling?

Guy Fawkes(Posted 2012) [#1]
Hi, Ross. I'm having trouble with the scale code I created...


What I need it to do is retain the object's size, BUT when u hold down CTRL + Shift + A, depending on if u hold down A (which is positive), or S (which is negative), then it scales it by whatever value is in the scale_selected parameters, as long as the value is > 0.0, and <= 0.5...



Here's the code:






Thanks, Ross! :)

Last edited 2012


Guy Fawkes(Posted 2012) [#2]
Ok, fixed the ABOVE problem. Having another problem...


It seems when u make one copy of an object, then scale the object with Ctrl + Shift + A or Ctrl + Shift + S, then make another copy, then try to scale it, the objects dont take into account the new position of an object when it is scaled...



Here's the problem:







Here's the code:







b3dfile.bb:







Any help is GREATLY appreciated! :)



Thanks! :)

Last edited 2012


Ross C(Posted 2012) [#3]
Please don't pick out forums members to fix your code.

For one thing, your not checking in your scale_selected code, if anything is selected.

I'm not sure what you mean by:


It seems when u make one copy of an object, then scale the object with Ctrl + Shift + A or Ctrl + Shift + S, then make another copy, then try to scale it, the objects dont take into account the new position of an object when it is scaled...



You copy an object. You scale it. You make another copy. You try to scale the copy. Then what happens? I don't follow...


Guy Fawkes(Posted 2012) [#4]
ok... u copy an object. u scale it. u then try to scale the copy, and it scales straight in to the other objects..



...



This happens:





Last edited 2012


Guy Fawkes(Posted 2012) [#5]
Do u need more information, Ross? :)


Ross C(Posted 2012) [#6]
You need to use CopyMesh instead of CopyEntity in the copy function, and ScaleMesh instead of ScaleEntity whereever it's used. That will sort it. The ScaleEntity command does nothing to actually scale the mesh, so the MeshWidth/Height/Depth commands only refer to the orginal mesh, not any scale entity modifiers.


Guy Fawkes(Posted 2012) [#7]
Copymesh screws up the way it pastes objects ><


Guy Fawkes(Posted 2012) [#8]
I just now found out. there's also a problem with copying. When u copy a bunch of objects, then u go back to the 1st 1 IF it's still in the same position, or RELATIVELY close to the same position, it copies a mesh inside of a mesh >< and keeps on doing that til it reaches the last mesh, THEN it goes back to normal and continues copying normally.


Ross C(Posted 2012) [#9]
CopyMesh only copies the mesh. You'll need to set the pickmode of the newly created mesh and other properties that are required, including position.


Guy Fawkes(Posted 2012) [#10]
? i DID set the pickmode.... o.o


as for position. what do u mean, exactly?


Ross C(Posted 2012) [#11]
Fix for the copy function:

; creates a copy and positions it away from the original. Uses the originals width to space, mulitplied by the provided values
Function create_new_copy(temp.obj,offset_x#,offset_y#,offset_z#,selected = 0)

	new_c.obj = New obj
	new_c\selected = 0
	new_c\mesh = CopyMesh(temp\mesh)
	temp_x_offset = (MeshWidth(new_c\mesh) + (MeshWidth(new_c\mesh)*0.1)) * offset_x
	temp_y_offset = (MeshHeight(new_c\mesh) + (MeshHeight(new_c\mesh)*0.1)) * offset_y
	temp_z_offset = (MeshDepth(new_c\mesh) + (MeshDepth(new_c\mesh)*0.1)) * offset_z
	
	EntityPickMode new_c\mesh,2
	
	PositionEntity new_c\mesh,EntityX(temp\mesh,True)+temp_x_offset, EntityY(temp\mesh,True)+temp_y_offset, EntityZ(temp\mesh,True)+temp_z_offset

	new_c\red = temp\red
	new_c\green = temp\green
	new_c\blue = temp\blue
	EntityColor new_c\mesh,new_c\red,new_c\green,new_c\blue
	
	If selected = 1 Then
		select_object(new_c.obj)
	End If
	
	object_count = object_count + 1
	
End Function


Last edited 2012


Guy Fawkes(Posted 2012) [#12]
Thanks, Ross. Here's a better fix:





It's still doing that entity inside entity thing though. Where if I 1st select an object, make a copy of it. then I select the 1st object AGAIN, and make ANOTHER copy of it, it pastes the entity inside of the entity. after that, if I hit copy a 3rd time or greater, it's back to normal AFTER it reaches beyond the last mesh. :)


Ross C(Posted 2012) [#13]
That's not a bug. It would be extremely difficult to keep track of how many copies you've made from each entity, and where you have positioned them, in order to keep going in a row. Your stuck with it the way it is i'm afraid, unless you can devise a better system. It's not doing anything other than copying the mesh and offseeting it, then selecting the copy.

Solution, don't do it, or create some kind of click where you want to paste system.

Regarding your better fix. Don't call it that please, as you could fix it in the first place :)Also, I don't have that function, as it must use an external DDL. I would stick with the ScaleMesh though, for simplicity, but meh. It's up to you.

Last edited 2012

Last edited 2012


Guy Fawkes(Posted 2012) [#14]
Hard. BWAHAHA. Take a look at this:







The ONLY thing left now, is to keep the "last" selected entity the same size as all the other copied entities :) If u can tell me how to do THAT, then problem solved! :)


Guy Fawkes(Posted 2012) [#15]
O yea! Ross, I almost forgot. U'll need the Blitz3D+ DLL to run this function with the editor, as I use "BP_GetEntityScaleX#,Y#,Z#", in order to get the EXACT correct size of an object! :)


Ross C(Posted 2012) [#16]
1. Why are you scaling the entity you are copying's mesh, to the same size it is already?

2. You do realise what PositionMesh does? Your moving the mesh away from it's actual entity location. If you where to say, PositionEntity c\mesh, it would be offset from this position by the amount you stated in PositionMesh. Furthermore, your RotateEntity/RotateMesh will be using the 0,0,0 co-ords of the Entities own co-ords, to rotate things around. The same goes with the ScaleEntity/ScaleMesh commands. Now, when you scale a mesh, if it's offset via PositionMesh, it will move away from the centre spot whilst scaling, and rotating.

3. Your moving the original entity away from it's location. Surely that's a very bad idea!

If your happy with it, then fair enough, but I can be pretty sure noone is going to want to use a copy function like that. It's crazy!

Last edited 2012


GfK(Posted 2012) [#17]
RossC: when you're done with your personal tutoring i was wondering if you, being the helpful sort that you are, might be able to find the time to do my knee operation? Would go to the NHS but i'd only have to wait and if figure you would do it right now and save me the trouble of going through the proper channels. Let me know in the next five minutes. Kthxbai.


Guy Fawkes(Posted 2012) [#18]
I dont think it's crazy. Hell, I can create over 1000 objects in < 30 seconds! :)


Guy Fawkes(Posted 2012) [#19]
GFK, get ur own bloody thread. and LEAVE ME ALONE! :<


Ross C(Posted 2012) [#20]
Run this code:



The sphere on the left has been positioned using PositionEntity.
The sphere in the right has been positioned using PositionMesh.

They now are both rotated. The same will happen with scaling.



That is why it's crazy. I can create 1,000 objects in < 30 seconds as well. But, as you wish. Sits at the side with popcorn.

Last edited 2012

Last edited 2012


Ross C(Posted 2012) [#21]
Gfk, no problem. I'm actually rather good at knee operations. If you sit right there, i'll start the procedure and someone else will fix what i've done and make it better. There you go sir. You didn't need that lung it seems.


Guy Fawkes(Posted 2012) [#22]
No one says u HAVE to use it -.- thats what single object copy is for. its for ppl who wanna create a MASSIVE LOAD of objects at one time just before work, and dont have time to sit there and keep on hitting CTRL + C


Ross C(Posted 2012) [#23]
Did you read anything I typed. Did you run the code I posted? I give up! Mmmmmmm... Popcorn.


Guy Fawkes(Posted 2012) [#24]
Yes. I'm modifying my formula now :)


Guy Fawkes(Posted 2012) [#25]
god darn it! Im so close... :(





Guy Fawkes(Posted 2012) [#26]
Ok... Ok... Ive made it so u can copy only SINGLY selected objects.


Function check_mouse():





Guy Fawkes(Posted 2012) [#27]
HA! I've almost got it stacking in rows! :)






Guy Fawkes(Posted 2012) [#28]
Ok... my math is still off. Can someone please help?


Any help is greatly appreciated! :)