It is currently Mon Apr 06, 2020 10:43 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: 3D Coordinate System
PostPosted: Tue Dec 22, 2015 11:44 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Aug 19, 2003 11:36 am
Posts: 1418
Location: Doubs - France
using mesh manual should work on all system
Code:
#CameraSpeed = 1

IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

Macro CreateLine3D_(No, x1, y1, z1, Color1, x2, y2, z2, Color2)
   CreateMesh(No, #PB_Mesh_LineList, #PB_Mesh_Static)
   MeshVertexPosition(x1, y1, z1)
   MeshVertexColor(Color1)
   MeshVertexPosition(x2, y2, z2)
   MeshVertexColor(Color2)

   FinishMesh(#False)
   
   SetMeshMaterial(No, MaterialID(1))
   AttachNodeObject(Node, MeshID(No))
EndMacro

If InitEngine3D()
   
  InitSprite()
  InitKeyboard()
  InitMouse()
   
  If Screen3DRequester()
   
    Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
    Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Models"  , #PB_3DArchive_FileSystem)
   
    LoadMesh(10, "axes.mesh")
    CreateMaterial(0, LoadTexture(0, "axes.png"))
    CreateEntity(0, MeshID(10), MaterialID(0))
    ScaleEntity(0, 0.1, 0.1 ,0.1)
   
     ;- Material
     CreateMaterial(1, LoadTexture(0, "White.jpg"))
     DisableMaterialLighting(1, #True)
    ; Line3D
    ;
    Node = CreateNode(#PB_Any)
    CreateLine3D_(0, 0, 0, 0, RGB(255,   0,   0), 10,  0,  0, RGB(255,   0,   0))  ; Axis X
    CreateLine3D_(1, 0, 0, 0, RGB(  0, 255,   0),  0, 10,  0, RGB(  0, 255,   0))  ; Axis Y
    CreateLine3D_(2, 0, 0, 0, RGB(  0,   0, 255),  0,  0, 10, RGB(  0,   0, 255))  ; Axis Z
       
    ; Camera
    ;
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 1, 1, 5, #PB_Absolute)
    CameraLookAt(0, 0, 0, 0)
   
     ;-Light
     CreateLight(0, RGB(255,255,255), -10, 60, 10)
     AmbientColor(RGB(90, 90, 90))
   
    Repeat
      Screen3DEvents()
     
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
     
      If ExamineKeyboard()
     
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
       
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf
       
      EndIf
       
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
     
      RenderWorld()
      Screen3DStats()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
   
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
 
End

_________________
Please correct my english
http://purebasic.developpez.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: 3D Coordinate System
PostPosted: Wed Dec 23, 2015 11:39 pm 
Offline
User
User

Joined: Mon Dec 21, 2015 7:43 pm
Posts: 16
Thank you all for sending your codes/comments.
What I am concerned about is the right-handed sense of the coordinate system not really the color. If you consider a vector multiplication like u x v = w where u is the unit vector along x and v is the unit vector along y then the product w must be along z axis. However in this coordinate system this would appear in the reverse direction and this can mess up all my calculations for visualization. So, for now I have to switch to Windows until this is corrected.


Top
 Profile  
Reply with quote  
 Post subject: Re: 3D Coordinate System
PostPosted: Thu Dec 24, 2015 6:48 am 
Offline
Addict
Addict
User avatar

Joined: Tue Aug 19, 2003 11:36 am
Posts: 1418
Location: Doubs - France
S.T. wrote:
If you consider a vector multiplication like u x v = w where u is the unit vector along x and v is the unit vector along y then the product w must be along z axis. However in this coordinate system this would appear in the reverse direction and this can mess up all my calculations for visualization. So, for now I have to switch to Windows until this is corrected.


There was a problem with the CreateLine3D"s color which is corrected with the 5.41 release.
OGRE uses a right-handed coordinate system.on Windows/Linux and MacOS X, so your vector will be the same on all system. If not, just show an example.

About the cross-Product Ogre doc say :
Quote:
As For which side the resultant vector will be on, the returned vector will be on the side from which the arc from 'this' To rkVector is anticlockwise,
e.g. UNIT_Y.crossProduct(UNIT_Z) = UNIT_X, whilst UNIT_Z.crossProduct(UNIT_Y) = -UNIT_X.

This is because OGRE uses a right-handed coordinate system.

_________________
Please correct my english
http://purebasic.developpez.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: 3D Coordinate System
PostPosted: Fri Dec 25, 2015 10:01 pm 
Offline
User
User

Joined: Mon Dec 21, 2015 7:43 pm
Posts: 16
This is fixed in version 5.41
Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: 3D Coordinate System
PostPosted: Tue Mar 24, 2020 12:55 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6099
Location: Wales, UK
I know this is an old debate and "fixed", but the current system for the OpenGL gadget is different to that used in manufacturing industry, so it would be great if PB could allow us to set our own World Ordinate System and not have to translate from a fixed, pre-defined system.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: 3D Coordinate System
PostPosted: Tue Mar 24, 2020 8:32 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 29, 2012 10:33 pm
Posts: 750
Location: United States
That's going into the shader territory. The opengl gadget is just a quicker way to create an opengl context. It doesn't limit you to a specific coordinate system. What will limit you is using opengl's old fixed function pipeline which was right handed(If i remember correctly). Go a little more modern and you create your own matrices and control what they are applied to. That will allow you to choose which handed system you want.
This also applies to DirectX.


Top
 Profile  
Reply with quote  
 Post subject: Re: 3D Coordinate System
PostPosted: Fri Mar 27, 2020 12:12 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6099
Location: Wales, UK
Hi Samuel

Well, yes - I could buy a car with square wheels, make my own round wheels and then fit them, but if I could choose the wheels I wanted, without making my own, that would be better. I think it's a valid wish :mrgreen:

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: 3D Coordinate System
PostPosted: Fri Mar 27, 2020 5:19 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 29, 2012 10:33 pm
Posts: 750
Location: United States
Sure you could buy your own tires and it would save you headache and time. In this case though you're not buying tires, you're asking for them.
And what you are asking for are 3D engine functions, which is what PB/Ogre is intended for. There's very little reason for them to develop another engine that's included with Purebasic.


Top
 Profile  
Reply with quote  
 Post subject: Re: 3D Coordinate System
PostPosted: Fri Mar 27, 2020 9:52 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6099
Location: Wales, UK
.... Not using the 3D Engine, using OpenGL in the OpenGL Gadget. All I'm saying is, instead of only the default World Ordinates system delivered preset, give the developer a choice.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: 3D Coordinate System
PostPosted: Sat Mar 28, 2020 12:35 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 29, 2012 10:33 pm
Posts: 750
Location: United States
As I said in a previous post, that preset is because you are using the fixed function pipeline. You will have a choice if you use more modern OpenGL.
Having the team build a 3D engine based around the OpenGL gadget when they already have a functioning 3D engine(Ogre) is pointless.

If you really want it then put the request in the Feature Requests and Wishlists. They'll decide for us.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye