#!/bin/env python

# Automatically translated python version of 
# OpenSceneGraph example program "osgautotransform"
# !!! This program will need manual tuning before it will work. !!!

import sys

from osgpypp import osg
from osgpypp import osgDB
from osgpypp import osgText
from osgpypp import osgUtil
from osgpypp import osgViewer


# Translated from file 'osgautotransform.cpp'

# OpenSceneGraph example, osgautotransform.
#*
#*  Permission is hereby granted, free of charge, to any person obtaining a copy
#*  of this software and associated documentation files (the "Software"), to deal
#*  in the Software without restriction, including without limitation the rights
#*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#*  copies of the Software, and to permit persons to whom the Software is
#*  furnished to do so, subject to the following conditions:
#*
#*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#*  THE SOFTWARE.
#

#include <osgUtil/Optimizer>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>

#include <osg/Material>
#include <osg/Geode>
#include <osg/BlendFunc>
#include <osg/Depth>
#include <osg/Projection>
#include <osg/AutoTransform>
#include <osg/Geometry>

#include <osgDB/WriteFile>

#include <osgText/Text>

#include <iostream>

def createLabel(pos, size, label, axisAlignment):

    
    geode = osg.Geode()

    timesFont = str("fonts/arial.ttf")

        text = osgText.Text()
        geode.addDrawable( text )

        text.setFont(timesFont)
        text.setPosition(pos)
        text.setCharacterSize(size)
        text.setAxisAlignment(axisAlignment)
        text.setAlignment(osgText.Text.CENTER_CENTER)
        text.setText(label)


    return geode


def createLabel3(pos, size, label):


    
    geode = osg.Geode()

    timesFont = str("fonts/arial.ttf")

        text = osgText.Text()
        geode.addDrawable( text )

        text.setFont(timesFont)
        text.setPosition(pos)
        text.setFontResolution(40,40)
        text.setCharacterSize(size)
        text.setAlignment(osgText.Text.CENTER_CENTER)
        text.setAutoRotateToScreen(True)
        text.setCharacterSizeMode(osgText.Text.OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT)
        text.setText(label)


    return geode

def createAxis(s, e, numReps, autoRotateMode, axisAlignment, str):

    
    group = osg.Group()

    dv = e-s
    dv /= float(numReps-1)

    pos = s

    useAuto = True
    if useAuto :
        vertices = osg.Vec3Array()

        for(int i=0i<numReps++i)
            at = osg.AutoTransform()
            at.setPosition(pos)
            at.setAutoRotateMode(autoRotateMode)
            at.addChild(createLabel(osg.Vec3(0.0,0.0,0.0),dv.length()*0.2,str, axisAlignment))