Page 5 of 8

Posted: Sun Jun 05, 2005 12:07 pm
by S.M.
@Psychophanta
No problem.If I remember right it could create a memory-leak when it's freed in wrong order (But I can't find the text on msdn.com). Anyway, nice to see that you're using S3DR.
Psychophanta wrote:By the way, please: Are there a way to increase/decrease the size of a created mesh on runtime?
I mean no zoom or camera movs, but mesh size.
Do you mean someting like
S3DR_DrawMesh(X.f,Y.f,Z.f,RotateX.f,RotateY.f,RotateZ.f[,ScaleX.f,ScaleY.f,ScaleZ.f]) ? :idea:

P.S.:
WOW, this it the sixtieth post in this thread. :shock:
regards
Stefan

Posted: Sun Jun 05, 2005 1:38 pm
by Psychophanta
S.M. wrote:
Psychophanta wrote:By the way, please: Are there a way to increase/decrease the size of a created mesh on runtime?
I mean no zoom or camera movs, but mesh size.
Do you mean someting like
S3DR_DrawMesh(X.f,Y.f,Z.f,RotateX.f,RotateY.f,RotateZ.f[,ScaleX.f,ScaleY.f,ScaleZ.f]) ? :idea:
Hieah! that's nice, because no needed a new function!
When? i am now jammed just because i can't resize meshes!
:D

Posted: Sun Jun 05, 2005 2:52 pm
by S.M.
Ok,here it is: :D
http://hometown.aol.de/MoebiusStefan/S3DR (only Purebasic Library)
It would be nice if somebody could test it ! :roll:
regards
Stefan

Posted: Sun Jun 05, 2005 3:09 pm
by Psychophanta
Great :D
tested, but i find something weird: when i add ,1,1,1) i notice no change, so all is ok. when i add 0.5,1,1) i notice the mesh is stretched in y axis.
When i add ,1,0.5,1) i notice it is stretched in x axis. And finally if i add ,1,1,0.5) it is stretched in x and y axis, but no in z axis :o

And hey, please don't forget one of the reasons i am using your lib is because i am believing nobody in the world can make it faster than S3DR do :wink:

Posted: Sun Jun 05, 2005 3:52 pm
by S.M.
@Psychophanta
Thanks for testing and sorry for doing the same mistake again.
Can you test it again ?
http://hometown.aol.de/MoebiusStefan/S3DR_library.zip
I will eat on my mousepad, if you find another bug in the command. :twisted:
Psychophanta wrote:And hey, please don't forget one of the reasons i am using your lib is because i am believing nobody in the world can make it faster than S3DR do
:lol:

regards
Stefan

Posted: Sun Jun 05, 2005 4:04 pm
by Psychophanta
Tested,
poor your mousepad, it will be eaten :lol:

look:

Code: Select all

InitSprite()
InitSprite3D()
InitKeyboard()
InitMouse()
OpenScreen(1024,768,32,"Rotating Cube")

S3DR_CreateZBuffer()
DataSection
sprite1:IncludeBinary "yourtexturehere"
EndDataSection
UsePNGImageDecoder()
CatchSprite(1,?sprite1,#PB_Sprite_Texture)
TransparentSpriteColor(1,255,0,255)
Start3D()
S3DR_BeginReal3D()
S3DR_MoveCamera(0,0,-5)

;Create the cube
S3DR_StartCreateMesh()
S3DR_CreateMesh_AddQuad(-1, 1, 1,-1, 1,-1,-1,-1, 1,-1,-1,-1);<-cara izquierda
S3DR_CreateMesh_AddQuad( 1,-1, 1,-1,-1, 1, 1,-1,-1,-1,-1,-1);<-cara de abajo
S3DR_CreateMesh_AddQuad(-1, 1, 1, 1, 1, 1,-1, 1,-1, 1, 1,-1);<-cara de arriba
S3DR_CreateMesh_AddQuad(1,1,1,-1,1,1,1,-1,1,-1,-1,1);<-cara de atras
S3DR_CreateMesh_AddQuad(-1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1);<-cara de enfrente
S3DR_CreateMesh_AddQuad( 1, 1,-1, 1, 1, 1, 1,-1,-1, 1,-1, 1);<-cara derecha
Cube=S3DR_StopCreateMesh()


S3DR_EndReal3D()

Sprite3DQuality(1)
Stop3D()

Repeat
  ExamineKeyboard()
  ExamineMouse()
  
  Start3D()
  S3DR_BeginReal3D()
  S3DR_ClearScreenAndZBuffer($000000)
  
  ;Draw the cube
  S3DR_SelectTexture(1)
  If MouseButton(1):angleZ.f-MouseDeltaX()/500
  Else:angleX.f-MouseDeltaX()/500
  EndIf
  angleY.f-MouseDeltaY()/500
  S3DR_DrawMesh(Cube,0,0,0,angleY.f,angleX.f,angleZ.f,1,1,1)

  
  If KeyboardPushed(#PB_Key_Left) :S3DR_RotateCamera(-0.025,0,0):EndIf
  If KeyboardPushed(#PB_Key_Right):S3DR_RotateCamera(0.025,0,0):EndIf
  If KeyboardPushed(#PB_Key_Up)   :S3DR_MoveCamera(0,0,0.5):EndIf 
  If KeyboardPushed(#PB_Key_Down) :S3DR_MoveCamera(0,0,-0.5):EndIf

  
  S3DR_EndReal3D()
  Stop3D()
  
  FlipBuffers()  :Delay(16)
  
Until KeyboardPushed(#PB_Key_Escape)

S3DR_FreeMesh(Cube); Don't forget to free the Mesh.

CloseScreen()
just run this code, move horizontally your mouse and see.
Now replace
S3DR_DrawMesh(Cube,0,0,0,angleY.f,angleX.f,angleZ.f,1,1,1)
by
S3DR_DrawMesh(Cube,0,0,0,angleY.f,angleX.f,angleZ.f)
and move horizontally again your mouse (for last time onto that mousepad) and see. Can you see the difference? :twisted:

Posted: Sun Jun 05, 2005 4:12 pm
by Psychophanta
NOTE:
don't get wrong: The cube must be moved just like it moves using
S3DR_DrawMesh(Cube,0,0,0,angleY.f,angleX.f,angleZ.f)
This is the way how it must be.
I swapped anglex and angley intentionally to move figure over x axis when move mouse vertically, and move figure over Y axis when moving mouse horizontally.

Posted: Sun Jun 05, 2005 4:52 pm
by S.M.
@Psychophanta
Hey, that doesn't count. You already found this bug.
And you should read more carefully. :lol: :twisted:
Can you test it again ?
http://hometown.aol.de/MoebiusStefan/S3DR_Library.zip

regards
Stefan

Posted: Sun Jun 05, 2005 6:00 pm
by Psychophanta
S.M. wrote:And you should read more carefully. :lol: :twisted:
hey!!! fake man! you have modified it :P :twisted:

BTW, i use to eat ON my desktop :P
Well, well,
Tested,
result: all ok :wink:
Congratulations, because you must know that with this new feature there is posible to get easely objects deformations. :)

But there could be another problem (which is converted in a request, not sure):
Look at the syntax:
S3DR_DrawMesh(Mesh,X.f,Y.f,Z.f,RotateX.f,RotateY.f,RotateZ.f[,ScaleX.f,ScaleY.f,ScaleZ.f])
The parameters RotateX.f,RotateY.f,RotateZ.f are referred to the X, Y and Z axis from the mesh (i mean the mesh is rotated over its own axis, not over outside world axis), but ScaleX.f,ScaleY.f,ScaleZ.f are being referred to the general X, Y and Z axis of the outside world where the mesh is in, so then this means that ScaleX.f,ScaleY.f,ScaleZ.f are not supposed to be deformation parameters of the mesh in itself but depending on its position on the world, it is crushed in world x axis (ScaleX.f), world y axis (ScaleY.f) or world z axis (ScaleZ.f).
In short: besides of this, i miss ability to scale (stretch) it over its own axis, and ability to rotate it over the world axis.
I know it can be done with some operations, but it is a hard work to do it everytime.

Posted: Sun Jun 05, 2005 6:44 pm
by Psychophanta
@Stefan
I've discovered a bug
RotateZ.f behaviour is different than RotateX.f and RotateY.f one.
Indeed RotateX.f and RotateY.f are referred to outside world, while RotateZ.f is referred to the Z axis from the mesh.
If you want to get a demonstration of this fact, just ask me for it.

Posted: Mon Jun 06, 2005 12:29 pm
by S.M.
@Psychophanta
Psychophanta wrote: hey!!! fake man! you have modified it
You're to clever to be lead behind the light.Image
Psychophanta wrote:I've discovered a bug
RotateZ.f behaviour is different than RotateX.f and RotateY.f one.
Indeed RotateX.f and RotateY.f are referred to outside world, while RotateZ.f is referred to the Z axis from the mesh.
If you want to get a demonstration of this fact, just ask me for it.
A demonstration would be great.
regards
Stefan

Posted: Mon Jun 06, 2005 1:03 pm
by Psychophanta
Choose a texture and run this:

Code: Select all

InitSprite()
InitSprite3D()
InitKeyboard()
InitMouse()
OpenScreen(1024,768,32,"Rotating Cube")

S3DR_CreateZBuffer()
DataSection
sprite1:IncludeBinary "yourtexturehere"
EndDataSection
UsePNGImageDecoder()
CatchSprite(1,?sprite1,#PB_Sprite_Texture)
TransparentSpriteColor(1,255,0,255)
Start3D()
S3DR_BeginReal3D()
S3DR_MoveCamera(0,0,-5)

;Create the cube
S3DR_StartCreateMesh()
S3DR_CreateMesh_AddQuad(-1, 1, 1,-1, 1,-1,-1,-1, 1,-1,-1,-1);<-cara izquierda
S3DR_CreateMesh_AddQuad( 1,-1, 1,-1,-1, 1, 1,-1,-1,-1,-1,-1);<-cara de abajo
S3DR_CreateMesh_AddQuad(-1, 1, 1, 1, 1, 1,-1, 1,-1, 1, 1,-1);<-cara de arriba
S3DR_CreateMesh_AddQuad(1,1,1,-1,1,1,1,-1,1,-1,-1,1);<-cara de atras
S3DR_CreateMesh_AddQuad(-1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1);<-cara de enfrente
S3DR_CreateMesh_AddQuad( 1, 1,-1, 1, 1, 1, 1,-1,-1, 1,-1, 1);<-cara derecha
Cube=S3DR_StopCreateMesh()


S3DR_EndReal3D()

Sprite3DQuality(1)
Stop3D()

Repeat
  ExamineKeyboard()
  ExamineMouse()
  
  Start3D()
  S3DR_BeginReal3D()
  S3DR_ClearScreenAndZBuffer($000000)
  
  ;Draw the cube
  S3DR_SelectTexture(1)
            ;*********************************************************  
;            If MouseButton(1):angleX.f+0.02:EndIf;    <- rotate over X axis
;              angleY.f-MouseDeltaX()/500:angleZ.f-MouseDeltaY()/500
            ;*********************************************************  
;              If MouseButton(1):angleY.f+0.02:EndIf;    <- rotate over Y axis
;              angleZ.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
            ;*********************************************************  
            If MouseButton(1):angleZ.f+0.02:EndIf;    <- rotate over Z axis
              angleY.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
            ;*********************************************************  
  If KeyboardPushed(#PB_Key_X):xs.f=0.5:Else:xs.f=1:EndIf
  If KeyboardPushed(#PB_Key_Y):ys.f=0.5:Else:ys.f=1:EndIf
  If KeyboardPushed(#PB_Key_Z):zs.f=0.5:Else:zs.f=1:EndIf
    
  S3DR_DrawMesh(Cube,0,0,0,angleX.f,angleY.f,angleZ.f,xs.f,ys.f,zs.f)

  If KeyboardPushed(#PB_Key_Left) :S3DR_RotateCamera(-0.025,0,0):EndIf
  If KeyboardPushed(#PB_Key_Right):S3DR_RotateCamera(0.025,0,0):EndIf
  If KeyboardPushed(#PB_Key_Up)   :S3DR_MoveCamera(0,0,0.5):EndIf 
  If KeyboardPushed(#PB_Key_Down) :S3DR_MoveCamera(0,0,-0.5):EndIf
  
  S3DR_EndReal3D()
  Stop3D()
  
  FlipBuffers()  :Delay(16)
  
Until KeyboardPushed(#PB_Key_Escape)

S3DR_FreeMesh(Cube); Don't forget to free the Mesh.

CloseScreen()
You will see that when you push left button on the mouse, the mesh rotates over ITS OWN Z axis and ALWAYS there will be 2 of the cube faces that ONLY rotate IN ITS PLANE, even you move the cobe using mouse, when pushing button, the mesh rotate always in the same axis.
Now replace:

Code: Select all

            ;*********************************************************  
;            If MouseButton(1):angleX.f+0.02:EndIf;    <- rotate over X axis
;              angleY.f-MouseDeltaX()/500:angleZ.f-MouseDeltaY()/500
            ;*********************************************************  
;              If MouseButton(1):angleY.f+0.02:EndIf;    <- rotate over Y axis
;              angleZ.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
            ;*********************************************************  
            If MouseButton(1):angleZ.f+0.02:EndIf;    <- rotate over Z axis
              angleY.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
            ;*********************************************************  
by

Code: Select all

            ;*********************************************************  
            If MouseButton(1):angleX.f+0.02:EndIf;    <- rotate over X axis
              angleY.f-MouseDeltaX()/500:angleZ.f-MouseDeltaY()/500
            ;*********************************************************  
;              If MouseButton(1):angleY.f+0.02:EndIf;    <- rotate over Y axis
;              angleZ.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
            ;*********************************************************  
;            If MouseButton(1):angleZ.f+0.02:EndIf;    <- rotate over Z axis
;              angleY.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
            ;*********************************************************  
and see.
Then by:

Code: Select all

            ;*********************************************************  
;            If MouseButton(1):angleX.f+0.02:EndIf;    <- rotate over X axis
;              angleY.f-MouseDeltaX()/500:angleZ.f-MouseDeltaY()/500
            ;*********************************************************  
            If MouseButton(1):angleY.f+0.02:EndIf;    <- rotate over Y axis
              angleZ.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
            ;*********************************************************  
;            If MouseButton(1):angleZ.f+0.02:EndIf;    <- rotate over Z axis
;              angleY.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
            ;*********************************************************  
In short: With this 2 last cases, the behaviour is that the mesh rotate over the WORLD AXIS (and over a merged weird axis in the case of Y) when pushing mouse. But in the first case the mesh rotates over its OWN Z AXIS.

Posted: Mon Jun 06, 2005 2:35 pm
by Psychophanta
Stefan,
you can see it much better with this: (no needed to load external textures)
(use mouse left button to rotate over the selected axis)
(Select X, Y, or Z axis using right mouse button):

Code: Select all

If InitMouse()=0 Or InitSprite()=0 Or InitSprite3D()=0 Or InitKeyboard()=0 
  MessageRequester("Error","Can't access DirectX",0):End 
EndIf 
OpenScreen(1024,768,32,"Sistema de coordenadas ortogonales cartesianas")

CreateSprite(1,512,512,#PB_Sprite_Texture) 
StartDrawing(SpriteOutput(1)):BackColor(0,0,0) 
Line(Int(512/2),0,0,511,$AAAAAA)
Line(Int(512/2-1),0,0,511,$AAAAAA) 
Line(0,Int(512/2),511,0,$AAAAAA)
Line(0,Int(512/2-1),511,0,$AAAAAA) 
StopDrawing() 

S3DR_CreateZBuffer() 

Start3D() 
S3DR_BeginReal3D() 
S3DR_MoveCamera(0,0,-4)

S3DR_UseTransparency(#S3DR_TRUE) 
S3DR_SetCullMode(#S3DR_NONE) 
;Create the system: 
S3DR_StartCreateMesh() 
S3DR_CreateMesh_AddQuad(-1,1,0,1,1,0,-1,-1,0,1,-1,0);<- Plano xy (plano atravesado ortogonalmente por el eje z) 
S3DR_CreateMesh_AddQuad(1,1,0,-1,1,0,1,-1,0,-1,-1,0);<- Plano xy visto por detrás 
S3DR_CreateMesh_AddQuad(-1,0,1,1,0,1,-1,0,-1,1,0,-1);<- Plano xz (plano atravesado ortogonalmente por el eje y) 
S3DR_CreateMesh_AddQuad(1,0,1,-1,0,1,1,0,-1,-1,0,-1);<- Plano xz visto por detrás 
S3DR_CreateMesh_AddQuad(0,1,1,0,1,-1,0,-1,1,0,-1,-1);<- Plano yz (plano atravesado ortogonalmente por el eje x) 
S3DR_CreateMesh_AddQuad(0,1,-1,0,1,1,0,-1,-1,0,-1,1);<- Plano yz visto por detrás
sys.l=S3DR_StopCreateMesh()

S3DR_EndReal3D()
Stop3D()

Sprite3DQuality(1)
axis.b=1
;-MAIN:
Repeat
  ExamineKeyboard()
  ExamineMouse()
  
  Start3D()
  S3DR_BeginReal3D()
  S3DR_ClearScreenAndZBuffer($000000)
  
  S3DR_UseTransparency(#S3DR_TRUE)
  S3DR_SetCullMode(#S3DR_NONE)

  S3DR_SelectTexture(1)
  If MouseButton(2)
    While MouseButton(2):Delay(20):ExamineMouse():Wend
    axis.b+1:If axis.b>=4:axis.b=1:EndIf
  EndIf
  StartDrawing(ScreenOutput()):Locate(0,0):DrawText(Chr($57+axis.b)+" axis"):StopDrawing()  
  StartDrawing(ScreenOutput()):Locate(0,0)
  Select axis.b
  Case 1
            If MouseButton(1):DrawText("Now rotating over X axis"):angleX.f+0.02:EndIf; <- rotate over X axis of the world ?
              angleY.f-MouseDeltaX()/500:angleZ.f-MouseDeltaY()/500
  Case 2
            If MouseButton(1):DrawText("Now rotating over Y axis"):angleY.f+0.02:EndIf; <- rotate over Y axis  of the world ?
              angleZ.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
  Case 3
            If MouseButton(1):DrawText("Now rotating over Z axis"):angleZ.f+0.02:EndIf; <- rotate over Z axis of the world ?
              angleY.f-MouseDeltaX()/500:angleX.f-MouseDeltaY()/500
  EndSelect
   StopDrawing()
   S3DR_DrawMesh(sys.l,0,0,0,angleX,angleY,angleZ);,1,1,1)

  If KeyboardPushed(#PB_Key_R):angleX=0:angleY=0:angleZ=0:EndIf
  
  If KeyboardPushed(#PB_Key_Up)  :S3DR_MoveCamera(0,0,0.04):EndIf
  If KeyboardPushed(#PB_Key_Down):S3DR_MoveCamera(0,0,-0.04):EndIf
  
  S3DR_EndReal3D() 
  Stop3D() 
  
  FlipBuffers():Delay(16) 
  
Until KeyboardPushed(#PB_Key_Escape) 

S3DR_FreeMesh(sys.l); Don't forget to free the Mesh. 
CloseScreen()
Note that when rotating over Z axis the Z axis OF THE MESH doesn't move, only rotates over itself. But when rotating over X axis or Y axis things are different.
Do you see?

Posted: Tue Jun 07, 2005 5:48 pm
by S.M.
Yes I see...
The rotation over the Z-axis is the only which is correct, right ?
Thanks for your really good demonstration.(I wouldn't find out this in 10 years)
But I don't know yet how to fix this, because I just feed the 3D-Device
like some functions from the Direct3DX utility library do.
I will look for something else... :roll:

Thanks again Image
regards
Stefan

Posted: Tue Jun 07, 2005 8:55 pm
by Psychophanta
S.M. wrote:Thanks again Image
Ohhh! more thanx to you who are the maker :wink:
S.M. wrote:Yes I see...
The rotation over the Z-axisis the only which is correct, right ?
Yes,
Rotation over Z-axis is the only which is correct respect the two others, but please listen a moment before do anything:
I don't know how D3D do things, but look:
When a space-time (well lets treat 3D space simply) based world is out there, there is usually treated as a system with cartesian ortogonal X, Y and Z coordinates, ok? That's the reason why you use X.f,Y.f and Z.f for coordenates for cameras, textures, meshes, etc.
Well, then we are talking about the X,Y anz Z referred to the whole world.
But pleaaassse keep in mind carefully: each mesh (or item, or entity, or whatever you want to call) into a "world" have its own X,Y and Z, this is; its own reference system. <- this means that if you consider that "the rotation over the Z-axisis the only which is correct" then you are considering the mesh reference system, but not the "world" reference system, so then, be carefully when treat ScaleX.f, ScaleY.f and ScaleZ.f.
In short, all this means that: if you consider the MESH REFERENCE SYSTEM then be consistent, and consider it for ALL its properties of inclination (angle) and scaling (i.e. consider same reference for AngleX.f, AngleY.f, AngleZ.f, ScaleX.f, ScaleY.f and ScaleZ.f). And: if you consider the WORLD REFERENCE SYSTEM then be consistent, and consider it for ALL its properties of inclination (angle) and scaling (i.e. consider same reference for AngleX.f, AngleY.f, AngleZ.f, ScaleX.f, ScaleY.f and ScaleZ.f)

The current situation now is that ScaleX.f, ScaleY.f and ScaleZ.f are being referred to the WORLD REFERENCE SYSTEM, but AngleZ.f is being referred to the MESH REFERENCE SYSTEM :!: