- 博客(38)
- 资源 (2)
- 收藏
- 关注
原创 从零开始的openGL--cs游戏(17) Tweener
Tweener类似于unity中的doTweener比如我想达下面的效果 auto x = [this](float p) { Log("当前时间" + to_string(p)); }; Tween::DoTween<float>(0.0f, 2.0f, 2.0f, x); auto y = [this](glm::vec3 p) { Log("当前x值" + to_string(p.x) + "---当前y值" + to_string(p.y) + "---当前
2021-12-28 19:06:31
1986
原创 从零开始的openGL--cs游戏(16) 定时器。
在游戏中定时器十分常见,主要有定时一段时间循环执行,延迟执行等等。比如我要实现这样的功能,延迟2秒执行a,在每隔1秒执行b,持续10次。 auto a = [this]() { int k = 0; Log(to_string(Width) + "----------" + to_string(Height)); this->Log("延迟2秒后"); auto b = [&k ,this]() { this->Log("延迟1秒输出" + to_s
2021-12-28 13:57:58
2304
原创 从零开始的openGL--cs游戏(15) Volume阴影。
Volume阴影我认为是做cs游戏的最难的一个点,但了解实现原理后其实不难。 目前完成的实现效果 shadow volume原理不过让我不理解的是,计算shadow volume三角面的扩展顶点使得cpu计算时间增加了10倍,就图中两个模型加载一共耗时将近1分钟。应该有更优化的方法。而且加了Volume阴影我的天空盒无法显示,这个问题有待解决。关键点一:扩展三角面顶点,一般三角面是3
2021-12-24 17:30:24
2127
原创 从零开始的openGL--cs游戏(14) 延迟渲染G缓冲。
window类中定义G缓冲#ifndef Window_H#define Window_H#include <glad/glad.h>#include <GLFW/glfw3.h>#include <iostream>using namespace std;class Scene;class Time;class Input;class Shader;enum class Key;void Resize(GLFWwindow* window, .
2021-12-17 16:09:27
1460
原创 从零开始的openGL--cs游戏(13) 完成cs游戏的第一阶段,完成模型载入和动画,下一步做成阴影
B站上的视频记录一下 自己做的OpenGL游戏,第一阶段完成
2021-12-16 18:07:58
1197
原创 从零开始的openGL--cs游戏(12)Mesh和ModelComponent
mesh类#ifndef Mesh_H#define Mesh_H#include"Component.h"#include <glm/glm.hpp>#include <glm/gtc/matrix_transform.hpp>#include <string>#include <vector>#include <map>#include "Texture.h"#include "Shader.h"#define MAX_B
2021-12-15 18:52:31
515
原创 从零开始的openGL--cs游戏(11)3种常用shader
纯材质#version 430 corelayout(location = 0) in vec3 aPos;layout(location = 1) in vec2 aTexCoord;layout(std140 , binding = 0) uniform PV{ mat4 projection; mat4 view;};out vec2 TexCoord;uniform mat4 model;void main(){ gl_Position = projection * v
2021-12-15 18:49:54
353
原创 从零开始的openGL--cs游戏(10)MoveComponent,主角移动组件
主角也是摄像机的移动类#ifndef MoveComponent_H#define MoveComponent_H#include"Component.h"#include <glm/glm.hpp>#include <glm/gtc/matrix_transform.hpp>class MoveComponent : public Component{public: const float moveSpeed = 10.0f; const float camer
2021-12-14 18:11:28
335
原创 从零开始的openGL--cs游戏(9)CubeMeshComponent,一个正方形物体------------第一个页面完成
CubeMeshComponent#ifndef CubeMeshComponent_H#define CubeMeshComponent_H#include"Component.h"#include"Shader.h"class CubeMeshComponent :public Component{public: float length, width, height; unsigned int cubeVAO; unsigned int cubeVBO; float* cubeV
2021-12-13 19:50:01
163
原创 从零开始的openGL--cs游戏(8)CameraComponent类。相机组件
相机组件#ifndef CameraComponent_H#define CameraComponent_H#include"Component.h"#include <glm/glm.hpp>#include <glm/gtc/matrix_transform.hpp>class CameraComponent : public Component{public: const float YAW = -90.0f; const float PITCH = 0.0
2021-12-13 19:45:39
240
原创 从零开始的openGL--cs游戏(7)Scene类
Scene类似unity中的场景#ifndef Scene_H#define Scene_H#include "Window.h"using namespace std;class Transform;class GameObject;class CameraComponent;class Scene{private: static unsigned int _uboPV; Scene(); static Scene* Init(); friend void Window::In
2021-12-13 19:41:25
321
原创 从零开始的openGL--cs游戏(6)Input类
Input类主要解决游戏中的输入#ifndef Input_H#define Input_Henum class Key{ W = 0, A = 1, S = 2, D = 3, Mouse1 = 4, Mouse2 = 5, Space = 6, Shift = 7, R = 8,};class Input{private: bool _keys[9]{ false }; void Check(Key key, bool newValue);public: sta
2021-12-13 13:56:52
513
原创 从零开始的openGL--cs游戏(5)EventCenter类事件类
开发游戏必不可少的就是事件,再此用到了boost::function,再看这篇文章前可以了解下boost。#ifndef EventCenter_H#define EventCenter_H#include<map>#include <string>#include <vector>#include <Map>#include <boost/function.hpp>using namespace std;class Multi
2021-12-13 13:54:33
691
原创 从零开始的openGL--cs游戏(3)Time类
Time类#ifndef Time_H#define Time_H#include "Window.h"class Time{private: static float _deltaTime; static float _startTime; static float _curTime; friend void Window::SetDeltaTime(float time); friend void Window::SetCurTime(float time); friend v
2021-12-10 19:13:05
435
原创 从零开始的openGL--cs游戏(4)GameObject类 ,Component类,Transform类
Time类主要定义和时间相关#ifndef Time_H#define Time_H#include "Window.h"class Time{private: static float _deltaTime; static float _startTime; static float _curTime; friend void Window::SetDeltaTime(float time); friend void Window::SetCurTime(float time);
2021-12-10 19:03:05
321
原创 从零开始的openGL--cs游戏(2)Shader类,Texture2D类,ResourceManager类
Shader类,Texture2D类,ResourceManager类都是从learnopengl中复制过来的。主要是这些代码的确写的很好,基本没有修改的必要,我直接复制了。( ̄_, ̄ )Shader类#ifndef SHADER_H#define SHADER_H#include <string>#include <glad/glad.h>#include <glm/glm.hpp>#include <glm/gtc/type_ptr.hpp&g
2021-12-09 18:22:48
1228
原创 从零开始的openGL--cs游戏(1)Window类
主要采用了Learn-Computer-Graphicsmain类#pragma once#include <iostream>using namespace std;#include "Window.h"int main();#include "main.h"int main(){ Window* window = new Window(800, 600); window->Mainloop(); delete window; return 0;}
2021-12-09 12:31:43
231
原创 从零开始的openGL--cs游戏(1)Window类,已经更新
Window类是游戏窗口,相当于main我主要采用了Learn-Computer-Graphics中的窗口类。main类#pragma once#include <iostream>using namespace std;#include "Window.h"int main();-----------------------------------------------------#include "main.h"int main(){ Window* wind
2021-12-09 12:27:39
393
原创 从零开始的openGL--cs游戏(0)
再学习了openGL后,自己准备动手写一个CS游戏,之后每两天发布一次文章。基础的代码,主要参考learnOpenGL。主要的插件有glad,glfw,assimp5.0。希望大家追更( ̄_, ̄ )ㄟ( ▔, ▔ )ㄏ。
2021-12-08 16:44:05
386
原创 Unity得到物体前面水平面随机点
/// <summary> /// 得到go面前随机掉落点 /// </summary> /// <param name="go"></param> /// <param name="angle">掉落的角度</param> /// <param name="maxDistance">掉落的最大距离</param> ...
2021-11-18 18:47:33
2171
1
原创 UE4 引入插件的头文件,例如ControlRig
前言作为新手C++学习UE4是痛苦的,UE4的蓝图很强大,基本上蓝图可以解决所有问题。但是我们不用蓝图呢?我就要用C++,这就是我痛苦的原因之一。ControlRig是UE4插件库中的一个插件,有关它的使用都是通过蓝图实现。我查找遍了网上的文章所有ControlRig的使用都是蓝图,没有有关C++实现的文章。那么开始用C++引用ControlRig插件。我找了一天,终于从零零散散的文章中找到了答案,发现答案的那一刻,我感觉自己像柯南一样。首先是UE4工程的yourProject.Build.cs
2021-11-17 11:14:09
3985
1
原创 关于白忙活一个下午,结果发现方法没写参数的反思。
今天在游戏中要用到dynamic关键字,dynamic确实特别方便和好用但在rider引入dynamic时报错。后面将编译版本从2.0设置到4.X。这时候运行报了一个很诡异的错误,就是使用dynamic对象中的方法时,我忘记加参数。然后就报错了。就是这个错误我白忙活了整个下午。。。。。百度中搜索报错信息,提示要引入Microsoft.CSharp.dll,结果引入就报错,后面用NuGet安装Microsoft.CSharp,但一直提示命名重复,就这样瞎折腾。后面我从简单语句,dynamic a =
2021-10-27 17:00:27
1908
原创 自己写的Unity红黑树,简单明了。
红黑树是个强大的工具,方便定位。算了不说了,直接上代码public enum RedBlack { Red, Black, } public class RedBlackTree<T> where T : IComparable { public class RedBlackTreeNode { public T Value; public Red
2021-10-21 18:07:46
1558
原创 Unity C#双向泛型链表
双向链表中,添加了结点交换,结点移动的功能。还有一些其它的常用方法。public class DoubleLinkedList<T> : IEnumerable<T> ,IEnumerator<T> { public class DoubleLinkedNode { public T Value; public DoubleLinkedNode Prior;
2021-10-15 19:34:57
795
原创 Unity旋转到指定角度和旋转到指定向量的问题,Z轴方向向量为V1,Y轴方向向量为V2
有一个物体,现在我们需要将它的Z轴方向向量为V1,Y轴方向向量为V2如何实现呢,看代码。transform.forward = V1;float angle = Vector3.Angle(V2, transform.up);transform.Rotate(new Vector3(0,0,angle));看吧就是这么简单。...
2021-10-12 11:20:42
4954
1
原创 Unity SQLite4Unity3d中添加判断表是否存在的方法
在unity项目中用到了SQLite3数据库其中引用了SQLite4Unity3d写的框架但是其中没有写是否判断表存在的方法,我直接头大,,,在认真读了代码后,添加了判断表是否存在的功能,直接上代码。/// <summary> /// 判断表是否存在 /// </summary> public int ExistsTable<T>() { return ExistsTable(typeof(T)); } /// <summ
2021-09-07 16:17:53
600
原创 unity材质球复制
unity材质球复制有时候多个对象会引用到同一个材质球,修改其中一个,其它引用也会被修改,所以可以这样做。Material sourceMat = Resources.Load<Material("材质球路径");Shader shader = sourceMat.shader;Material material = new Material(shader);material.CopyPropertiesFromMaterial(sourceMat);...
2021-08-31 18:20:05
2977
原创 Unity 文字背景的宽高适应文字内容
在游戏中经常要用到的ui功能,有一个Text文本,同时文本有一个背景,当文本变动时,背景的大小也会变动首先transfrom的关系如下图请添加图片描述bg就是背景图image就是右下角的标签,line图中一条线,des就是text文本。des的Insprctor结构然后是bg的Insprctor结构在unity编辑器中更改des的文本内容,背景也会改变。细心的人会发现有时候改变des内容,bg框大小不会改变,我们点击一下Hierarchy视图中的bg就大小改变了,这是因为cintensi
2021-08-05 12:24:02
634
原创 Unity UGUI 一个UI逐渐显示或者逐渐消失
```csharpprotected void GraduallyShow(GameObject go,float time = 0.5f) { Transform[] transforms = go.GetComponentsInChildren<Transform>(); foreach (var transformChild in transforms) { Ima.
2021-08-04 11:28:42
1760
原创 获取标记有自定义Attribute的成员
现在我们有这样一个需求public class Base{ private List<String> _stringList;}[AttributeUsage(AttributeTargets.Field)]class ComponentAttribute:Attribute{}所有继承Base的类,在类中的string类型成员加上ComponentAttribute特性后,该string类型成员都会添加到Base的_stringList中。不多说上代码。publi
2021-08-03 19:28:02
155
原创 使用批处理命令和python将当前文件夹下的csv文件转换成UTF-8格式
使用批处理命令和python将当前文件夹下的csv文件转换成UTF-8格式批处理命令python脚本批处理命令// An highlighted blockecho offsetlocal enabledelayedexpansion set DIR="%cd%"for /R %DIR% %%f in (*.csv) do ( echo %%fset "FILE_FULLNAME=%%~nxf"python ToUTF8.py !FILE_FULLNAME!echo change to
2021-07-23 15:00:24
595
原创 将任意类对象转成Json字符串
将任意类对象转成Json字符串在我们开发可能遇到这样的问题,我们需要将一个类打印,也就是将一个类中的基本类型成员和该成员的数值打印,或者转成json数据,不多说上代码。一段漂亮的代码片.// An highlighted block//将类对象转成JSONObject对象 @SuppressWarnings("unchecked") private<T> JSONObject toJSON(T t) { JSONObject data = new
2020-08-10 09:34:43
1164
java学生管理系统(没用数据库)
2018-12-26
深度学习的物体识别原版论文(英文)
2018-12-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人