skeletal and morph animation samples
beginning of light animation, easier animation building and triangle winding order
@@ -6,6 +6,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -pedantic")
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(BUILD_TESTS ON)
|
||||
set(BUILD_SAMPLES ON)
|
||||
set(LIB_NAME vb01)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
cmake_policy(SET CMP0015 NEW)
|
||||
@@ -24,7 +25,7 @@ include_directories(external/glm/glm)
|
||||
include_directories(external/glad)
|
||||
include_directories(external/stb)
|
||||
|
||||
add_library(vb01 SHARED external/glad/glad.c ${LIB_SRC})
|
||||
add_library(${LIB_NAME} SHARED external/glad/glad.c ${LIB_SRC})
|
||||
|
||||
set(GLFW_DIR external/glfw)
|
||||
set(FREETYPE_DIR external/freetype)
|
||||
@@ -39,22 +40,22 @@ endif()
|
||||
|
||||
add_subdirectory(${GLFW_DIR})
|
||||
set(GLFW_LIB_DIR build/${GLFW_DIR}/src)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${GLFW_DIR}/include/GLFW)
|
||||
target_link_directories(${PROJECT_NAME} PUBLIC ${GLFW_LIB_DIR})
|
||||
target_include_directories(${LIB_NAME} PUBLIC ${GLFW_DIR}/include/GLFW)
|
||||
target_link_directories(${LIB_NAME} PUBLIC ${GLFW_LIB_DIR})
|
||||
|
||||
add_subdirectory(${ASSIMP_DIR})
|
||||
set(ASSIMP_LIB_DIR build/${ASSIMP_DIR}/lib)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${ASSIMP_DIR}/include/assimp)
|
||||
target_link_directories(${PROJECT_NAME} PUBLIC ${ASSIMP_LIB_DIR})
|
||||
target_include_directories(${LIB_NAME} PUBLIC ${ASSIMP_DIR}/include/assimp)
|
||||
target_link_directories(${LIB_NAME} PUBLIC ${ASSIMP_LIB_DIR})
|
||||
|
||||
set(FREETYPE_LIB_DIR build/${FREETYPE_DIR})
|
||||
add_subdirectory(${FREETYPE_DIR})
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${FREETYPE_DIR}/include)
|
||||
target_link_directories(${PROJECT_NAME} PUBLIC ${FREETYPE_LIB_DIR})
|
||||
target_include_directories(${LIB_NAME} PUBLIC ${FREETYPE_DIR}/include)
|
||||
target_link_directories(${LIB_NAME} PUBLIC ${FREETYPE_LIB_DIR})
|
||||
|
||||
set(DEPS glfw assimp freetype ${CMAKE_DL_LIBS})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${DEPS})
|
||||
target_link_libraries(${LIB_NAME} ${DEPS})
|
||||
|
||||
if(BUILD_TESTS)
|
||||
if(UNIX)
|
||||
@@ -72,10 +73,19 @@ if(BUILD_TESTS)
|
||||
set(TEST_SRC main.cpp ${LIB_SRC} ${RENDER_TEST} ${ARMATURE_TEST} ${MODEL_TEST} ${ANIMATION_TEST})
|
||||
|
||||
add_executable(vb01Tests ${TEST_SRC})
|
||||
target_link_libraries(vb01Tests ${PROJECT_NAME} ${DEPS} cppunit)
|
||||
target_link_libraries(vb01Tests ${LIB_NAME} ${DEPS} cppunit)
|
||||
endif()
|
||||
|
||||
if(BUILD_SAMPLES)
|
||||
add_executable(textSample textSample.cpp)
|
||||
target_link_libraries(textSample ${PROJECT_NAME})
|
||||
target_link_libraries(textSample ${LIB_NAME})
|
||||
|
||||
add_executable(skeletalAnimationSample skeletalAnimationSample.cpp)
|
||||
target_link_libraries(skeletalAnimationSample ${LIB_NAME})
|
||||
|
||||
add_executable(morphAnimationSample morphAnimationSample.cpp)
|
||||
target_link_libraries(morphAnimationSample ${LIB_NAME})
|
||||
|
||||
add_executable(lightSample lightSample.cpp)
|
||||
target_link_libraries(lightSample ${LIB_NAME})
|
||||
endif()
|
||||
|
||||
@@ -41,24 +41,24 @@ namespace vb01{
|
||||
Vector2(0, 0),
|
||||
Vector2(1, 0)
|
||||
};
|
||||
unsigned int data[]={
|
||||
0, 3, 1, 4, 3, 0, 1, 3, 2,
|
||||
5, 3, 3, 1, 3, 2, 4, 3, 0,
|
||||
unsigned int data[] = {
|
||||
1, 3, 2, 4, 3, 0, 0, 3, 1,
|
||||
4, 3, 0, 1, 3, 2, 5, 3, 3,
|
||||
|
||||
2, 0, 1, 6, 0, 0, 3, 0, 2,
|
||||
6, 0, 2, 7, 0, 0, 3, 0, 3,
|
||||
3, 0, 2, 6, 0, 0, 2, 0, 1,
|
||||
3, 0, 3, 7, 0, 0, 6, 0, 2,
|
||||
|
||||
3, 2, 0, 7, 2, 1, 4, 2, 2,
|
||||
4, 2, 2, 0, 2, 3, 3, 2, 0,
|
||||
4, 2, 2, 7, 2, 1, 3, 2, 0,
|
||||
3, 2, 0, 0, 2, 3, 4, 2, 1,
|
||||
|
||||
1, 5, 0, 5, 5, 1, 6, 5, 2,
|
||||
6, 5, 2, 2, 5, 3, 1, 5, 0,
|
||||
1, 4, 0, 5, 4, 1, 6, 4, 2,
|
||||
6, 4, 2, 2, 4, 3, 1, 4, 0,
|
||||
|
||||
0, 1, 0, 1, 1, 1, 2, 1, 2,
|
||||
2, 1, 2, 3, 1, 3, 0, 1, 0,
|
||||
2, 1, 2, 1, 1, 1, 0, 1, 0,
|
||||
0, 1, 0, 3, 1, 3, 2, 1, 2,
|
||||
|
||||
4, 4, 3, 6, 4, 1, 5, 4, 2,
|
||||
6, 4, 1, 4, 4, 3, 7, 4, 0
|
||||
5, 5, 2, 6, 5, 1, 4, 5, 3,
|
||||
7, 5, 0, 4, 5, 3, 6, 5, 1
|
||||
};
|
||||
for(int i = 0; i < 3 * numTris; i++){
|
||||
Vertex v;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# Blender MTL File: 'jet00.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl None
|
||||
Ns 500
|
||||
Ka 0.8 0.8 0.8
|
||||
Kd 0.8 0.8 0.8
|
||||
Ks 0.8 0.8 0.8
|
||||
d 1
|
||||
illum 2
|
||||
@@ -23,7 +23,7 @@ namespace vb01{
|
||||
float KeyframeChannel::interpolateBezier(vector<float> points, float ratio){
|
||||
int numPoints = points.size();
|
||||
vector<float> newPoints;
|
||||
for(int i = 0; i < numPoints - 1; i++)
|
||||
for(int i = 0; i < numPoints - 1; i++)
|
||||
newPoints.push_back(points[i] + (points[i + 1] - points[i]) * ratio);
|
||||
|
||||
if(newPoints.size() >= 2)
|
||||
@@ -79,4 +79,12 @@ for(int i = 0; i < numPoints - 1; i++)
|
||||
}
|
||||
return keyframeChannel.keyframes[pastKeyframeId + (last ? 0 : 1)];
|
||||
}
|
||||
|
||||
Keyframe KeyframeChannel::createKeyframe(KeyframeInterpolation interpolation, float frame, float value){
|
||||
Keyframe keyframe;
|
||||
keyframe.interpolation = interpolation;
|
||||
keyframe.frame = frame;
|
||||
keyframe.value = value;
|
||||
return keyframe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace vb01{
|
||||
static KeyframeChannel::Type getKeyframeChannelType(std::string);
|
||||
static float interpolate(Keyframe, Keyframe, float);
|
||||
static Keyframe findKeyframe(float, KeyframeChannel, bool);
|
||||
static Keyframe createKeyframe(Keyframe::Interpolation, float, float);
|
||||
};
|
||||
|
||||
typedef KeyframeChannel::Type KeyframeChannelType;
|
||||
|
||||
@@ -1,290 +0,0 @@
|
||||
#ifndef __khrplatform_h_
|
||||
#define __khrplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
||||
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
||||
* The last semantic modification to khrplatform.h was at commit ID:
|
||||
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
* group so that they can be included in future versions of this file.
|
||||
* Please submit changes by filing pull requests or issues on
|
||||
* the EGL Registry repository linked above.
|
||||
*
|
||||
*
|
||||
* See the Implementer's Guidelines for information about where this file
|
||||
* should be located on your system and for more details of its use:
|
||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||
*
|
||||
* This file should be included as
|
||||
* #include <KHR/khrplatform.h>
|
||||
* by Khronos client API header files that use its types and defines.
|
||||
*
|
||||
* The types in khrplatform.h should only be used to define API-specific types.
|
||||
*
|
||||
* Types defined in khrplatform.h:
|
||||
* khronos_int8_t signed 8 bit
|
||||
* khronos_uint8_t unsigned 8 bit
|
||||
* khronos_int16_t signed 16 bit
|
||||
* khronos_uint16_t unsigned 16 bit
|
||||
* khronos_int32_t signed 32 bit
|
||||
* khronos_uint32_t unsigned 32 bit
|
||||
* khronos_int64_t signed 64 bit
|
||||
* khronos_uint64_t unsigned 64 bit
|
||||
* khronos_intptr_t signed same number of bits as a pointer
|
||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||
* khronos_ssize_t signed size
|
||||
* khronos_usize_t unsigned size
|
||||
* khronos_float_t signed 32 bit floating point
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
* booleans cannot use this as the base type for their boolean.
|
||||
*
|
||||
* Tokens defined in khrplatform.h:
|
||||
*
|
||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||
*
|
||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||
*
|
||||
* Calling convention macros defined in this file:
|
||||
* KHRONOS_APICALL
|
||||
* KHRONOS_APIENTRY
|
||||
* KHRONOS_APIATTRIBUTES
|
||||
*
|
||||
* These may be used in function prototypes as:
|
||||
*
|
||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||
* int arg1,
|
||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||
*/
|
||||
|
||||
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
|
||||
# define KHRONOS_STATIC 1
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APICALL
|
||||
*-------------------------------------------------------------------------
|
||||
* This precedes the return type of the function in the function prototype.
|
||||
*/
|
||||
#if defined(KHRONOS_STATIC)
|
||||
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
|
||||
* header compatible with static linking. */
|
||||
# define KHRONOS_APICALL
|
||||
#elif defined(_WIN32)
|
||||
# define KHRONOS_APICALL __declspec(dllimport)
|
||||
#elif defined (__SYMBIAN32__)
|
||||
# define KHRONOS_APICALL IMPORT_C
|
||||
#elif defined(__ANDROID__)
|
||||
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||
#else
|
||||
# define KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIENTRY
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
# define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
# define KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIATTRIBUTES
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the closing parenthesis of the function prototype arguments.
|
||||
*/
|
||||
#if defined (__ARMCC_2__)
|
||||
#define KHRONOS_APIATTRIBUTES __softfp
|
||||
#else
|
||||
#define KHRONOS_APIATTRIBUTES
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* basic type definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||
|
||||
|
||||
/*
|
||||
* Using <stdint.h>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__VMS ) || defined(__sgi)
|
||||
|
||||
/*
|
||||
* Using <inttypes.h>
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
|
||||
/*
|
||||
* Win32
|
||||
*/
|
||||
typedef __int32 khronos_int32_t;
|
||||
typedef unsigned __int32 khronos_uint32_t;
|
||||
typedef __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
|
||||
/*
|
||||
* Sun or Digital
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#if defined(__arch64__) || defined(_LP64)
|
||||
typedef long int khronos_int64_t;
|
||||
typedef unsigned long int khronos_uint64_t;
|
||||
#else
|
||||
typedef long long int khronos_int64_t;
|
||||
typedef unsigned long long int khronos_uint64_t;
|
||||
#endif /* __arch64__ */
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif 0
|
||||
|
||||
/*
|
||||
* Hypothetical platform with no float or int64 support
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#define KHRONOS_SUPPORT_INT64 0
|
||||
#define KHRONOS_SUPPORT_FLOAT 0
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Generic fallback
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Types that are (so far) the same on all platforms
|
||||
*/
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef _WIN64
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
typedef unsigned long long int khronos_usize_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef unsigned long int khronos_uintptr_t;
|
||||
typedef signed long int khronos_ssize_t;
|
||||
typedef unsigned long int khronos_usize_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_FLOAT
|
||||
/*
|
||||
* Float type
|
||||
*/
|
||||
typedef float khronos_float_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64
|
||||
/* Time types
|
||||
*
|
||||
* These types can be used to represent a time interval in nanoseconds or
|
||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||
* time the system booted). The Unadjusted System Time is an unsigned
|
||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy value used to pad enum types to 32 bits.
|
||||
*/
|
||||
#ifndef KHRONOS_MAX_ENUM
|
||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enumerated boolean type
|
||||
*
|
||||
* Values other than zero should be considered to be true. Therefore
|
||||
* comparisons should not be made against KHRONOS_TRUE.
|
||||
*/
|
||||
typedef enum {
|
||||
KHRONOS_FALSE = 0,
|
||||
KHRONOS_TRUE = 1,
|
||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||
} khronos_boolean_enum_t;
|
||||
|
||||
#endif /* __khrplatform_h_ */
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "root.h"
|
||||
#include "box.h"
|
||||
#include "material.h"
|
||||
#include "node.h"
|
||||
#include "light.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace vb01;
|
||||
|
||||
int main(){
|
||||
const string PATH = "../", TEX_PATH = PATH + "samples/textures/", MODEL_PATH = PATH + "samples/models/";
|
||||
string skyboxTextures[] = {
|
||||
TEX_PATH + "top.jpg",
|
||||
TEX_PATH + "bottom.jpg",
|
||||
TEX_PATH + "left.jpg",
|
||||
TEX_PATH + "right.jpg",
|
||||
TEX_PATH + "front.jpg",
|
||||
TEX_PATH + "back.jpg"
|
||||
};
|
||||
|
||||
Root *root = Root::getSingleton();
|
||||
root->start(800, 600, PATH, "Light sample");
|
||||
root->createSkybox(skyboxTextures);
|
||||
Node *rootNode = root->getRootNode();
|
||||
|
||||
Camera *cam = root->getCamera();
|
||||
cam->setPosition(Vector3(0, 1, 1) * 30);
|
||||
cam->lookAt(Vector3(0, -1, -1).norm(), Vector3(0, 1, -1).norm());
|
||||
|
||||
Box *box = new Box(Vector3(20, 1, 20));
|
||||
Node *boxNode = new Node();
|
||||
|
||||
Material *mat = new Material();
|
||||
mat->setTexturingEnabled(true);
|
||||
mat->setLightingEnabled(true);
|
||||
string images[] = {TEX_PATH + "bricks.jpg"};
|
||||
Texture *texture = new Texture(images, 1);
|
||||
mat->addDiffuseMap(texture);
|
||||
box->setMaterial(mat);
|
||||
|
||||
boxNode->attachMesh(box);
|
||||
rootNode->attachChild(boxNode);
|
||||
|
||||
Light *light = new Light(Light::SPOT);
|
||||
light->setColor(Vector3(1, 1, 1));
|
||||
Node *lightNode = new Node();
|
||||
lightNode->addLight(light);
|
||||
rootNode->attachChild(lightNode);
|
||||
lightNode->setOrientation(Quaternion(1.57, Vector3(1, 0, 0)));
|
||||
lightNode->setPosition(Vector3(0, 2, 0));
|
||||
|
||||
while(true)
|
||||
root->update();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "root.h"
|
||||
#include "model.h"
|
||||
#include "material.h"
|
||||
#include "mesh.h"
|
||||
#include "skeleton.h"
|
||||
#include "animationController.h"
|
||||
#include "animationChannel.h"
|
||||
#include "box.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace vb01;
|
||||
|
||||
int main(){
|
||||
const string PATH = "../", TEX_PATH = PATH + "samples/textures/", MODEL_PATH = PATH + "samples/models/";
|
||||
string skyboxTextures[] = {
|
||||
TEX_PATH + "top.jpg",
|
||||
TEX_PATH + "bottom.jpg",
|
||||
TEX_PATH + "left.jpg",
|
||||
TEX_PATH + "right.jpg",
|
||||
TEX_PATH + "front.jpg",
|
||||
TEX_PATH + "back.jpg"
|
||||
};
|
||||
|
||||
Root *root = Root::getSingleton();
|
||||
root->start(800, 600, PATH, "Morph animation sample");
|
||||
root->createSkybox(skyboxTextures);
|
||||
Node *rootNode = root->getRootNode();
|
||||
|
||||
Camera *cam = root->getCamera();
|
||||
cam->setPosition(Vector3(-1, 0.25, .2) * 20);
|
||||
cam->lookAt(Vector3(1, 0, 0).norm(), Vector3(0, 1, 0).norm());
|
||||
|
||||
Model *model = new Model(MODEL_PATH + "kek.vb");
|
||||
Material *mat = new Material();
|
||||
mat->setLightingEnabled(false);
|
||||
mat->setTexturingEnabled(true);
|
||||
string images[] = {TEX_PATH + "defaultTexture.jpg"};
|
||||
Texture *texture = new Texture(images, 1);
|
||||
mat->addDiffuseMap(texture);
|
||||
model->setMaterial(mat);
|
||||
rootNode->attachChild(model);
|
||||
|
||||
int numChildren = model->getNumChildren();
|
||||
Node *node = model->getChild(1);
|
||||
Mesh *mesh = node->getMesh(0);
|
||||
Skeleton *skeleton = mesh->getSkeleton();
|
||||
|
||||
AnimationController *controller = skeleton->getAnimationController();
|
||||
AnimationChannel *channel = new AnimationChannel(controller);
|
||||
channel->addAnimatable(skeleton->getBone("bone"));
|
||||
channel->setAnimationName("morph");
|
||||
channel->setLoop(true);
|
||||
controller->addAnimationChannel(channel);
|
||||
|
||||
Box *box = new Box(Vector3(1, 1, 1) * .25);
|
||||
Material *boxMat = new Material();
|
||||
boxMat->setTexturingEnabled(false);
|
||||
boxMat->setDiffuseColor(Vector4(1, 0, 0, 1));
|
||||
box->setMaterial(boxMat);
|
||||
skeleton->getBone("bone")->attachMesh(box);
|
||||
|
||||
while(true){
|
||||
root->update();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -123,10 +123,10 @@ namespace vb01{
|
||||
|
||||
if(skybox){
|
||||
glDepthMask(GL_FALSE);
|
||||
//glCullFace(GL_FRONT);
|
||||
glCullFace(GL_FRONT);
|
||||
skybox->update();
|
||||
glDepthMask(GL_TRUE);
|
||||
//glCullFace(GL_BACK);
|
||||
glCullFace(GL_BACK);
|
||||
}
|
||||
|
||||
rootNode->update();
|
||||
|
||||
|
Before Width: | Height: | Size: 723 KiB After Width: | Height: | Size: 723 KiB |
|
Before Width: | Height: | Size: 274 KiB After Width: | Height: | Size: 274 KiB |
|
Before Width: | Height: | Size: 394 KiB After Width: | Height: | Size: 394 KiB |
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 462 KiB After Width: | Height: | Size: 462 KiB |
|
Before Width: | Height: | Size: 588 KiB After Width: | Height: | Size: 588 KiB |
|
Before Width: | Height: | Size: 525 KiB After Width: | Height: | Size: 525 KiB |
|
Before Width: | Height: | Size: 338 KiB After Width: | Height: | Size: 338 KiB |
|
Before Width: | Height: | Size: 953 KiB After Width: | Height: | Size: 953 KiB |
@@ -0,0 +1,62 @@
|
||||
#include "root.h"
|
||||
#include "model.h"
|
||||
#include "material.h"
|
||||
#include "mesh.h"
|
||||
#include "skeleton.h"
|
||||
#include "animationController.h"
|
||||
#include "animationChannel.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace vb01;
|
||||
|
||||
int main(){
|
||||
const string PATH = "../", TEX_PATH = PATH + "samples/textures/", MODEL_PATH = PATH + "samples/models/";
|
||||
string skyboxTextures[] = {
|
||||
TEX_PATH + "top.jpg",
|
||||
TEX_PATH + "bottom.jpg",
|
||||
TEX_PATH + "left.jpg",
|
||||
TEX_PATH + "right.jpg",
|
||||
TEX_PATH + "front.jpg",
|
||||
TEX_PATH + "back.jpg"
|
||||
};
|
||||
|
||||
Root *root = Root::getSingleton();
|
||||
root->start(800, 600, PATH, "Skeletal animation sample");
|
||||
root->createSkybox(skyboxTextures);
|
||||
Node *rootNode = root->getRootNode();
|
||||
|
||||
Camera *cam = root->getCamera();
|
||||
cam->setPosition(Vector3(0, 0, 1) * 20);
|
||||
cam->lookAt(Vector3(0, 0, -1).norm(), Vector3(0, 1, 0).norm());
|
||||
|
||||
Model *model = new Model(MODEL_PATH + "kek.vb");
|
||||
Material *mat = new Material();
|
||||
mat->setLightingEnabled(false);
|
||||
mat->setTexturingEnabled(true);
|
||||
string images[] = {TEX_PATH + "defaultTexture.jpg"};
|
||||
Texture *texture = new Texture(images, 1);
|
||||
mat->addDiffuseMap(texture);
|
||||
model->setMaterial(mat);
|
||||
rootNode->attachChild(model);
|
||||
|
||||
int numChildren = model->getNumChildren();
|
||||
Node *node = model->getChild(1);
|
||||
Mesh *mesh = node->getMesh(0);
|
||||
Skeleton *skeleton = mesh->getSkeleton();
|
||||
|
||||
AnimationController *controller = skeleton->getAnimationController();
|
||||
AnimationChannel *channel = new AnimationChannel(controller);
|
||||
channel->addAnimatable(skeleton->getBone("handIK.R"));
|
||||
channel->addAnimatable(skeleton->getBone("elbowIK.R"));
|
||||
channel->setAnimationName("righArmAnim");
|
||||
channel->setLoop(true);
|
||||
controller->addAnimationChannel(channel);
|
||||
|
||||
skeleton->getBone("handIK.L")->setPosePos(Vector3(1.5, -1.5, 0));
|
||||
|
||||
while(true){
|
||||
root->update();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -13,8 +13,8 @@ using namespace vb01;
|
||||
int main(){
|
||||
Root *root = Root::getSingleton();
|
||||
Node *guiNode = root->getGuiNode();
|
||||
const string PATH = "../", FONT_PATH = PATH + "samples/textSample/fonts/", TEX_PATH = PATH + "samples/textSample/textures/";
|
||||
root->start(800, 600, PATH, "TextSample");
|
||||
const string PATH = "../", FONT_PATH = PATH + "samples/textSample/fonts/", TEX_PATH = PATH + "samples/textures/";
|
||||
root->start(800, 600, PATH, "Text sample");
|
||||
|
||||
int numTexts = 4;
|
||||
wstring texts[] = {
|
||||
@@ -61,11 +61,7 @@ int main(){
|
||||
KeyframeChannel kcA;
|
||||
kcA.animatable = texture;
|
||||
kcA.type = KeyframeChannel::TEXTURE_FRAME_A;
|
||||
Keyframe k0;
|
||||
k0.interpolation = Keyframe::CONSTANT;
|
||||
k0.value = 0;
|
||||
k0.frame = 1;
|
||||
kcA.keyframes = vector<Keyframe>({k0});
|
||||
kcA.keyframes = vector<Keyframe>({KeyframeChannel::createKeyframe(Keyframe::CONSTANT, 0, 1)});
|
||||
|
||||
KeyframeChannel kcB;
|
||||
kcB.animatable = texture;
|
||||
|
||||
|
Before Width: | Height: | Size: 953 KiB |