Author Topic: X_screen2world and X_world2_Screen  (Read 1687 times)

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3375
  • Integrated Brain
    • View Profile
X_screen2world and X_world2_Screen
« on: 2011-Aug-18 »
Hi I try this 2 commands in the last update, but don´t works, fine.

Code: (glbasic) [Select]
X_LOADOBJ "Media/Box344.ddd", 1

WHILE TRUE



INC a



X_MAKE3D 1,10000,45

X_CAMERA 0,0,-100, 0,0,0
X_WORLD2SCREEN 100+(100*COS(a)), 100+(100*SIN(a)), wz#, sx, sy, sz#

X_MOVEMENT sx,sy,1200
X_DRAWOBJ 1,0

X_MAKE2D
PRINT "*",100+(100*COS(a)),100+(100*SIN(a))

SHOWSCREEN
WEND

On PC, runs perfectly, in Android not,  I have to try in Palm Pre and iPhone. ()

Notice: About this command, you can make it whit a simple rules of 3, but well, I think this it´s a fudge what I made it!!!.  :-[ :-[

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10817
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: X_screen2world and X_world2_Screen
« Reply #1 on: 2011-Aug-18 »
Code: (glbasic) [Select]
// --------------------------------- //
// Project: LR
// Start: Thursday, August 11, 2011
// IDE Version: 10.057


// SETCURRENTDIR("Media") // go to media files

CreateCube(1, 20, RGB(0, 0, 255))

// X_LOADOBJ "Media/Box344.ddd", 1
LOCAL a, sx,sy,sz, wx, wy, wz

WHILE TRUE
INC a

X_MAKE3D 1,10000,45

X_CAMERA 0,0,-100, 0,0,0
X_SCREEN2WORLD 100+(100*COS(a)), 100+(100*SIN(a)), 0, sx, sy, sz#

X_MOVEMENT sx,sy,sz
X_SCALING 0.01, 0.01, 0.01
X_DRAWOBJ 1,0

X_MAKE2D
PRINT "*",100+(100*COS(a)),100+(100*SIN(a))

SHOWSCREEN
WEND


FUNCTION CreateCube: num, sz, col
X_AUTONORMALS 1
sz = sz / 2

X_OBJSTART num
// Front Face
X_OBJADDVERTEX  sz, -sz,  sz, 1, 0, col
X_OBJADDVERTEX -sz, -sz,  sz, 0, 0, col
X_OBJADDVERTEX  sz,  sz,  sz, 1, 1, col
X_OBJADDVERTEX -sz,  sz,  sz, 0, 1, col
X_OBJNEWGROUP
// Back Face
X_OBJADDVERTEX -sz,  sz, -sz, 1, 1, col
X_OBJADDVERTEX -sz, -sz, -sz, 1, 0, col
X_OBJADDVERTEX  sz,  sz, -sz, 0, 1, col
X_OBJADDVERTEX  sz, -sz, -sz, 0, 0, col
X_OBJNEWGROUP
// Top Face
X_OBJADDVERTEX -sz,  sz,  sz, 0, 0, col
X_OBJADDVERTEX -sz,  sz, -sz, 0, 1, col
X_OBJADDVERTEX  sz,  sz,  sz, 1, 0, col
X_OBJADDVERTEX  sz,  sz, -sz, 1, 1, col
X_OBJNEWGROUP
// Bottom Face
X_OBJADDVERTEX  sz, -sz, -sz, 0, 1, col
X_OBJADDVERTEX -sz, -sz, -sz, 1, 1, col
X_OBJADDVERTEX  sz, -sz,  sz, 0, 0, col
X_OBJADDVERTEX -sz, -sz,  sz, 1, 0, col
X_OBJNEWGROUP
// Right face
X_OBJADDVERTEX  sz,  sz, -sz, 1, 1, col
X_OBJADDVERTEX  sz, -sz, -sz, 1, 0, col
X_OBJADDVERTEX  sz,  sz,  sz, 0, 1, col
X_OBJADDVERTEX  sz, -sz,  sz, 0, 0, col
X_OBJNEWGROUP
// Left Face
X_OBJADDVERTEX -sz, -sz,  sz, 1, 0, col
X_OBJADDVERTEX -sz, -sz, -sz, 0, 0, col
X_OBJADDVERTEX -sz,  sz,  sz, 1, 1, col
X_OBJADDVERTEX -sz,  sz, -sz, 0, 1, col
X_OBJNEWGROUP
X_OBJEND
ENDFUNCTION

You want the 2D coords of the PRINT and move the 3D object to that position. Thus, X_SCREEN2WORLD - not the other way round.


Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3375
  • Integrated Brain
    • View Profile
Re: X_screen2world and X_world2_Screen
« Reply #2 on: 2011-Aug-18 »
Thanks Gernnot, but for me your code not works too  :'( :'(

Perhaps it´s my device, but the blue Cube don´t move, a thing... I look strange is the size of the cube, in Windows it´s a good Cube, a greater Cube, but in Android it´s very, very small. This it´s only whit the cube code created, the .ddd exported from 3ds MAX, it´s the same size in Windows and Android.

How I sayed I have to try in another platforms, it´s strange the trobles whit this command, becuase are only Maths, not?¿, not is nothing specific of C++.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10817
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: X_screen2world and X_world2_Screen
« Reply #3 on: 2011-Aug-18 »
Yes, I removed all OpenGL dependencies and the X_WORLD/SCREEN commands are just plain math now.