Select Object Arrows

Blitz3D Forums/Blitz3D Programming/Select Object Arrows

Caton(Posted 2017) [#1]
I'm trying to select and move the object for my level editor with the mouse anyway I could do that?
<Image Removed>


grable(Posted 2017) [#2]
A CameraPick for the colored parts on first detected MouseDown, then move the entity with MouseXSpeed/MouseYSpeed depending on picked direction.

My code for moving with the mouse usually follows this pattern:
Global down

If MouseDown(1) Then
	If Not down Then
		; enter move state
		down = True
		MouseXSpeed()
		MouseYSpeed()
	EndIf
	; inside move state
	; move it here using MouseXSpeed() and MouseYSpeed())
ElseIf down Then
	; leaving move state
	down = False
EndIf



Caton(Posted 2017) [#3]
I have two objects, Now when I select one object to move, the other one goes missing

If MouseDown(1) Then
CameraPick(Maincam, MouseX(), MouseY())
For obj.tobj = Each tobj
If PickedEntity() Then PositionEntity obj\mesh,PickedX#(),0,PickedZ#()
Next
EndIf



grable(Posted 2017) [#4]
I assumed from your picture you wanted a movable thingy, like what 3D editors have, but looking at your code you are doing placement instead?

In any case, heres some code to move a thingy with the mouse:



Caton(Posted 2017) [#5]
but what about object rotation?


grable(Posted 2017) [#6]
Replace MoveEntity with TurnEntity?


Caton(Posted 2017) [#7]
I know this off topic but I need to fix this error.
Trying to make level list

ListDir=ReadDir("c:\test") 
Repeat
lvfile$=NextFile$(ListDir)
If lvfile$="" Then Exit
If FileType("c:\test"+"\"+lvfile$) = 2 Then
DebugLog("c:\test"+"\"+lvfile$)
list.levlist = New levlist
y=y+1
list\y=y
EndIf
Forever
CloseDir ListDir

Type levlist
field name$,y
End Type


I only have one folder in test but it says three how can I fix this?


grable(Posted 2017) [#8]
You need to check for "." and ".." too and skip them.


Caton(Posted 2017) [#9]
I did but it still doesn't work.
ListDir=ReadDir("c:\test") 
Repeat
lvfile$=NextFile$(ListDir)
If lvfile$="" or lvfile$="." or lvfile$=".." Then Exit
If FileType("c:\test"+"\"+lvfile$) = 2 Then
DebugLog("c:\test"+"\"+lvfile$)
list.levlist = New levlist
y=y+1
list\y=y
EndIf
Forever
CloseDir ListDir

Type levlist
field name$,y
End Type



grable(Posted 2017) [#10]
"." and ".." are the two first elements of a directory, your loop never reaches any further because you exit to early.


Caton(Posted 2017) [#11]
Still didn't work
ListDir=ReadDir("c:\test") 
Repeat
lvfile$=NextFile$(ListDir)
If lvfile$="" Then Exit
If FileType("c:\test"+"\"+lvfile$) = 2 Then
list.levlist = New levlist
y=y+1
list\y=y
DebugLog("c:\test"+"\"+lvfile$)
EndIf
If lvfile$="." or lvfile$=".." Then Exit
Forever
CloseDir ListDir

Type levlist
field name$,y
End Type



Chalky(Posted 2017) [#12]
That's because you're still exiting as soon as you find them.

You should only exit if lvfile$ is empty (untested):
ListDir=ReadDir("c:\test") 
Repeat
  lvfile$=NextFile$(ListDir)
  If lvfile$="" Then Exit
  If FileType("c:\test\"+lvfile$) = 2 Then
    If lvfile$<>"." And lvfile$<>".." Then
      list.levlist = New levlist
      y=y+1
      list\y=y
      DebugLog("c:\test\"+lvfile$)
    EndIf
  EndIf
Forever
CloseDir ListDir

Type levlist
  field name$,y
End Type



Caton(Posted 2017) [#13]
Only will do one object but not other objects



Chalky(Posted 2017) [#14]
1.
Did the code I posted for you in #12 work?

2.
If you're posting as much code as you have in #13 it's probably better to use [codebox][/codebox] than [code][/code].

3.
Did you write the code in #13 yourself - or are you trying to adapt someone else's? I assume you want to know why only one object is getting processed in the For/Next loop? Could you please highlight where in your code are you creating multiple objects?

Repeatedly posting chunks of code with a vague question/statement is not likely to get much response - particularly if you do not acknowledge people's efforts to help.


Caton(Posted 2017) [#15]
Yep the level list works now.

grable's code



My code




Caton(Posted 2017) [#16]
umm... so why is it doing it wrong moving only one object?


dna(Posted 2017) [#17]
I get a memory access violation


Caton(Posted 2017) [#18]
your debugger is off.


grable(Posted 2017) [#19]
I tried your latest code, but it doesnt even compile, and even after making it compile its not setup correctly.

Anyway...
You are confusing the various objects you are selecting and moving, i assume you dont want to move ALL objects like you are attempting to do (with all those For loops), lots of redundant code.

Heres what i got after some fixing, i added creation of new objects with space. Also i added some indentation, as i could not read it without.
Notice that the first mousedown has 2 states now, using entity type 0 for the real objects and still 1,2,3 for the axl.