Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赤子奈落
ygopro
Commits
b2b6c0d4
Commit
b2b6c0d4
authored
Mar 11, 2025
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update CGUITTFont::addTextSceneNode
parent
db333ef3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
24 deletions
+20
-24
gframe/CGUITTFont.cpp
gframe/CGUITTFont.cpp
+20
-24
No files found.
gframe/CGUITTFont.cpp
View file @
b2b6c0d4
...
...
@@ -879,11 +879,7 @@ core::dimension2d<u32> CGUITTFont::getDimensionUntilEndOfLine(const wchar_t* p)
}
core
::
array
<
scene
::
ISceneNode
*>
CGUITTFont
::
addTextSceneNode
(
const
wchar_t
*
text
,
scene
::
ISceneManager
*
smgr
,
scene
::
ISceneNode
*
parent
,
const
video
::
SColor
&
color
,
bool
center
)
{
using
namespace
core
;
using
namespace
video
;
using
namespace
scene
;
array
<
scene
::
ISceneNode
*>
container
;
core
::
array
<
scene
::
ISceneNode
*>
container
;
if
(
!
Driver
||
!
smgr
)
return
container
;
if
(
!
parent
)
...
...
@@ -894,8 +890,8 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
if
(
!
shared_plane_ptr_
)
//this points to a static mesh that contains the plane
createSharedPlane
();
//if it's not initialized, we create one.
dimension2d
<
s32
>
text_size
(
getDimension
(
text
));
//convert from unsigned to signed.
vector3df
start_point
(
0
,
0
,
0
),
offset
;
core
::
dimension2d
<
s32
>
text_size
(
getDimension
(
text
));
//convert from unsigned to signed.
core
::
vector3df
start_point
(
0
,
0
,
0
),
offset
;
/** NOTICE:
Because we are considering adding texts into 3D world, all Y axis vectors are inverted.
...
...
@@ -909,7 +905,7 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
}
// the default font material
SMaterial
mat
;
video
::
SMaterial
mat
;
mat
.
setFlag
(
video
::
EMF_LIGHTING
,
true
);
mat
.
setFlag
(
video
::
EMF_ZWRITE_ENABLE
,
false
);
mat
.
setFlag
(
video
::
EMF_NORMALIZE_NORMALS
,
true
);
...
...
@@ -921,7 +917,7 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
wchar_t
current_char
=
0
,
previous_char
=
0
;
u32
n
=
0
;
array
<
u32
>
glyph_indices
;
core
::
array
<
u32
>
glyph_indices
;
while
(
*
text
)
{
current_char
=
*
text
;
...
...
@@ -954,23 +950,23 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
s32
offy
=
(
font_metrics
.
ascender
/
64
)
-
glyph
.
offset
.
Y
;
// Apply kerning.
vector2di
k
=
getKerning
(
current_char
,
previous_char
);
core
::
vector2di
k
=
getKerning
(
current_char
,
previous_char
);
offset
.
X
+=
k
.
X
;
offset
.
Y
+=
k
.
Y
;
vector3df
current_pos
(
offset
.
X
+
offx
,
offset
.
Y
-
offy
,
0
);
dimension2d
<
u32
>
letter_size
=
dimension2d
<
u32
>
(
texw
,
texh
);
core
::
vector3df
current_pos
(
offset
.
X
+
offx
,
offset
.
Y
-
offy
,
0
);
core
::
dimension2d
<
u32
>
letter_size
=
core
::
dimension2d
<
u32
>
(
texw
,
texh
);
// Now we copy planes corresponding to the letter size.
IMeshManipulator
*
mani
=
smgr
->
getMeshManipulator
();
IMesh
*
meshcopy
=
mani
->
createMeshCopy
(
shared_plane_ptr_
);
mani
->
scale
(
meshcopy
,
vector3df
((
f32
)
letter_size
.
Width
,
(
f32
)
letter_size
.
Height
,
1
));
scene
::
IMeshManipulator
*
mani
=
smgr
->
getMeshManipulator
();
scene
::
IMesh
*
meshcopy
=
mani
->
createMeshCopy
(
shared_plane_ptr_
);
mani
->
scale
(
meshcopy
,
core
::
vector3df
((
f32
)
letter_size
.
Width
,
(
f32
)
letter_size
.
Height
,
1
));
ISceneNode
*
current_node
=
smgr
->
addMeshSceneNode
(
meshcopy
,
parent
,
-
1
,
current_pos
);
scene
::
ISceneNode
*
current_node
=
smgr
->
addMeshSceneNode
(
meshcopy
,
parent
,
-
1
,
current_pos
);
meshcopy
->
drop
();
current_node
->
getMaterial
(
0
)
=
mat
;
current_node
->
setAutomaticCulling
(
EAC_OFF
);
current_node
->
setAutomaticCulling
(
scene
::
EAC_OFF
);
current_node
->
setIsDebugObject
(
true
);
//so the picking won't have any effect on individual letter
//current_node->setDebugDataVisible(EDS_BBOX); //de-comment this when debugging
...
...
@@ -988,7 +984,7 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
for
(
u32
i
=
0
;
i
<
glyph_indices
.
size
();
++
i
)
{
u32
n
=
glyph_indices
[
i
];
SGUITTGlyph
const
&
glyph
=
Glyphs
[
n
-
1
];
ITexture
*
current_tex
=
Glyph_Pages
[
glyph
.
glyph_page
]
->
texture
;
video
::
ITexture
*
current_tex
=
Glyph_Pages
[
glyph
.
glyph_page
]
->
texture
;
f32
page_texture_size
=
(
f32
)
current_tex
->
getSize
().
Width
;
//Now we calculate the UV position according to the texture size and the source rect.
//
...
...
@@ -1004,15 +1000,15 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
f32
v2
=
v1
+
(
glyph
.
source_rect
.
getHeight
()
/
page_texture_size
);
//we can be quite sure that this is IMeshSceneNode, because we just added them in the above loop.
IMeshSceneNode
*
node
=
static_cast
<
IMeshSceneNode
*>
(
container
[
i
]);
scene
::
IMeshSceneNode
*
node
=
static_cast
<
scene
::
IMeshSceneNode
*>
(
container
[
i
]);
S3DVertex
*
pv
=
static_cast
<
S3DVertex
*>
(
node
->
getMesh
()
->
getMeshBuffer
(
0
)
->
getVertices
());
video
::
S3DVertex
*
pv
=
static_cast
<
video
::
S3DVertex
*>
(
node
->
getMesh
()
->
getMeshBuffer
(
0
)
->
getVertices
());
//pv[0].TCoords.Y = pv[1].TCoords.Y = (letter_size.Height - 1) / static_cast<f32>(letter_size.Height);
//pv[1].TCoords.X = pv[3].TCoords.X = (letter_size.Width - 1) / static_cast<f32>(letter_size.Width);
pv
[
0
].
TCoords
=
vector2df
(
u1
,
v2
);
pv
[
1
].
TCoords
=
vector2df
(
u2
,
v2
);
pv
[
2
].
TCoords
=
vector2df
(
u1
,
v1
);
pv
[
3
].
TCoords
=
vector2df
(
u2
,
v1
);
pv
[
0
].
TCoords
=
core
::
vector2df
(
u1
,
v2
);
pv
[
1
].
TCoords
=
core
::
vector2df
(
u2
,
v2
);
pv
[
2
].
TCoords
=
core
::
vector2df
(
u1
,
v1
);
pv
[
3
].
TCoords
=
core
::
vector2df
(
u2
,
v1
);
container
[
i
]
->
getMaterial
(
0
).
setTexture
(
0
,
current_tex
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment