Comments (24)
You can use CSprite2d::Draw
method with additional texture coordinates setup:
void Draw(CRect const& posn, CRGBA const& color, float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4);
where
u1, v1
- texture coordinates for left-top corner vertex
u2, v2
- texture coordinates for right-top corner vertex
u3, v3
- texture coordinates for left-bottom corner vertex
u4, v4
- texture coordinates for right-bottom corner vertex
#include "plugin.h"
#include "game_sa\CSprite2d.h"
#include "game_sa\CScene.h"
using namespace plugin;
class TextureTest {
public:
TextureTest() {
static CSprite2d sprite;
Events::drawingEvent += [] {
if (!sprite.m_pTexture)
sprite.m_pTexture = RwD3D9DDSTextureRead(PLUGIN_PATH("logo"), NULL);
sprite.Draw(CRect(SCREEN_COORD(100.0f), SCREEN_COORD(100.0f), SCREEN_COORD(800.0f), SCREEN_COORD(800.0f)),
CRGBA(255, 255, 255, 255), 0.1f, 0.1f, 0.7f, 0.1f, 0.1f, 0.7f, 0.7f, 0.7f);
};
Events::shutdownRwEvent += [] {
sprite.Delete();
};
}
} test;
You can also create your own function where these parameters will look much more understandable.
#include "plugin.h"
#include "game_sa\CSprite2d.h"
#include "game_sa\CScene.h"
using namespace plugin;
class TextureTest {
public:
static void DrawSpritePart(CSprite2d &sprite, float x, float y, float w, float h, CRect const &part) {
sprite.Draw(CRect(x, y, x + w, y + h), CRGBA(255, 255, 255, 255),
part.left, part.top, part.right, part.top, part.left, part.bottom, part.right, part.bottom);
}
TextureTest() {
static CSprite2d sprite;
Events::drawingEvent += [] {
if (!sprite.m_pTexture)
sprite.m_pTexture = RwD3D9DDSTextureRead(PLUGIN_PATH("logo"), NULL);
float size = SCREEN_COORD(280.0f);
DrawSpritePart(sprite, SCREEN_COORD_CENTER_LEFT(300.0f), SCREEN_COORD_CENTER_UP(300.0f), size, size, CRect(0.0f, 0.0f, 0.5f, 0.5f));
DrawSpritePart(sprite, SCREEN_COORD_CENTER_RIGHT(20.0f), SCREEN_COORD_CENTER_UP(300.0f), size, size, CRect(0.5f, 0.0f, 1.0f, 0.5f));
DrawSpritePart(sprite, SCREEN_COORD_CENTER_LEFT(300.0f), SCREEN_COORD_CENTER_DOWN(20.0f), size, size, CRect(0.0f, 0.5f, 0.5f, 1.0f));
DrawSpritePart(sprite, SCREEN_COORD_CENTER_RIGHT(20.0f), SCREEN_COORD_CENTER_DOWN(20.0f), size, size, CRect(0.5f, 0.5f, 1.0f, 1.0f));
};
Events::shutdownRwEvent += [] {
sprite.Delete();
};
}
} test;
from plugin-sdk.
Yes, it's a problem with that plugin you used to generate .dds.
If you have DirectX 9 SDK installed, you can use DxTex
utility (it's in Utilities\bin\x64/x86
folder) to re-save your texture.
Or you can use NVidia's DDS plugin for Photoshop, I have never had problems with it.
logo.zip
Also, some fix to your code: do not use class name to name an instance of you class (variable). Use, for example, tacticRadar
.
class TacticRadar {
// ...
} tacticRadar; // use different name here
from plugin-sdk.
No problem! Glad to help you. Here is the code of FindPlayerHeading.
As you can see, you MUST NOT pass -1, but you have to pass 0.
Would be glad to see if the R* methods of getting heading actually work for you :-)
from plugin-sdk.
For map markers, you need to go with ms_RadarTrace array.
Something like this:
for (int i = 0; i < MAX_RADAR_TRACES; i++) {
auto &blip = CRadar::ms_RadarTrace[i];
// check if blip exists
if (blip.m_bTrackingBlip) {
// perform any other actions - for example, check sprite id
if (blip.m_nBlipSprite == RADAR_SPRITE_POLICE) {
// ...
}
}
}
For sprite transparency, you can setup it in "color" parameter:
sprite.Draw(CRect(left, top, right, bottom), CRGBA(red, green, blue, alpha));
I'm closing this issue now. If you have any other questions, please create a new one with a proper name.
from plugin-sdk.
Hello and welcome to plugin-sdk community.
RwD3D9DDSTextureRead
does not use second parameter (called "maskName"), so you can set this parameter to NULL
.
- Are you sure your .dds file uses alpha channel? Can you upload it so we could check?
- How do you draw your texture? Maybe you missing something in the 'drawing' part?
from plugin-sdk.
Hi!
Thank you for your answer.
I thought the second parameter is properly for masking.
Yes, my .dds file has an alpha channel, i used the following plugin to create my .dds file:
http://gametechdev.github.io/Intel-Texture-Works-Plugin/
Link to .dds file: https://www.file-upload.net/download-12596036/logo.dds.html
I used your example to draw textures.
Source:
#include "plugin.h"
#include "game_sa\CSprite2d.h"
using namespace plugin;
class TacticRadar {
public:
TacticRadar() {
static CSprite2d sprite;
Events::drawingEvent += [] {
if (!sprite.m_pTexture) // load texture only once
sprite.m_pTexture = RwD3D9DDSTextureRead(PLUGIN_PATH("logo"), PLUGIN_PATH("logo_alpha")); // rw api gives you ability to load dds images
sprite.Draw(CRect(10.0f, 10.0f, 300.0f, 300.0f), CRGBA(255, 255, 255, 255)); // draw sprite
};
Events::shutdownRwEvent += [] {
sprite.Delete(); // delete loaded texture
};
}
} TacticRadar;
It doesn't work with the given .dds file, but with a .dds file, without alpha channel, it works.
Greetings
from plugin-sdk.
Thank you very much!
It works fine, i tried the NVidia DDS Plugin, and it works.
Also thank you for the advice relating to the instance name.
One last question:
Is there any chance to show only a specific part of the image? Like cropping the image?
For better understanding: I want to create an image (compas, like in Player Unknows Battlegrounds)
and show only the needed part of the image.
Thank's for your help!
from plugin-sdk.
That's awesome! Thank you.
I create the modification and will inform you with the result!
See ya.
from plugin-sdk.
Hi. Again a question. How do I use SCREEN_COORD
properly?
The resolution of my image is 1064x40
.
That's acutally what I have:
float width = SCREEN_COORD(500.0f);
float height = SCREEN_COORD(40.0f);
And it looks not that bad, but also not right.
from plugin-sdk.
Maybe
float width = SCREEN_COORD(532.0f); // 1064 / 2
float height = SCREEN_COORD(20.0f); // 40 / 2
?
from plugin-sdk.
Oh. Sorry, I totally forgot to say, that I figured it out.
But I have another problem:
Events::gameProcessEvent += UpdatePlayerCoords;
static void UpdatePlayerCoords() {
KeyCheck::Update();
if (KeyCheck::Check(VK_SHIFT)) {
if (KeyCheck::CheckJustDown('1')) {
CMessages::AddMessage("Hi", 3000, 0, false); // Does not work
}
}
}
Is it becuase I play/test it on SAMP?
Acutally, it does not work either with other functions.
from plugin-sdk.
What if you will just output an error message?
Events::gameProcessEvent += [] {
Error("gameProcessEvent");
};
from plugin-sdk.
Doesn't show up anything, tried with my code and with your example above.
But the images created under Events::drawingEvent
showing up.
Edit:
Under Events::drawingEvent
the function Error
shows up a MsgBox.
from plugin-sdk.
Okay... Looks like a conflict with SAMP.
You can try processScriptsEvent
as a replacement for gameProcessEvent
.
from plugin-sdk.
Ok, that's helpfuel, thank you.
How do I get the Rotation of the player? player->m_fCurrentRotation
and player->m_fCurrentRotation
returning a too small number. If north is 0 and 360 (like SAMP? doesn't know aktually).
And is there also an option to get the rotation/direction of the player camera?
You are very kind and helpfuel, I thank you for the help!
from plugin-sdk.
They're probably in radians.
from plugin-sdk.
Okay, thank you. I will see if that could be.
from plugin-sdk.
Hello.
i was on vacation, sorry for the late reply. I converted radian to degree, but it looks wrong.
Mostly I get a negative response. Maybe @DK22Pac can answer my question?
How do I get the Rotation of the player? player->m_fCurrentRotation and player->m_fCurrentRotation
returning a too small number. If north is 0 and 360 (like SAMP? doesn't know aktually).
And is there also an option to get the rotation/direction of the player camera?
Greetings.
from plugin-sdk.
from plugin-sdk.
Hi.
FindPlayerHeading doesn't return anything, and it causes to stop my mod.
player->m_fCurrentRotation returns the player angle in radians, so that's not the problem.
I actually get it. Doesn't know, what I did wrong. THere is maybe a better solution, but this works for me:
static float ConvertRadiansToDegree(float radian) {
static float radianConv = 57.295779513082F;
float response = 0.0F;
if (radian < 0) {
response = 180.0F;
radian = radian + 3.14159F;
}
response = response + (radian * radianConv);
return response;
}
from plugin-sdk.
Hi again.
Soon I'll be ready. But I need to calculate the position of the image with the roation. <- No problem for me.
But there is still my question about the camera direction. Is there any function to get the camera direction?
With the camera direction the mod looks a lot better. Here is a preview:
https://www.youtube.com/watch?v=4L20EBYy8Ww
from plugin-sdk.
@Cireyses
and it causes to stop my mod.
Hopefully you passed 0 for first player as argument and are trying to get rotation of a player that was created by the game ;-)
To get the camera direction I recommend using the CCamera::GetHeading method that is available because the CCamera class is also a CPlaceable.
from plugin-sdk.
Hi @quiret!
Yes, I passed -1 for the player not 0, like the other functions.
Yesterday I found the CCamera file and tested TheCamera.m_fOrientation
,
and it works properly. I will see, if I get a same result with your method.
Thank you.
from plugin-sdk.
Works fine so far.
Is there any possibility to get all map markers on the map?
Like a list with ht eicon name or something else.
I want to show the map icons also in the compass.
And: Can I set a transparency to a sprite/draw, separately from the transparency of the image?
from plugin-sdk.
Related Issues (20)
- Error while compiling script (C3861 'M_PI': identifier not found) [Visual Studio 2019] HOT 3
- Error while building HOT 4
- injector::MakeInline modifies the EFLAGS register HOT 1
- Can't build plugin.sln (C2760 Error) [Visual Studio 2019 Community]
- Crash when calling CPlaceable::GetAtDirection()
- Build errors caused by C/C++ preprocessor definitions HOT 1
- Is this error caused because a d3dx9 sdk installation is missing? HOT 2
- Plugin-SDK adaptable for GTA SA mobile version. HOT 1
- VSIX installer error in Visual Studio HOT 3
- GetD3DDevice not work correct
- Compilation error. Visual Studio 2019 HOT 4
- Linux crosscompilation: error due to includes with different casing than the file HOT 2
- GPS example broken due to missing type on GetD3DDevice template function HOT 1
- WN 11 ?? HOT 2
- Error in plugin gen HOT 5
- Recent error while trying to clone HOT 1
- Modifying shadow colors.
- CRoadBlocks::aScriptRoadBlocks address collision HOT 1
- About UE4 GTA game sdk
- Issues with installing(FIXED)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugin-sdk.