Horde3D

Next-Generation Graphics Engine
It is currently 24.11.2024, 21:30

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: 29.03.2010, 11:47 
Offline

Joined: 25.03.2010, 03:58
Posts: 13
I modified app.py blows.
def init(self):
...
self.ft = font.load('Arial', 28)
self.fps_text = font.Text(self.ft, y=10)

def mainloop(self):
...
self.fps_text.text = "dddd"
self.fps_text.draw()

w.flip()
h3d.finalizeFrame()

but nothing else happens.
what is wrong??


Last edited by sellee on 05.04.2010, 00:43, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: 29.03.2010, 14:17 
Offline

Joined: 14.04.2008, 15:06
Posts: 183
Location: Germany
Why don't you use h3d.utils.showText?

pyglet.font.Text is deprecated. Try pyglet.text.Label. Also make sure the font file was really found. Does a minimal pyglet program work, that is without Horde3D? All raw OpenGL calls must be done after the h3d.finalizeFrame and before w.flip calls.

Looking at that code the order of w.flip and h3d.finalizeFrame must be changed. I'm wondering how that worked so good... Anyway now it's fixed in the community repository.


Top
 Profile  
Reply with quote  
PostPosted: 30.03.2010, 01:21 
Offline

Joined: 25.03.2010, 03:58
Posts: 13
yes. i tried to use pyglet.text.Label , result dosent shown.
but basic font,Lable works fine.

I want to show 2byte chracters( 가나다... as like hangul, hirakana, kanji).
and pyglet.font is easy to use.

I glanced http://www.horde3d.org/forums/viewtopic.php?f=6&t=750&hilit=BMFont.
but that tool genete paged texture, I dont know how to use it.


Top
 Profile  
Reply with quote  
PostPosted: 30.03.2010, 07:33 
Offline

Joined: 25.03.2010, 03:58
Posts: 13
I succeed to show mutibyte chracter.
the answer is http://www.horde3d.org/forums/viewtopic.php?f=1&t=1027&hilit=primitives.
Code:
from euclid import Matrix4

self.label = pyglet.text.Label(u'한글Hello, world',
  font_name='Gulim', # Gulim font is korean (unicode)
  font_size=20, x=200, y=200,
  anchor_x='left', anchor_y='center')

def mainloop(self):
    self.domy()
    w.flip()
  h3d.finalizeFrame()

def domy(self):
   for w in self._windows:
      camNode = w.camera

   projMat = h3d.getCameraProjMat(camNode)
   glMatrixMode( GL_PROJECTION )
   glLoadMatrixf((GLfloat * 16)(*projMat))
   
   glPushMatrix()
   glLoadIdentity
   glOrtho(0,640,0,480,0,1)
   glDisable(GL_DEPTH_TEST)
   self.label.draw()
   glPopMatrix()

   glMatrixMode( GL_MODELVIEW )
   glLoadIdentity
   glEnable(GL_DEPTH_TEST)
   camera = h3d.getNodeTransMats(camNode)
   camM = Matrix4()
   camM[:]=camera[1][:]
   glLoadMatrixf((GLfloat * 16)(*camM.inverse()[:]))
      
   a=h3d.getNodeAABB(self._knight)
   [minX, minY, minZ], [maxX, maxY, maxZ] = a[0],a[1]
   glColor3f(1.0, 1.0, 1.0)
   glBegin(GL_LINE_STRIP)
   glVertex3f(minX, minY, minZ)
   glVertex3f(maxX, minY, minZ)
   glVertex3f(maxX, maxY, minZ)
   glVertex3f(minX, maxY, minZ)
   glVertex3f(minX, minY, minZ)
   glVertex3f(minX, minY, maxZ)
   glVertex3f(maxX, minY, maxZ)
   glVertex3f(maxX, maxY, maxZ)
   glVertex3f(minX, maxY, maxZ)
   glVertex3f(minX, minY, maxZ)
   glEnd()
   glBegin(GL_LINES)
   glVertex3f(minX, maxY, minZ)
   glVertex3f(minX, maxY, maxZ)
   glVertex3f(maxX, minY, minZ)
   glVertex3f(maxX, minY, maxZ)
   glVertex3f(maxX, maxY, minZ)
   glVertex3f(maxX, maxY, maxZ)
   glEnd()
   
   pos = h3d.getNodeTransform(self._knight)
   glColor3f(1.0, 0.0, 1.0)
   glBegin(GL_LINES)
   glVertex3f(pos[0][0],pos[0][1],pos[0][2])
   glVertex3f(pos[0][0],pos[0][1]-10,pos[0][2])
   glEnd()

Attachment:
File comment: hangul is ok
hangul.PNG
hangul.PNG [ 80.15 KiB | Viewed 13592 times ]

but it has problem.
Attachment:
File comment: invisible
hangul_invisi.PNG
hangul_invisi.PNG [ 101.31 KiB | Viewed 13592 times ]

The Text is invisible by mesh.
How is your think?


Last edited by sellee on 30.03.2010, 12:01, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: 30.03.2010, 09:40 
Offline

Joined: 14.04.2008, 15:06
Posts: 183
Location: Germany
If you disable z testing the text will be always above the mesh.


Top
 Profile  
Reply with quote  
PostPosted: 30.03.2010, 12:02 
Offline

Joined: 25.03.2010, 03:58
Posts: 13
ok. now text always on top.
thank you.


Top
 Profile  
Reply with quote  
 Post subject: vector4
PostPosted: 07.04.2010, 08:44 
Offline

Joined: 25.03.2010, 03:58
Posts: 13
euclid.py has no vector4.

http://www.horde3d.org/wiki/index.php5? ... _the_scene

Code:
from euclid import Vector3,Matrix4

class Vector4:
   #Vector3, [x,y,z]
   def __init__(self, x=0, y=0, z=0, w=0):
      if isinstance(x, Vector3):
         self.x = x.x
         self.y = x.y
         self.z = x.z
         self.w = 1.
      elif isinstance(x, type([])):
         assert len(x)==3
         self.x = x[0]
         self.y = x[1]
         self.z = x[2]
         self.w = y
      else:
         self.x = x
         self.y = y
         self.z = z
         self.w = w


   def __copy__(self):
      return self.__class__(self.x, self.y, self.z,self.w)

   copy = __copy__

   def __repr__(self):
      return 'Vector4(%.2f, %.2f, %.2f, %.2f)' % (self.x, self.y, self.z,self.w)


   def __add__(self, other):
      assert isinstance(other, Vector4)
      v4 = Vector4()
      v4.x = self.x + other.x
      v4.y = self.y + other.y
      v4.z = self.z + other.z
      v4.w = self.w + other.w
      return v4

   def __mul__(self, other):
      if isinstance(other, Vector4):
         return Vector4(
               self.x * other.x,
               self.y * other.y,
               self.z * other.z,
               self.w * other.w)
      elif isinstance(other, Matrix4):
         A = other
         B = self
         V = Vector4()
         V.x = A.a * B.x  + A.b * B.y  + A.c * B.z  + A.d * B.w
         V.y = A.e * B.x  + A.f * B.y  + A.g * B.z  + A.h * B.w
         V.z = A.i * B.x  + A.j * B.y  + A.k * B.z  + A.l * B.w
         V.w = A.m * B.x  + A.n * B.y  + A.o * B.z  + A.p * B.w
         return V
      else:
         assert type(other) in (int, long, float)
         return Vector4(
               self.x * other,
               self.y * other,
               self.z * other,
               self.w * other)
   __rmul__ = __mul__

   def __imul__(self, other):
      assert type(other) in (int, long, float)
      self.x *= other
      self.y *= other
      self.z *= other
      self.w *= other
      return self


now can use vector4.
Code:
      for w in self._windows:
         camNode = w.camera
      # projection ,view matrix
      camProj = h3d.getCameraProjMat(camNode)
      projMat = Matrix4()
      projMat[:] = camProj[:]

      camTrans = h3d.getNodeTransMats(camNode)
      viewMat = Matrix4()
      viewMat[:]=camTrans[1][:]
      viewMat = viewMat.inverse();
      
      # draw hangul
      glLoadIdentity()
      glMatrixMode( GL_PROJECTION )
      glLoadIdentity()
      glOrtho(0,640,0,480,0,1)
      glDisable(GL_DEPTH_TEST)
      
      self.label.draw()
      
      #draw player name
      #nodeMat = h3d.getNodeTransMats(self._knight)
      #ppos =  Vector4(nodeMat[1][12],nodeMat[1][13],nodeMat[1][14],1)
      
      nodePos = h3d.getNodeTransform(self._knight)
      ppos =  Vector4(nodePos[0],1)
      
      ppos = ppos * (projMat * viewMat)
      if ppos.w > 0:
         x = ppos.x/ppos.w
         y = ppos.y/ppos.w
         x = int(x * 0.5 * 640 + 320)
         y = int(y * 0.5 * 480 + 240)
         self.nmLabel.x = x
         self.nmLabel.y = y
         self.nmLabel.draw()
      glEnable(GL_DEPTH_TEST)
      glLoadIdentity()


Top
 Profile  
Reply with quote  
PostPosted: 07.04.2010, 08:50 
Offline

Joined: 14.04.2008, 15:06
Posts: 183
Location: Germany
Great!
You should submit a patch to http://code.google.com/p/pyeuclid/ for other users.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 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
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group