Local axes of an entity in Polycode

  1. last year
    Edited last year by MNetoNX

    Hello.

    What is the orientation of the axes of a primitive in Polycode?

    I am still exploring the API using Lua, and I'm having difficulty making a cone following a ball. I would like the top of the cone pointed to the ball.

    Following the code I'm using:

    scene = Scene(Scene.SCENE_3D)
    PrimaryEntity = SceneEntityInstance(scene, "Resources/Primary.entity")
    scene:addEntity(PrimaryEntity)
    
    scene:getDefaultCamera():setPosition(7,7,7)
    scene:getDefaultCamera():lookAt(Vector3(0,0,0), Vector3(0,1,0))
    
    -- Cone
    cone = ScenePrimitive(ScenePrimitive.TYPE_CONE, 1.5, 0.5, 100)
    cone:setPosition(-2, 1, -2)
    cone:setColor(116/255, 239/255, 255/255, 1.0)
    scene:addChild(cone)
    
    -- Plane
    plane = ScenePrimitive(ScenePrimitive.TYPE_PLANE, 10,10)
    plane:setPosition(0,-0.5,0)
    plane:setColor(40/255, 216/255, 122/255, 1.0)
    scene:addChild(plane)
    
    -- Sphere
    origin = ScenePrimitive(ScenePrimitive.TYPE_SPHERE, 0.1, 10, 10)
    origin:setPosition(0,0,0)
    origin:setColorInt(255, 0, 0, 255)
    scene:addChild(origin)
    
    ---------------------------------------------------------------
    function onTimer(t, event)
      origin:setPositionX(origin:getPosition().x + 0.2)
      cone:lookAtEntity(origin, Vector3(0,1,0))
    end
    
    chronometer = Timer(true, 400)
    
    chronometer:addEventListener(nil, onTimer, Timer.EVENT_TRIGGER)
    ---------------------------------------------------------------

    I tried using various combinations for up vector (0, -1.0), (0,1,0), (1,1,0), etc., but neither does the cone effectively follow the ball.

    1. Is there a way to display the axes of an entity in Polycode?
    2. What are the directions of the axes of the entities in Polycode?
 

or Sign Up to reply!