Homebrew How to move the render camera with libctru?

displayname

New Member
OP
Newbie
Joined
Dec 28, 2020
Messages
3
Trophies
0
Age
23
XP
44
Country
United States
Hi all! This is my first post here, and although this may be a stupid question, I haven't been able to find anything about it and it's really bugging me. I want to make a 3DS game with a 3D environment, and the graphics examples in devkitpro have been very helpful for learning the basics. But I've been stumped with something I thought would be pretty simple; how does one move the camera that renders the scene?

Lets take the lenny example scene in graphics/gpu/lenny as an example, suppose I want to move the camera on the X, Y, or Z axis to look at the lenny model in all of it's glory. How does one do this? I've looked through the libctru documentation, and although I've relatively experienced in C/C++ (it being the first language I learned), it's all rather foreign to me. Again, sorry if this is a stupid question, I've just been stumped with it. Thanks! :D
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,034
Country
United States
The shader in the Lenny example uses the traditional model view and projection matrixes used by 3D apis. You will need to translate and rotate the model view matrix to change the view. The matrix is used by the shader to translate object coordinates to view coordinates. If you are unfamiliar with this then I recommend taking a look at similar procedures with OpenGL.
 
  • Like
Reactions: displayname

displayname

New Member
OP
Newbie
Joined
Dec 28, 2020
Messages
3
Trophies
0
Age
23
XP
44
Country
United States
The shader in the Lenny example uses the traditional model view and projection matrixes used by 3D apis. You will need to translate and rotate the model view matrix to change the view. The matrix is used by the shader to translate object coordinates to view coordinates. If you are unfamiliar with this then I recommend taking a look at similar procedures with OpenGL.

Drats, I knew I should have familiarized myself with openGL before diving head first into something like this lol.

In any case, if it's no trouble, is there a quick explanation on how to change the model view matrix in real time with libctru? (For instance, on press A button move on the X axis, etc etc)
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,034
Country
United States
Drats, I knew I should have familiarized myself with openGL before diving head first into something like this lol.

In any case, if it's no trouble, is there a quick explanation on how to change the model view matrix in real time with libctru? (For instance, on press A button move on the X axis, etc etc)
Take a look at the wide_mode_3d gpu example. It looks like it can rotate a bit.
The best advice is really just give it a go yourself - and reserve questions for when you have something specific to ask after you have tried something yourself.
 
  • Like
Reactions: displayname

displayname

New Member
OP
Newbie
Joined
Dec 28, 2020
Messages
3
Trophies
0
Age
23
XP
44
Country
United States
Take a look at the wide_mode_3d gpu example. It looks like it can rotate a bit.
The best advice is really just give it a go yourself - and reserve questions for when you have something specific to ask after you have tried something yourself.

Fair enough, thanks for the pointers! Will be taking a look at the provided example :D
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • K3Nv2 @ K3Nv2:
    Thanks for signing up at LinusTechTips
  • QuarterCut @ QuarterCut:
    holey shmoley!
  • BigOnYa @ BigOnYa:
    Your credit card has been charged. Thank you.
  • K3Nv2 @ K3Nv2:
    Your screwdriverPlus will arrive in three weeks
    +1
  • QuarterCut @ QuarterCut:
    K64_Waddle_Dee_Artwork_1.jpg

    my reaction to such information
    +2
  • BigOnYa @ BigOnYa:
    Press 1 for English. Press 2 for Pig Latin. Or press 3 to speak to a representative.
  • BakerMan @ BakerMan:
    guys, i need help, i got into an argument about what genre radioactive is, and i forgot who made it
  • Sicklyboy @ Sicklyboy:
    @BakerMan, Imagine Dragons
  • Sicklyboy @ Sicklyboy:
    Dragon deez nuts across yo face GOTEEM
  • Sicklyboy @ Sicklyboy:
    lmao now I realize that was probably the joke in the first place
    +1
  • BakerMan @ BakerMan:
    IMAGINE DRAGON DEEZ NUTS ACROSS YO- FUCK HE BEAT ME TO IT
  • BigOnYa @ BigOnYa:
    You have selected 4 - Death by Snu Snu, please stand by...
    +1
  • BakerMan @ BakerMan:
    lucky bastard
    +1
  • Sicklyboy @ Sicklyboy:
    hahahaha I'm half way through a bag off my Volcano and my tolerance is way down because I haven't been smoking much lately, so I was a little slow to catch that that was what your angle was 🤣🤣
    +1
  • Sicklyboy @ Sicklyboy:
    Also I was just excited to know a music reference for once (I am the LAST person in the world that you want on your trivia team)
    +2
  • K3Nv2 @ K3Nv2:
    Bummer webos 7.4 isnt working with dejavuln-autoroot
  • Sicklyboy @ Sicklyboy:
    PS4 right? I think that's what mine's on. Or 5.6, maybe.
  • K3Nv2 @ K3Nv2:
    [!] Installation failed (devmode_enabled not recognized)
  • K3Nv2 @ K3Nv2:
    0.5 seemed to work whatever lol i wont bitch
  • Alysh_Graham @ Alysh_Graham:
    Hehehe
    Alysh_Graham @ Alysh_Graham: Hehehe