Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Vector3 (first attempt) — Gideros Forum

Vector3 (first attempt)

dr_maxdr_max Member
edited September 2013 in General questions
Hello
I'm a beginner in Gideros. my first attempt at writing.
your comments?

Likes: SinisterSoft

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • While functionally it seems to be completely ok (although I currently can't remember the case where vec3 would be needed in Gideros, but I don't exclude the possibility that it might)
    but you are not utilizing the power of Gideros provided OOP approach.

    While you do it right in the constructor, assigning x,y and z to the self as instance properties, you then go completely other way around and plugin your own method through metatable and do not reuse the self instance properties at all.

    It could all be as easy as:
    Vector3 = Core.class()
     
    function Vector3:init(x, y, z)
    	self.x = x
    	self.y = y
    	self.z = z
    end
     
    function Vector3:toString()
    	return self.x .. "," .. self.y .. "," .. self.z
    end
     
    function Vector3:add(b)
    	if type(b) == "number" then
    		self.x = self.x + b
    		self.y = self.y + b
    		self.z = self.z + b
    	else
    		self.x = self.x + b.x
    		self.y = self.y + b.y
    		self.z = self.z + b.z
    	end
    end
     
    function Vector3:getLenght()
    	return math.sqrt(self.x*self.x + self.y*self.y + self.z*self.z)
    end
     
    --etc
    But thats just my suggestion. Cheers ;)
  • Thank you!
    3D vectors want to use in a small engine, rotation of a 3D shape. as flash old technology (flash7). Again, I am new, gideros saw 3 days ago) and Lua is also seen. mainly programmed in flash.soon I'll show 3D shape )

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • Oh, I forgot gideros chose to porting games:
    http://www.globalcorp.org.ru/img/magicdrugs.jpg

    but for some reason became interested in 3D :)
  • I'm really interested in this, Vector3 would be really useful and should be native imho, especially for v2 of Gideros.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Yes, I agree! vecor2&3 should be native) soon I'll show 3D shape with environment maping. Although to start make flat shading)

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.